feat: Improve shell history handoff and session cleanup#80
Conversation
bbsngg
left a comment
There was a problem hiding this comment.
Review Notes
Overall code quality is good. The three features (shell history edit handoff, session-bound shell tabs, session cleanup + PTY replay filtering) work together to form a coherent user flow.
Specific Observations
Server side (server/index.js)
stripReplayTerminalQueries— Clean regex-based filtering of terminal probe sequences (DA1/DA2, DSR, DECRQM). Thereducecreates a new string on each pass, which could matter for very large replay buffers, but is fine for typical use.buildEmbeddedShellEnv— Good idea to stripVSCODE_*,FIG_*,QTERM_*prefixes and specific terminal env vars to avoid interference from the host terminal emulator.- Early return when
stripReplayTerminalQueriesproduces an empty string avoids sending empty output messages — nice.
Session deletion (server/projects.js)
- Both Gemini and generic branches now call
sessionDb.deleteSession(sessionId)to clean up index rows. ThematchedFiles/removedEntriesapproach is more robust than the previous "throw if not found" logic.
Frontend — shell history edit flow
- Modal in
ChatInterface.tsx(fixed inset-0 z-50 overlay + dialog, click-to-dismiss backdrop) is straightforward. latestEditableUserMessageinChatMessagesPane.tsxcorrectly limits the "Edit message history" button to only the last user message.- Session shell tab in
ShellWorkspace.tsxuses thesession-shell:prefix to distinguish from plain tabs; close-tab fallback logic is complete.
i18n — All three locales (en, ko, zh-CN) have the new historyEdit keys. Complete.
Suggestions
-
activeShellIdleaks into localStorage — The persistence effect (line 143) savesactiveShellIdas-is, including when it is asession-shell:*value. On next load,loadWorkspaceStatewon't find it inshellsand falls back tostoredShells[0].id, so there is no functional bug, but localStorage will contain a stale session shell id. Consider filtering before persisting:const persistedActiveId = activeShellId.startsWith('session-shell:') ? shells[0]?.id ?? activeShellId : activeShellId;
-
loadWorkspaceStateclosure in effect —loadWorkspaceStatecapturesstorageKeyandcreateShellInstance(which depends ont), but the effect dependency array is only[storageKey]. Iftchanges (e.g. language switch), shell tab titles won't update. Minor issue, unlikely to affect real usage.
LGTM with the suggestion above (item 1) as a nice-to-have cleanup.
Avoid writing transient session-shell:* activeShellId into localStorage, which would become stale on next load. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Addressed review suggestion #1 in commit a551b85:
Suggestion #2 (effect dependency on |
Summary
Testing