Repository navigation
irckit: add reactive anti-idle recovery and scope touchActivity to new posts - #1192
Merged
Merged
Conversation
…w posts - Wake runAntiIdle immediately when an ActivityRefresher bridge receives a remote status_change to "away" while SyncAwayStatus is disabled and the IRC user is not locally /AWAY, bypassing lastActivity deferral with a minAntiIdleInterval (30s) cooldown. Because RefreshActivity uses manual=false, automatic server away and Mattermost HA WebSocket unregister rewinds recover to online immediately while manual away, DND, and offline statuses remain preserved. - Move u.touchActivity() out of commands.Run (removing isLocalPrivMsg) and invoke it only on successful post creation in CmdPrivMsg (channel and DM sends), threadMsgChannelUser, and quoteMsgChannelUser so reactions, message edits/deletes, local service/virtual-channel messages, and failed sends no longer defer anti-idle heartbeats. - Add TestRunAntiIdleReactiveWakeOnRemoteAway and replace TestLocalPrivMsgDoesNotTouchActivity with TestPrivMsgLocalAndNonPostDoNotTouchActivity and TestPrivMsgPostCreationTouchesActivity in mm-go-irckit/antiidle_test.go.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Cooldown handling discards remote-away transitions instead of deferring recovery, and the threaded-post test uses an unsupported ID that bypasses the intended code path.
2 open issues
What changed in this PR
Adds reactive anti-idle recovery to the IRC bridge and limits activity tracking to successful post creation.
Changes:
- Wakes anti-idle on eligible remote-away events, with a 30-second cooldown.
- Stops reactions, edits, local messages, and failed sends from deferring heartbeats.
- Adds tests for reactive recovery and post-specific activity tracking.
| File | Description |
|---|---|
mm-go-irckit/userbridge.go |
Adds wake state and remote-away handling. |
mm-go-irckit/server_commands.go |
Records activity after successful post creation. |
mm-go-irckit/commands.go |
Removes blanket PRIVMSG activity tracking. |
mm-go-irckit/antiidle.go |
Adds forced refreshes and reactive cooldown handling. |
mm-go-irckit/antiidle_test.go |
Tests reactive wakes and activity tracking. |
Review effort: Balanced
…x thread test - Defer remote-away reactive refreshes that arrive during the 30s cooldown instead of discarding them by tracking pendingWake and lastWake in antiIdleLoop (removing UserBridge.lastReactiveWake), so a follow-up away transition executes once the remaining cooldown expires while still bypassing lastActivity deferral and rechecking away/status guards. - Log successful reactive anti-idle recoveries at DEBUG level and emit an IRC server NOTICE via sendServerNotice when SyncAwayStatus=false and a remote away status is corrected while not locally /AWAY. - Use a valid 26-character thread ID in TestPrivMsgPostCreationTouchesActivity and assert MsgChannelThread is invoked, and extend TestRunAntiIdleReactiveWakeOnRemoteAway to cover deferred cooldown execution and the server NOTICE.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The cooldown test can fail despite correct behavior because waiting for the NOTICE consumes part of the cooldown, allowing a valid deferred refresh during the failure window.
1 open issue
2 resolved since last review
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
away: WhenSyncAwayStatus = falseon anActivityRefresherbridge (such as Mattermost) and the user is not locally/AWAYon IRC, an incomingstatus_change: awayevent now wakesrunAntiIdleimmediately (bounded by a 30sminAntiIdleIntervalcooldown, bypassinglastActivitydeferral) to callRefreshActivity.Hub.unregisteractivity rewinds within milliseconds instead of waiting up toAntiIdleInterval.away,dnd, andofflinestatuses becauseRefreshActivitysendsmanual=false.touchActivity()scoping: Movedu.touchActivity()out of the blanketPRIVMSGhook inmm-go-irckit/commands.go(removingisLocalPrivMsg) and placed it directly on successful post-creation paths inmm-go-irckit/server_commands.go(CmdPrivMsgchannel/DM sends,threadMsgChannelUser, andquoteMsgChannelUser). Reactions, edits/deletes, local service/virtual-channel messages, and failed sends no longer defer anti-idle heartbeats.Changes
mm-go-irckit/antiidle.go: AddedwakeAntiIdle(),forceparameter toantiIdleStep, and reactive wake handling withminAntiIdleIntervalcooldown inrunAntiIdle.mm-go-irckit/userbridge.go: AddedantiIdleWakechannel andlastReactiveWakeonUserBridge; extractedhandleSelfStatusNoSyncfromhandleSelfStatusChangeEventto triggerwakeAntiIdle()when appropriate.mm-go-irckit/commands.go: Removed blanketPRIVMSGtouchActivity()andisLocalPrivMsg.mm-go-irckit/server_commands.go: Calledu.touchActivity()after successful post creation inCmdPrivMsg,threadMsgChannelUser, andquoteMsgChannelUser.mm-go-irckit/antiidle_test.go: AddedTestRunAntiIdleReactiveWakeOnRemoteAway,TestPrivMsgLocalAndNonPostDoNotTouchActivity, andTestPrivMsgPostCreationTouchesActivity.Testing
go test -count=1 -race ./...golangci-lint rungo build ./...