Skip to content

fix(shell-mode): cd does not update footer cwd (LAC-3732) - #44

Merged
lacymorrow merged 1 commit into
lashfrom
LAC-3732/shell-cd-footer-cwd-event
Sep 11, 2026
Merged

lacymorrow merged 1 commit into
lashfrom
LAC-3732/shell-cd-footer-cwd-event

Conversation

@lacymorrow

Copy link
Copy Markdown
Owner

Summary

Fixes LAC-3732 — QA defect from LAC-3268: submitting cd /tmp in Shell mode did not update the footer shortenedWorkingDir.

Root cause: setCwd() in packages/opencode/plugin/shell-mode/cwd.ts only emitted cwd.updated when the ambient AsyncLocalStorage instance context was present (instanceContext.use()), swallowing the NotFound throw in a bare catch. But the session prompt (the live shell-mode path) runs under Effect's InstanceRef — the ambient context is only entered by CLI bootstrap(), as the docstring on getCwd() in the same file already warns. So the emit silently never fired: the event chain (GlobalBus → worker RPC global.event → TUI sync store → footer) is intact, it just never received the event. This also explains why the QA repro logged nothing.

Changes

  • setCwd(dir, options?: { directory?: string }) — an explicit directory bypasses the ambient-context lookup; falls back to ambient context as before; still skips emission when neither is available.
  • session/prompt.ts threads ctx.directory (already in scope for the getCwd fallbacks) through to the sentinel-parse setCwd call.
  • Regression tests (test/plugin/cwd.test.ts): emit fires without ambient context when directory is passed; event carries the caller's directory; no emit when neither source is available. The two new emit tests fail on the old code.

Not changed: session-shell.ts:296 also calls setCwd without a directory, but SessionShellExecute has no production callers today — behavior there is unchanged (works iff ambient context exists, same as before).

Testing

  • bun test test/plugin/cwd.test.ts — 23 pass (new tests failed before the fix, TDD).
  • bun test test/plugin/shell-mode.test.ts — 32 pass.
  • bun run typecheck (packages/opencode) — clean.
  • Manual repro per issue: TUI in tmux, ctrl+space Shell mode, cd /tmp → footer updates to /private/tmp; pwd confirms. Before-fix behavior documented in LAC-3268 QA transcript.

🤖 Generated with Claude Code

…ctory (LAC-3732)

The session prompt runs under Effect InstanceRef, not the ambient
AsyncLocalStorage instance context (only CLI bootstrap enters that), so
the cwd.updated emit in setCwd hit the NotFound catch and was silently
skipped — the TUI footer cwd never updated after a shell-mode cd.

setCwd now accepts an optional { directory } that bypasses the ambient
context lookup, and the session prompt passes the instance directory it
already has in scope. Emission still falls back to the ambient context
for bootstrap-scoped callers and is skipped only when neither is
available.

Includes regression tests covering emit-without-ambient-context and the
event's directory field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lacymorrow
lacymorrow merged commit 5c95c88 into lash Sep 11, 2026
8 of 10 checks passed
@lacymorrow
lacymorrow deleted the LAC-3732/shell-cd-footer-cwd-event branch September 11, 2026 17:52
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