fix(editor): preserve unsaved Monaco edits across tab switches - #36
Merged
Conversation
Wire a focus/blur signal from the frontend (TerminalPanel) through the terminal WS into the agent status engine so the idle-timeout watchdog and the watchers' re-bind pass can account for which terminal pane the user is currently driving. - terminal: add OnPtyFocus callback and a `focus` message type handled in HandleTerminalWS. - agent: track ptyFocus (single-focus map) with IsPtyFocused accessor; clean up on session exit. - idle-timeout watchdog: exempt the focused PTY from the auto-revert to idle even when its output has gone quiet (the user may be mid-prompt or reading a long answer). - watchers (claude/codex/copilot/opencode): allow the re-bind to fire when the PTY is focused even without recent PTY output, so a /new or /resume issued in the focused pane re-binds before the agent emits bytes; an unfocused PTY stays conservative and won't steal a sibling's session. - frontend: TerminalPanel sends focus/blur on isActive changes and mirrors the flag onto TerminalInstance so connectWs.onopen re-sends it after a reconnect, preventing stale unfocused state.
Cache dirty editor content per filePath in a module-level store so switching tabs/panes and returning restores in-memory edits instead of reloading from disk. Cache is cleared on successful save, explicit reload, or disk-conflict resolution. Fixes #35
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.
Fixes #35
Summary
Unsaved edits in the Monaco File Editor were lost whenever the user switched tabs/panes and came back, because
EditorPanelreloaded the file from disk on everyfilePathchange, overwritingeditedContent.Changes
dirtyContentCache: Map<filePath, {dirty, original}>inEditorPanel.filePathchange, if a cached dirty entry exists, it is restored (preserving the* unsavedstate) instead of fetching from disk.handleEditorChangewrites to the cache on every keystroke.handleSaveclears the cache on successful save.silentReload(used by "Reload" on disk conflict) clears the cache so the on-disk version wins.Validation
make lint✅make build✅