fix(resume-patterns): return the most recent resume command from scrollback - #364
Open
dormouse-bot wants to merge 1 commit into
Open
fix(resume-patterns): return the most recent resume command from scrollback#364dormouse-bot wants to merge 1 commit into
dormouse-bot wants to merge 1 commit into
Conversation
…llback detectResumeCommand matched each pattern against the whole scrollback with a non-global regex, which returns the first (oldest) occurrence. A pane that resumed more than once prints a fresh resume hint each time, so the persisted resumeCommand pointed at a stale session id. Scan lines newest-first instead, returning the most recent match across all patterns. Adds regression tests for repeated same-command hints and for most-recent-wins across pattern types; both fail against the old first-match logic.
Deploying mouseterm with
|
| Latest commit: |
f2ca6d6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a3091070.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-resume-patterns-most-rec.mouseterm.pages.dev |
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.
Problem
detectResumeCommandscanned scrollback by matching each pattern against the whole joined text with a non-global regex:String.matchwith a non-global regex returns the first occurrence, i.e. the chronologically oldest one in the scrollback. When a pane resumes an agent more than once, each run prints its own resume hint (codex resume <id>), so the buffer holds several.session-save.tspersists the returned command asresumeCommandso a restored pane can resume the current session — but it was getting the stale, oldest id.There was also a secondary recency bug across pattern types:
codexwas always checked beforeclaude, so an oldercodex resumewon over a more recentclaude --resume.Fix
Scan the last 50 lines newest-first and return the first match found, which is the most recent resume command regardless of type. Behavior for single-occurrence scrollback is unchanged.
Tests
Added two regression tests — repeated same-command hints (most recent wins) and most-recent-wins across pattern types. Both fail against the old first-match logic and pass with the fix. The existing seven tests are unchanged and still pass.