Skip to content

feat: reopen recent sessions at startup, plus PowerShell cwd and long voice fixes - #83

Merged
SPhillips1337 merged 4 commits into
mainfrom
feat/launch-picker
Nov 9, 2026
Merged

SPhillips1337 merged 4 commits into
mainfrom
feat/launch-picker

Conversation

@SPhillips1337

Copy link
Copy Markdown
Contributor

Summary

Four commits, each a separate change:

  • Recent sessions at startup (feat(sessions)): a launch picker shows up to eight recently open sessions as cards, and clicking one opens it again.
    • Screen sessions reattach through planSessionRestore, the same rule the history list and workspace restore use.
    • Plain local shells reopen with their backend. When the new opt-in Remember directories setting is on, they reopen in the directory they were last in.
    • Plain SSH shells open in the remote home directory.
    • The list is kept in a new main-process store, recent-sessions.json, because workspace memory only keeps panes that can be reattached.
    • Directories are saved only while the setting is on, and turning it off deletes them.
    • The picker is skipped for --cwd / ZEROG_OPEN_CWD launches. It can be turned off from the picker itself or in Settings → Sessions, and Esc closes it.
  • PowerShell / cmd directory tracking (feat(cwd)): local PowerShell, pwsh and cmd panes now read the PS C:\…> and C:\…> prompts and Windows OSC 7, so the breadcrumb, directory browser and picker follow cd. Remote, WSL and Git Bash panes still only report POSIX paths. The PowerShell integration snippet's OSC 7 was malformed (file://HOSTC:\…); it now writes file://HOST/C:/…, and the old form is still read.
  • Every local shell backend over IPC (fix(sessions)): sessions:createLocal only allowed bash, zsh, powershell and wsl, so pwsh, cmd, fish and sh quietly became the default shell. It now uses the shell catalog's isLocalShellBackend.
  • Long voice recordings (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) and npm run build pass on the branch head.
  • The cards, sessions and cwd commits were each checked on their own: typecheck plus the full suite, run on an exported copy of the index.
  • New tests: tests/recent-sessions.test.ts (store, recording, plans) and Windows cases in tests/cwd-tracker.test.ts.
  • The fixed snippet's OSC 7 URL was generated in real PowerShell and parsed back to the correct path.
  • In the app: the picker appeared and opened a PowerShell session. That run found the missing-directory bug fixed here.

Not yet checked in the running app:

  • a PowerShell pane reopening in the directory it was left in;
  • a voice recording longer than 30 seconds through the built-in model.

🤖 Generated with Claude Code

Stephen Phillips and others added 4 commits November 9, 2026 15:05
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>
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

  1. src/main/recent-session-store.ts line 96 — The key field cap of 600 characters is too low given that recentKey() builds the key from JSON.stringify of multiple fields (including sshTarget up to 256 chars). Keys exceeding 600 chars are silently dropped, causing sessions to permanently disappear from the picker after the first restart.

  2. src/renderer/recent-sessions.ts lines 84–85 — cwd is unconditionally stored into the entry in the loop body, then stripped in post-processing. While the final returned value is correct, the rememberDirectories guard 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.
  • isLocalShellBackend fix for sessions:createLocal — closes the silent default-shell regression.
  • Windows OSC 7 dual-form parsing (parseWindowsOsc7Payload) — both URL and legacy forms handled correctly.
  • recordRecents timestamp 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 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).

Comment on lines +84 to +85
const cwd = rememberableCwd(session.cwd);
if (cwd) entry.cwd = cwd;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 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.

Suggested change
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];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 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.

@SPhillips1337
SPhillips1337 merged commit a4341d0 into main Nov 9, 2026
1 of 3 checks passed
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