Skip to content

feat: Improve shell history handoff and session cleanup#80

Merged
Zhang-Henry merged 2 commits intomainfrom
fix/shell-history-handoff
Mar 23, 2026
Merged

feat: Improve shell history handoff and session cleanup#80
Zhang-Henry merged 2 commits intomainfrom
fix/shell-history-handoff

Conversation

@bbsngg
Copy link
Copy Markdown
Contributor

@bbsngg bbsngg commented Mar 23, 2026

Summary

  • route chat-side history edit requests into shell with an explicit confirmation flow instead of pretending to rewrite message history in Web Chat
  • keep session-bound shell tabs alongside regular shells, make the session tab dismissible, and preserve multi-shell workspace behavior
  • harden session deletion and embedded shell reconnect handling by cleaning session index rows and filtering terminal probe sequences from PTY replay

Testing

  • npm run typecheck
  • npm run build

Copy link
Copy Markdown
Contributor Author

@bbsngg bbsngg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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). The reduce creates a new string on each pass, which could matter for very large replay buffers, but is fine for typical use.
  • buildEmbeddedShellEnv — Good idea to strip VSCODE_*, FIG_*, QTERM_* prefixes and specific terminal env vars to avoid interference from the host terminal emulator.
  • Early return when stripReplayTerminalQueries produces 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. The matchedFiles / removedEntries approach 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.
  • latestEditableUserMessage in ChatMessagesPane.tsx correctly limits the "Edit message history" button to only the last user message.
  • Session shell tab in ShellWorkspace.tsx uses the session-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

  1. activeShellId leaks into localStorage — The persistence effect (line 143) saves activeShellId as-is, including when it is a session-shell:* value. On next load, loadWorkspaceState won't find it in shells and falls back to storedShells[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;
  2. loadWorkspaceState closure in effectloadWorkspaceState captures storageKey and createShellInstance (which depends on t), but the effect dependency array is only [storageKey]. If t changes (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>
@bbsngg
Copy link
Copy Markdown
Contributor Author

bbsngg commented Mar 23, 2026

Addressed review suggestion #1 in commit a551b85:

  • Filter session-shell:* from activeShellId before writing to localStorage, falling back to the first plain shell id. This prevents stale session shell ids from persisting across page reloads.

Suggestion #2 (effect dependency on t) is intentionally skipped — the impact is negligible and the fix would add complexity without practical benefit.

@Zhang-Henry Zhang-Henry merged commit 6b07f03 into main Mar 23, 2026
1 check passed
@bbsngg bbsngg changed the title Improve shell history handoff and session cleanup feat: Improve shell history handoff and session cleanup Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants