Skip to content

feat: scope terminal shell history per worktree - #620

Merged
AmethystLiang merged 4 commits into
mainfrom
fix-worktree-console-log-crossing
Apr 14, 2026
Merged

AmethystLiang merged 4 commits into
mainfrom
fix-worktree-console-log-crossing

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

  • Adds worktree-scoped shell history so each worktree gets its own HISTFILE — ArrowUp no longer surfaces commands from other worktrees
  • Integrates with the new LocalPtyProvider architecture: history env injection runs after buildSpawnEnv but before spawnShellWithFallback, and onBeforeFallbackSpawn keeps HISTFILE in sync when the shell falls back
  • Adds terminalScopeHistoryByWorktree setting (defaults to true) for users who prefer shared global history
  • Cleans up per-worktree history directories on worktree removal and runs background GC for orphaned dirs
  • Passes worktreeId through the renderer → preload → main IPC chain to enable history scoping

Test plan

  • Unit tests for terminal-history scoping in terminal-history.test.ts
  • Typecheck passes (only pre-existing ssh2 module errors)
  • Manual: open two worktrees, run distinct commands in each, verify ArrowUp shows only local history
  • Manual: delete a worktree and verify its history dir is cleaned up

Each worktree gets its own HISTFILE so ArrowUp only surfaces commands
from the current worktree. Integrates with the new LocalPtyProvider
architecture: history env injection runs after buildSpawnEnv but before
spawnShellWithFallback, and onBeforeFallbackSpawn keeps HISTFILE in
sync when the shell falls back.
Add missing command field to PtyApi.spawn in index.d.ts to match
the runtime index.ts signature, fixing TS2769 overload conflict.
The deleteWorktreeHistoryDir import pulls in electron's app module.
Add a vi.mock so the test doesn't hit the real electron export.
@AmethystLiang
AmethystLiang merged commit 130c3e9 into main Apr 14, 2026
1 check passed
@AmethystLiang
AmethystLiang deleted the fix-worktree-console-log-crossing branch April 14, 2026 05:42
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

looking into it

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* feat: scope terminal shell history per worktree

Each worktree gets its own HISTFILE so ArrowUp only surfaces commands
from the current worktree. Integrates with the new LocalPtyProvider
architecture: history env injection runs after buildSpawnEnv but before
spawnShellWithFallback, and onBeforeFallbackSpawn keeps HISTFILE in
sync when the shell falls back.

* fix: align preload type declaration with implementation

Add missing command field to PtyApi.spawn in index.d.ts to match
the runtime index.ts signature, fixing TS2769 overload conflict.

* chore: remove terminal-history-scope-design.md from tracked files

* fix: mock terminal-history in worktrees test

The deleteWorktreeHistoryDir import pulls in electron's app module.
Add a vi.mock so the test doesn't hit the real electron export.
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.

1 participant