Skip to content

Commit

Permalink
inbox browser: add announcements for automatic self-update notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover committed Nov 18, 2024
1 parent 99deffa commit f360a5a
Show file tree
Hide file tree
Showing 98 changed files with 533 additions and 27 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ name: Tests
on: [push, workflow_dispatch]

jobs:
build:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: smalltalkci
uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Squeak64-Trunk
- run: smalltalkci -s ${{ steps.smalltalkci.outputs.smalltalk-image }}
- run: smalltalkci -s ${{ steps.smalltalkci.outputs.smalltalk-image }} tests.smalltalk.ston
timeout-minutes: 15
env:
# for uploading coverage reports
GITHUB_TOKEN: ${{ github.token }}

jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: smalltalkci
uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Squeak64-Trunk
- run: smalltalkci -s ${{ steps.smalltalkci.outputs.smalltalk-image }} jobs.smalltalk.ston
timeout-minutes: 15
env:
SIT_GIST_TOKEN: ${{ secrets.SIT_GIST_TOKEN }}
3 changes: 2 additions & 1 deletion .squot
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ OrderedDictionary {
'packages/BaselineOfSqueakInboxTalk.package' : #SquotCypressCodeSerializer,
'packages/SqueakInboxTalk.package' : #SquotCypressCodeSerializer,
'packages/SqueakInboxTalkTests.package' : #SquotCypressCodeSerializer,
'packages/SqueakInboxTalkExtras-Semantics.package' : #SquotCypressCodeSerializer
'packages/SqueakInboxTalkExtras-Semantics.package' : #SquotCypressCodeSerializer,
'packages/SqueakInboxTalkJobs.package' : #SquotCypressCodeSerializer
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
cleanUpTimeStamps

LatestTimeStamps := nil.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
latestTimeStampFor: spec

^ (self latestTimeStampsFor: spec) max
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
accessing
latestTimeStampForPackage: aPackageInfo

^ (LatestTimeStamps ifNil: [LatestTimeStamps := Dictionary new])
at: aPackageInfo name ifAbsentPut:
[(aPackageInfo methods collect: [:method |
[TimeStamp fromMethodTimeStamp: method timeStamp] ifError: [TimeStamp new]])
max]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
accessing
latestTimeStampsFor: spec

^ (((self project version allPackagesForSpecNamed: spec)
collect: [:packageSpec | packageSpec workingCopy packageInfo])
, {self packageInfo. (Smalltalk classNamed: #BaselineOfSqueakHistory) package})
collect: [:package | package -> (self latestTimeStampForPackage: package)]
as: Dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ baseline: spec
requires: 'SqueakHistory';
postLoadDoIt: #postLoad].
spec package: 'SqueakInboxTalkExtras-Semantics' with: [
spec requires: #('SqueakInboxTalk' 'SemanticText')].
spec
requires: #('SqueakInboxTalk' 'SemanticText');
postLoadDoIt: #postLoadGeneric].
"test packages"
spec package: 'SqueakInboxTalkTests' with: [spec requires: #(#app)].

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scripts
postLoad

self postLoadMailingLists
self postLoadGeneric.
self postLoadMailingLists.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scripts
postLoadGeneric

self class cleanUpTimeStamps.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"class" : {
},
"cleanUpTimeStamps" : "ct 11/18/2024 02:08",
"latestTimeStampFor:" : "ct 11/18/2024 02:23",
"latestTimeStampForPackage:" : "ct 11/18/2024 02:22",
"latestTimeStampsFor:" : "ct 11/18/2024 20:26" },
"instance" : {
"baseline:" : "ct 11/17/2024 23:16",
"baseline:" : "ct 11/18/2024 02:08",
"initializeSqhPreferences" : "ct 11/17/2024 23:26",
"installDependencies" : "ct 11/17/2024 23:17",
"isCI" : "ct 10/15/2022 21:23",
"openWelcomeContentsSync" : "ct 7/8/2021 21:00",
"postLoad" : "ct 5/26/2021 15:42",
"postLoad" : "ct 11/18/2024 02:08",
"postLoadGeneric" : "ct 11/18/2024 02:08",
"postLoadMailingLists" : "ct 7/8/2021 21:00",
"projectClass" : "ct 5/26/2021 15:29" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"classinstvars" : [
],
"classvars" : [
],
"LatestTimeStamps" ],
"commentStamp" : "",
"instvars" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*SqueakInboxTalk-UI-testing
isTalkAnnouncement

^ false
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"involvementFor:" : "ct 7/24/2021 03:10",
"involvementState" : "ct 6/16/2021 16:27",
"involvementStateFor:" : "ct 6/15/2021 19:49",
"isTalkAnnouncement" : "ct 11/18/2024 03:32",
"latestDate" : "ct 5/7/2021 15:38",
"mailConversation" : "ct 5/7/2021 15:06",
"mailConversation:" : "ct 5/7/2021 15:07",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildButtonBar: aBuilder
model: self;
label: 'Reply';
action: #reply;
enabled: #hasActualMessageSelected;
enabled: #canReply;
yourself);
add: (aBuilder pluggableActionButtonSpec new
model: self;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
canReply

^ self hasActualMessageSelected and: [self selectedMessage isTalkAnnouncement not]
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
"browseAttachmentsColor" : "ct 6/22/2023 17:15",
"browseAttachmentsLabel" : "ct 6/22/2023 17:15",
"browseContributions" : "ct 6/25/2023 21:22",
"buildButtonBar:" : "ct 7/2/2023 23:26",
"buildButtonBar:" : "ct 11/18/2024 03:49",
"buildContentPane:" : "ct 5/14/2023 19:46",
"buildFilterBar:" : "ct 7/22/2021 16:17",
"buildMessageList:" : "ct 6/2/2023 20:01",
"buildMessagePane:" : "ct 5/12/2023 18:01",
"buildSearchBar:" : "ct 7/22/2021 16:17",
"buildWith:" : "ct 5/12/2023 17:57",
"canReply" : "ct 11/18/2024 03:50",
"conversation" : "ct 4/30/2021 00:06",
"conversation:" : "ct 6/22/2023 22:20",
"currentText" : "ct 8/21/2023 02:43",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
announcements
allAnnouncementSelectors

^ (Pragma allNamed: #talkAnnouncement in: self class)
collect: [:pragma | pragma selector]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
self-updating
checkSelfUpdatesIfFound: dateBlock

| selfUpdateTimeStamps response selfUpdateTimeStampsUrl hasUpdates |
selfUpdateTimeStampsUrl := 'https://gist.githubusercontent.com/LinqLover/36dd3c4a155eed5aa7e874415cd60eea/raw/{1}.json' format: {('latestTimeStamps/{1}' format: {"self selfUpdateBranch"nil}) asFileName encodeForHTTP}.
response := WebClient httpGet: selfUpdateTimeStampsUrl.
response isSuccess ifFalse: [^ false].

selfUpdateTimeStamps := response content parseAsJson timeStamps
collect: [:ea | ea asDateAndTime asTimeStamp].

hasUpdates := self latestPackageTimeStamps associations anySatisfy: [:packageInfoAndTimeStamp |
selfUpdateTimeStamps
at: packageInfoAndTimeStamp key name
ifPresent: [:selfUpdateTimeStamp | selfUpdateTimeStamp > packageInfoAndTimeStamp value]
ifAbsent: [true]].

^ "hasUpdates"true ifTrue: [dateBlock value: selfUpdateTimeStamps max asDateAndTime]
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ initialize-release
cleanUp: aggressive

aggressive ifTrue: [
UseSimpleIcons := nil].
Icons := Dictionary new
InboxAgeForDanger := InboxAgeForWarning := SelfUpdateMetacelloSpec := SelfUpdateBranch := ShowAnnouncements := UseSimpleIcons := nil].
HiddenAnnouncementSelectors := nil.
Icons := Dictionary new.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
feedback
defaultFeedbackText

| latestTimeStamp |
latestTimeStamp := (self packageInfo methods collect: [:method | TimeStamp fromMethodTimeStamp: method timeStamp]) max.
^ '<br><br><i>Reported from {1}, for version of {2} last updated at {3}.</i>' asTextFromHtml format: {SystemVersion current. self appName. latestTimeStamp}
^ '<br><br><i>Reported from {1}, for version of {2} last updated at {3}.</i>' asTextFromHtml format: {SystemVersion current. self appName. self latestTimeStamp}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
announcements
hideAnnouncementSelector: selector

(HiddenAnnouncementSelectors ifNil: [HiddenAnnouncementSelectors := Set new])
add: selector.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
self-updating
latestPackageTimeStamps

^ (Smalltalk classNamed: #BaselineOfSqueakInboxTalk)
latestTimeStampsFor: self basicSelfUpdateMetacelloSpec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
self-updating
latestTimeStamp

^ (self environment classNamed: #BaselineOfSqueakInboxTalk) ifNotNil: [:baseline |
baseline latestTimeStampFor: self basicSelfUpdateMetacelloSpec]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
announcements
pendingAnnouncements

self shouldShowAnnouncements ifFalse: [^ #()].

^ Array streamContents: [:stream |
self checkSelfUpdatesIfFound: [:date | stream nextPut: (self selfUpdateAnnouncementFor: DateAndTime today - 5 days"date")].
(self allAnnouncementSelectors copyWithoutAll: (HiddenAnnouncementSelectors ifNil: [#()])) do: [:selector |
stream nextPut: (self perform: selector)]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
announcements
resetAnnouncements

HiddenAnnouncementSelectors := nil.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
announcements
selfUpdateAnnouncementFor: aDateAndTime

| changes changesSummary |
changesSummary := 'This might include new features, bug fixes, or performance improvements.'.
changes :=
[| response |
response := WebClient httpGet: ('https://api.github.com/repos/{1}/{2}/commits?sha={3}&since={4}' format:
{self githubRepositoryParams first.
self githubRepositoryParams second.
self selfUpdateBranch.
aDateAndTime asString}).
response isSuccess ifFalse: [self error: response content].
response content parseAsJson collect: [:ea | ea commit message]]
ifError: [:msg | 'Error retrieving changes: {1}' format: {msg}].
(changes isArray and: [TalkInbox enableSemanticSearch]) ifTrue:
[| changesHash |
changesHash := changes hash.
(thisContext homeMethod propertyValueAt: #changesHash ifAbsent: []) = changesHash
ifTrue: [changesSummary := thisContext homeMethod propertyValueAt: #changesSummary]
ifFalse:
[[changesSummary := (Smalltalk classNamed: #SemanticConversation) new
addSystemMessage: ('Summarize the following changes to Squeak Inbox Talk (which is a mailing list client for squeak-dev) in a single very short sentence. The changes are provided as technical commit messages. The sentence should have the form "This..." and be very short.
If you very unsure about the nature of the changes, answer "{1}" instead.
Audience: Users of the tool.' format: {changesSummary});
addUserMessage: changes asJsonString;
in: [:conversation |
(Smalltalk classNamed: #SemanticText) registeredConversationModels
detect: [:model | model name = (Smalltalk classNamed: #OpenAIConversationModel) cheapestName]
ifFound: [:model | conversation model: model]];
getAssistantReply.
thisContext homeMethod propertyValueAt: #changesSummary put: changesSummary.
thisContext homeMethod propertyValueAt: #changesHash put: changesHash]
ifError: [:msg | changesSummary := '{1} (Error retrieving summary: {2}.)' format: {changesSummary. msg}]]].

^ TalkInboxBrowserAnnouncement
date: aDateAndTime
subject: ('Updates for {1} are available' format: {self appName})
content: ('New updates for {appName} are available. {changesSummary} It is recommended to install {appName} updates together with Squeak updates.
You can <a href="{codeInstallUpdates}">install the updates now</a> or <a href="{changesUrl}">inspect the changes on GitHub first</a>.
New changes:
{changes}'
format:
(Dictionary new
at: #appName put: self appName;
at: #codeInstallUpdates put: 'code:// TalkInboxBrowser selfUpdate. nil';
at: #changesUrl put:
('https://github.com/{1}/{2}/commits/{3}' format: {
self githubRepositoryParams first.
self githubRepositoryParams second.
self selfUpdateBranch});
at: #changesSummary put: changesSummary;
at: #changes put: (changes isArray ifTrue: [changes ifEmpty: ['(not found)'] ifNotEmpty: [(changes collect: [:ea | '* ' , (ea lines at: 1 ifAbsent: [''])]) joinSeparatedBy: String cr]] ifFalse: [changes]);
yourself))
talkAsTextFromHtmlWithCRs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
preferences
shouldShowAnnouncements: aBoolean

aBoolean ifTrue:
[(self confirm: 'Reset all announcements?') ifTrue:
[self resetAnnouncements]].
ShowAnnouncements := aBoolean.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
preferences
shouldShowAnnouncements
<preference: 'Show announcements in inbox browser' category: #'Squeak Inbox Talk' description: 'Learn about new features in Squeak Inbox Talk when browsing mailing lists.' type: #Boolean>

^ ShowAnnouncements ifNil: [true]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ conversationColumns
ifFalse:
[((cachedConversationColumns ifNil: [cachedConversationColumns := Dictionary new])
at: columnIndex ifAbsentPut: [WeakIdentityKeyDictionary new])
at: conversation ifAbsentPut: [columnBlock value: conversation]]
at: conversation ifAbsentPut:
[| text |
text := columnBlock value: conversation.
conversation isTalkAnnouncement ifTrue:
[text := text asText
addAttribute: TextEmphasis bold;
yourself].
text]]
ifTrue:
[columnIndex = 1
ifTrue: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ conversation gathering
gatherConversationsOn: aStream

| newConversations filteredConversations |
aStream nextPutAll: self pendingAnnouncements.

newConversations := self allConversations readStream.

filteredConversations := self totalFilter filter: newConversations.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
pendingAnnouncements

^ pendingAnnouncements ifNil: [pendingAnnouncements :=
self class pendingAnnouncements]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ refreshMessages

Project uiManager
informUser: 'Refreshing messages...'
during: [self inbox refreshMessages].
during:
[self refreshPendingAnnouncements.
self inbox refreshMessages].

allConversations := nil.
self changed: #allConversations
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
refreshPendingAnnouncements

pendingAnnouncements := nil.
self pendingAnnouncements.
Loading

0 comments on commit f360a5a

Please sign in to comment.