Repository navigation
refactor(native-chat): keep each chat's scratch files in chat-scratch - #28219
Closed
brennanb2025 wants to merge 2 commits into
Closed
brennanb2025 wants to merge 2 commits into
brennanb2025 wants to merge 2 commits into
Conversation
The per-chat folder agents write into is the chat's scratch space, not only a visuals folder. Rename its root to <state>/chat-scratch/<hash> and the agent variable to ORCA_CHAT_SCRATCH_DIR before later work publishes the path. The old variable is still stripped from inherited environments, and the sweep keeps removing folders under the old root by the same rules. The visuals skill names the new variable and says the folder is temporary.
…h env from Pi A root that cannot be listed is logged and skipped, so an unreadable pre-rename root never stops the live root's cleanup (and vice versa). Pi launches get no scratch folder, so both the new and the pre-rename variable are stripped from what a Pi child inherits.
6 of 7 tasks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Each native chat gets a private folder on the computer that runs it, where the agent saves files such as the HTML pages Orca shows inline. That folder was called
native-chat-visuals, but it is really the chat's scratch space. This PR renames it tochat-scratch(and the agent's variable toORCA_CHAT_SCRATCH_DIR) before later PRs make the name part of bigger contracts.What Changed
Problem. The folder's name says "visuals", but it is the chat's general scratch area: it is keyed only by the chat's id, sits outside the workspace, and is cleaned up with the chat. The next PRs in this stack let ordinary file opens reach this folder on paired and SSH hosts, publish its path on the chat's status, and expire it after 30 days without use. Once those land, the path is shown to users, stored in open tabs and share links, and checked by host access rules, so renaming later would need a real migration. Renaming now is cheap because nothing persists or publishes the path yet.
User-facing change. Nothing visible in the app. Agents see a different variable name, and the visuals skill gains two short factual sentences:
$ORCA_CHAT_VISUALS_DIR(<state dir>/native-chat-visuals/<hash>).$ORCA_CHAT_SCRATCH_DIR(<state dir>/chat-scratch/<hash>). The skill now also says: "This folder is temporary: Orca may remove it after 30 days without chat activity or changes. Save files meant to last in the workspace."Mechanism.
native-chat-visuals-folder.tsis nownative-chat-scratch-folder.ts, withnativeChatScratchRootFor/nativeChatScratchFolderName/nativeChatScratchFolderFor. Only the root folder name changes. The per-chat name is still the first 32 hex characters of sha256(session id).ORCA_CHAT_SCRATCH_DIRand never set the old name. When Orca was itself started from a chat, it inherits that chat's variable. Every Claude, Codex, ACP and Pi agent therefore has both the new and the old name stripped from what it inherits: the shared env helper, the Claude child environment (case-insensitive on Windows), and the Codex, ACP and Pi inherited-env delete lists. Without that, an agent started by Orca could write into another chat's folder. Pi never stripped the old name onmain. Pi gets no scratch folder, so any value it inherits belongs to another chat.native-chat-visuals-sweep.ts) lists the oldnative-chat-visuals/root as well aschat-scratch/. Both roots get the same rules and one shared per-run removal limit: remove a folder whose chat record is gone, or whose local workspace is proven removed. A missing or symlinked root is ignored. If one root can't be listed, the sweep logs it and still sweeps the other. The old root's name appears in exactly one place, a clearly named legacy constant in the folder module.::orca-visual{file=...}reply line, theorca-chat-visualsskill name, the packaged plugin folderresources/native-chat-visuals/, theagentSession.readVisualendpoint, and the attachments store.Why
chat-scratchdescribes what this folder promises: per-chat working files that can expire. Rejected alternatives:chat-storage: suggests durable storage, but this folder expires after 30 idle days (S13), and attachments must never live in it.agent-session-scratch: would match theagent-session-*state folders, but it is longer and names an internal concept. The agent-facing variable and skill already say "chat".No compatibility alias is emitted for the old variable. Aliasing would only help agents launched before the upgrade, which still have their original environment anyway. Stripping the old name is not an alias: it only stops a stale parent value from leaking through.
Stack position. S0, the root of the chat-visuals scratch-folder stack, based on
main. S2 (#28189), S3 and S13 (#28193) will merge this branch once and use the new helper names. S9 builds on it. S1 and S8 do not depend on it.Differences from the common pattern.
Linked Issue
Part of the chat visuals scratch-folder stack (internal; no separate issue).
Visual Proof
N/A: no UI change. The only agent-visible change is the variable name and two sentences in the skill text.
Testing
native-chat-scratch-folder.test.ts: the new root, the unchanged hash derivation, and the legacy root path.ORCA_CHAT_VISUALS_DIR. The skill text names the new variable for POSIX and PowerShell and no longer mentions the old one.ORCA_REAL_CLAUDE_CLI_TEST=1 ORCA_REAL_CODEX_CLI_TEST=1onclaude-structured-real-cli,claude-structured-real-cli-fold,claude-structured-real-cli-visualsandcodex-structured-real-cli-visuals: 4 files, 16 tests, all passed. Both visuals tests ran against the real CLIs; neither was skipped.AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)