Skip to content

feat(scratch): report the scratch shell's own cwd - #981

Merged
umputun merged 3 commits into
masterfrom
scratch-cwd
Nov 12, 2026
Merged

umputun merged 3 commits into
masterfrom
scratch-cwd

Conversation

@umputun

@umputun umputun commented Nov 12, 2026

Copy link
Copy Markdown
Owner

a custom command fired from the scratch terminal got the main pane's directory in AGT_SESSION_PWD, so a file name selected from an ls in the scratch resolved against the wrong directory.

  • the scratch's OSC 7 reports go to a new Session.scratchCwd, never the row's cwd or title. A local scratch seeds it with its start directory, and it is cleared whenever a scratch departs
  • AGT_SESSION_PWD from the scratch is that directory. AGT_SESSION_HOST is empty from the local scratch of an attached session, so the pair names one shell; a remote window's server scratch keeps the host
  • the palette and keymap run keep the primary or split pane, as documented
  • relative links libghostty leaves raw (./main.go:42) resolve against a local scratch's cwd
  • tree reports scratchCwd while a scratch exists, shown or hidden, and the human tree output shows it when it differs from the session cwd
  • cwd(for:), remoteHost(for:) and localWorkingDirectory move to Session+PaneDirectory.swift to keep Session.swift under the file length limit

skill reference, site/commands.html, site/docs.html and the control-api/keymap rules are updated.

Related to #976

A custom command fired from the scratch terminal got the main pane's
directory in AGT_SESSION_PWD, so a file name selected from an ls in the
scratch resolved against the wrong directory.

- the scratch's OSC 7 reports go to Session.scratchCwd, never the row's
  cwd or title; a local scratch seeds it with its start directory
- AGT_SESSION_PWD from the scratch is that directory. AGT_SESSION_HOST is
  empty from the local scratch of an attached session, so the pair names
  one shell; a remote window's scratch keeps the host
- the palette and keymap run keep the primary or split pane, as documented
- relative links libghostty leaves raw resolve against a local scratch's cwd
- tree reports scratchCwd while a scratch exists, shown or hidden
- cwd(for:), remoteHost(for:) and localWorkingDirectory move to
  Session+PaneDirectory.swift, keeping Session.swift under the length limit

Related to #976
A server scratch dropped or replaced while it had no surface kept the old
daemon's directory, so the next scratch reported it in AGT_SESSION_PWD and
tree.scratchCwd until its shell sent OSC 7. The clear moves from
closeScratch into releaseScratchOwnedState, which every departing path runs;
a reattach to the same daemon does not, so its directory survives.

Also splits a two-sentence line in the control-api rule.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 18:23

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying agterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: abd6bfb
Status: ✅  Deploy successful!
Preview URL: https://a49d6fec.agterm.pages.dev
Branch Preview URL: https://scratch-cwd.agterm.pages.dev

View logs

@umputun
umputun merged commit 82910bb into master Nov 12, 2026
10 checks passed
@umputun
umputun deleted the scratch-cwd branch November 12, 2026 18:38
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.

2 participants