Update block working directory from CLI agent cwd reports#13849
Update block working directory from CLI agent cwd reports#13849benjschiller wants to merge 1 commit into
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Ben Schiller.
|
CLI agents (e.g. Claude Code via the claude-code-warp plugin) report their working directory in the OSC 777 payload, which lands in CLIAgentSession::session_context.cwd but never reached the block that owns the displayed directory. As a result, an agent that changed directory mid-session — most commonly `claude --worktree`, which relocates into <project>/.claude/worktrees/<name> — left the block pinned to its launch directory, so the WorkingDirectory chip, tab subtitle, git branch, and diff/PR chips all stayed stale. Bridge the agent-reported cwd into the existing OSC 7 path: when a CLI-agent session reports a directory that differs from the block's current pwd, route it through TerminalModel::set_active_block_working_directory (extracted from the OSC 7 handler so the SSH-block guard and block-list routing live in one place). This emits BlockWorkingDirectoryUpdated and refreshes the downstream chips, so branch/PR/diff/tab-subtitle all update with no new event types or UI. The OSC 7 hostname gate is intentionally not applied — the agent cwd is already a parsed local path with no file://host component. Fixes warpdotdev#10031 Includes a spec under specs/GH10031/ and unit tests for the session_context.cwd behavior the bridge reads.
6d60d33 to
5ce09f3
Compare
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @benjschiller on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Every PR must be linked to a same-repo issue before Oz can review it. This PR is linked to #10031, but no linked issue is marked See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
This PR is linked to #10031, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
Description
CLI agents (e.g. Claude Code via the
claude-code-warpplugin) report theirworking directory in the OSC 777 payload, which lands in
CLIAgentSession::session_context.cwdbut never reached the block that owns thedisplayed directory. As a result, an agent that changed directory mid-session —
most commonly
claude --worktree, which relocates into<project>/.claude/worktrees/<name>— left the block pinned to its launchdirectory, so the
WorkingDirectorychip, tab subtitle, git branch, and diff/PRchips all stayed stale.
This bridges the agent-reported cwd into the existing OSC 7 path. When a
CLI-agent session reports a directory that differs from the block's current pwd,
it is routed through
TerminalModel::set_active_block_working_directory(extracted from the OSC 7 handler so the SSH-block guard and block-list routing
live in one place). That emits
BlockWorkingDirectoryUpdatedand refreshes thedownstream chips, so branch / PR / diff / tab-subtitle all update — no new event
types or UI. The OSC 7 hostname gate is intentionally not applied: the agent
cwd is already a parsed local path with no
file://hostcomponent to validate,while the
is_ssh_block()guard is inherited so an agent inside an SSH-wrappedblock cannot clobber the remote block's pwd.
A spec (product + tech) is included under
specs/GH10031/, matching theready-to-speclabel on the issue. The root-cause analysis was also posted as acomment on the issue.
Linked Issue
Fixes #10031
ready-to-specorready-to-implement.Testing
Unit tests added in
app/src/terminal/cli_agent_sessions/mod_tests.rscover thesession_context.cwdbehavior the bridge relies on (update from event, preservewhen an event carries no cwd, record when starting empty):
cargo check -p warppasses andrustfmt --checkis clean on the changed files.The end-to-end view→block→chip path is exercised by the real-display GUI
integration harness rather than a unit test (cf.
test_osc7_updates_current_working_directory); manual verification below coversit end to end.
./script/runScreenshots / Videos
Agent Mode
CHANGELOG-BUG-FIX: CLI agent working-directory changes (e.g.
claude --worktree) now update the block's directory, git branch, and diff/PR metadata instead of staying pinned to the launch directory.