feat(v0.3): M6 — new tab opens in the active tab's directory

- title-util.cwdFromOsc7: parse cwd from OSC 7 (file:// URL); 4 unit tests
- terminal-session: register OSC 7 handler → cwd getter; opts.cwd → sent in the
  attach frame on a fresh session
- protocol/types: ClientMessage attach.cwd (absolute path); validated
- session/manager/server: thread cwd → createSession spawn cwd (defaults homeDir)
- tabs: '+' (newTab) opens in the active tab's reported cwd, falls back to home
- Verified: server attach.cwd spawns there; cd /private/tmp → + → new tab pwd is
  /private/tmp. 212 tests green.
This commit is contained in:
Yaojia Wang
2026-06-18 07:14:52 +02:00
parent f79f14b89d
commit 87e11734d8
9 changed files with 97 additions and 13 deletions

View File

@@ -151,7 +151,7 @@ export class TabApp {
/* ── tab lifecycle ───────────────────────────────────────────── */
private addEntry(sessionId: string | null, customTitle: string | null): TabEntry {
private addEntry(sessionId: string | null, customTitle: string | null, cwd?: string): TabEntry {
const entry: TabEntry = {
session: null as unknown as TerminalSession,
customTitle,
@@ -161,6 +161,7 @@ export class TabApp {
}
entry.session = new TerminalSession({
sessionId,
...(cwd !== undefined ? { cwd } : {}),
onSessionId: () => this.persist(),
// onActivity only fires for hidden (inactive) panes (see TerminalSession).
onActivity: () => {
@@ -189,7 +190,9 @@ export class TabApp {
}
newTab(): void {
this.addEntry(null, null)
// M6: open the new tab in the active tab's current directory, if known.
const cwd = this.tabs[this.activeIndex]?.session.cwd ?? undefined
this.addEntry(null, null, cwd)
this.persist()
this.rebuild()
this.activate(this.tabs.length - 1)