Repository navigation
feat: reopen recent sessions at startup, plus PowerShell cwd and long voice fixes - #83
Conversation
sessions:createLocal only passed bash, zsh, powershell and wsl through, so a pwsh, cmd, fish or sh request silently fell back to the default shell. Use the shell catalog's own isLocalShellBackend so the list cannot drift again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A launch picker lists up to eight recently open sessions; clicking one opens it again. Screen-backed sessions go through planSessionRestore, the rule the history list and workspace restore already share. Plain local shells reopen with their backend and, when "Remember directories" is on, in the directory they were last in. Plain SSH shells open in the remote home directory. Recent sessions live in a new main-process store, recent-sessions.json, because workspace memory only keeps panes that can be reattached. Directories are written only while the opt-in setting is on, and turning it off forgets them. The picker is skipped for --cwd / ZEROG_OPEN_CWD launches, can be turned off from the picker or in Settings, and closes with Esc. The --cwd deep link now shares an openLocalPane helper with the picker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tracker only read POSIX prompts, so a PowerShell pane kept reporting the directory it started in: the breadcrumb, the directory browser and the launch picker all saw a stale path. Local PowerShell, pwsh and cmd panes now also read the default `PS C:\...>` and `C:\...>` prompts and a Windows OSC 7. SSH, WSL and Git Bash panes still only report POSIX paths, which the transfer panel relies on. The PowerShell integration snippet wrote OSC 7 as `file://HOSTC:\...`, which nothing could parse. It now writes `file://HOST/C:/...`, and the old form is still read for profiles that have it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The built-in Whisper pipeline was called without chunking, so it padded or truncated every recording to one 30-second window and silently dropped the rest. Recordings over 30 seconds are now transcribed in overlapping chunks; shorter ones are unchanged. The maximum utterance limit goes from 120 to 300 seconds, and its default from 30 to 120. Also removes MAX_UTTERANCE_SECONDS, which nothing used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
There was a problem hiding this comment.
Review Summary
This PR introduces four well-scoped changes: recent session picker at startup, PowerShell/cmd cwd tracking, shell backend fix for sessions:createLocal, and long-voice chunking for the built-in Whisper pipeline. The overall structure and input validation are thorough.
Issues Found
Note: One of the line-specific comments I posted (src/main/recent-session-store.ts line 71 on persist()) was a false positive — the await this.writeQueue pattern is correct and intentional there, ensuring save() callers receive confirmation that the write completed. Please disregard that comment.
The two remaining line-specific comments flag real issues:
-
src/main/recent-session-store.tsline 96 — Thekeyfield cap of 600 characters is too low given thatrecentKey()builds the key fromJSON.stringifyof multiple fields (includingsshTargetup to 256 chars). Keys exceeding 600 chars are silently dropped, causing sessions to permanently disappear from the picker after the first restart. -
src/renderer/recent-sessions.tslines 84–85 —cwdis unconditionally stored into the entry in the loop body, then stripped in post-processing. While the final returned value is correct, therememberDirectoriesguard should be applied at the point of assignment so the intent is clear and any future refactor of the post-processing step doesn't accidentally leak paths.
No Issues Found In
- Voice chunking logic (
longAudioOptions) — correct threshold and stride. isLocalShellBackendfix forsessions:createLocal— closes the silent default-shell regression.- Windows OSC 7 dual-form parsing (
parseWindowsOsc7Payload) — both URL and legacy forms handled correctly. recordRecentstimestamp stamping logic — correct one-per-run behavior.- Schema validation in
normalizeFile— control character stripping, sort, dedup and cap all look correct.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| // Remembering recent sessions must never affect terminal operation. | ||
| } | ||
| }); | ||
| await this.writeQueue; |
There was a problem hiding this comment.
🛑 Logic Error: persist() awaits this.writeQueue after re-assigning it to the new promise chain. This means every call to persist() will wait for the entire chain (including the newly appended work) to settle before returning, rather than just enqueuing the write. The intent of a write queue is to serialize writes without blocking the caller on all pending work — the current implementation causes save() to hang until every previously queued write, plus the new one, completes. If multiple rapid saves occur (e.g., directory updates from prompt reads), each save() call will await all prior writes, stacking the latency.
Replace the last line of persist() with return this.writeQueue; so that each caller only awaits its own write being enqueued, and the queue itself serializes the disk I/O without holding up later callers unnecessarily — or drop await this.writeQueue entirely if fire-and-forget is the intent (consistent with the "best-effort" comment on the class).
| const cwd = rememberableCwd(session.cwd); | ||
| if (cwd) entry.cwd = cwd; |
There was a problem hiding this comment.
🛑 Logic Error: The recordRecents function unconditionally records cwd onto the entry regardless of the rememberDirectories setting. The cwd is stripped from existing entries on lines 90–92, but for a session currently being processed in the for loop (lines 70–88), a non-null cwd is always written to entry.cwd (line 85) before it reaches the post-processing strip. This means that during the same tick a session first appears while rememberDirectories is false, its cwd is written into byKey and will be sent to recentSessionStore.save() before the setting-based strip on line 92 removes it — creating a race where cwd can transiently reach the IPC boundary and the persisted JSON file.
| const cwd = rememberableCwd(session.cwd); | |
| if (cwd) entry.cwd = cwd; | |
| const cwd = options.rememberDirectories ? rememberableCwd(session.cwd) : undefined; | |
| if (cwd) entry.cwd = cwd; |
| export function readCwd(buffer: string): CwdReading | null { | ||
| export function readCwd(buffer: string, options?: { windows?: boolean }): CwdReading | null { | ||
| let payload: string | null = null; | ||
| for (const match of buffer.matchAll(OSC7)) payload = match[1]; |
There was a problem hiding this comment.
🛑 Logic Error: parseWindowsPromptPath strips OSC sequences and CSI sequences from the buffer before matching, but the OSC_ANY regex used here is the same global regex instance (/g flag) shared with readCwd and parsePromptPath. Because RegExp instances with the g flag maintain lastIndex state, calling .replace() with a shared global regex is safe (replace resets lastIndex), but calling .matchAll() with a shared global regex in readCwd (line 84) will carry stale lastIndex between calls if the same regex object is used concurrently. In readCwd, OSC7.matchAll() is used — OSC7 is a module-level global regex with the g flag. If readCwd is called while a prior iteration of buffer.matchAll(OSC7) is still in flight (e.g., from a different pane), the shared lastIndex will cause the second call to start mid-string and silently miss OSC 7 sequences at the beginning of the buffer, resulting in directory reads being dropped.
| if (!value || typeof value !== 'object') return undefined; | ||
| const item = value as Record<string, unknown>; | ||
| if (item.kind !== 'local' && item.kind !== 'ssh') return undefined; | ||
| const key = optionalText(item.key, 600); |
There was a problem hiding this comment.
🛑 Logic Error: The key field is capped at 600 characters in optionalText, but recentKey() in the renderer builds the key by JSON.stringify-ing up to 6 fields — including sshTarget (allowed up to 256 chars) and name (up to 64 chars). A valid sshTarget near the 256-char limit plus the surrounding JSON structure can easily exceed 600 characters. Any session entry whose key exceeds 600 characters will be silently dropped by normalizeEntry (key returns undefined, causing the entry to be discarded at line 99), making the session permanently disappear from the picker after the first app restart even though it was validly saved.


Summary
Four commits, each a separate change:
feat(sessions)): a launch picker shows up to eight recently open sessions as cards, and clicking one opens it again.planSessionRestore, the same rule the history list and workspace restore use.recent-sessions.json, because workspace memory only keeps panes that can be reattached.--cwd/ZEROG_OPEN_CWDlaunches. It can be turned off from the picker itself or in Settings → Sessions, and Esc closes it.feat(cwd)): local PowerShell, pwsh and cmd panes now read thePS C:\…>andC:\…>prompts and Windows OSC 7, so the breadcrumb, directory browser and picker followcd. Remote, WSL and Git Bash panes still only report POSIX paths. The PowerShell integration snippet's OSC 7 was malformed (file://HOSTC:\…); it now writesfile://HOST/C:/…, and the old form is still read.fix(sessions)):sessions:createLocalonly allowed bash, zsh, powershell and wsl, so pwsh, cmd, fish and sh quietly became the default shell. It now uses the shell catalog'sisLocalShellBackend.fix(voice)): the built-in Whisper pipeline ran without chunking, so only the first 30 seconds of any recording was transcribed. Recordings over 30 seconds are now transcribed in overlapping chunks. The maximum utterance limit goes from 120 to 300 seconds, with a default of 120 instead of 30. Existing users keep whatever value they have saved.Testing
npm run typecheck,npm test(1192 passed, 3 skipped) andnpm run buildpass on the branch head.tests/recent-sessions.test.ts(store, recording, plans) and Windows cases intests/cwd-tracker.test.ts.Not yet checked in the running app:
🤖 Generated with Claude Code