Skip to content

refactor(native-chat): rename the chat visuals folder to the chat scratch folder - #28389

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/cs-rename-chat-scratch
Oct 14, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/cs-rename-chat-scratch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178 $\color{#cf222e}{\Huge{\mathbf{−}}}$​126 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​52
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 $\color{#cf222e}{\Huge{\mathbf{−}}}$​66 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

ELI5

Each Orca chat gets a private folder where its agent saves the HTML pages it shows inline. The folder and its variable were named "visuals", but the folder is the chat's scratch space and later work also opens, edits and expires files in it. This PR only renames it: native-chat-visuals becomes chat-scratch.

PR 2 of 6 in the chat-scratch stack. Depends on PR 1 (#28385, never write through a dangling symlink). PR 3 (host serves the scratch folder as a file root) and PR 5 (scratch folders expire after 30 days unused) build on it.

What Changed

The problem. The per-chat folder lived at <state dir>/native-chat-visuals/<hash> and agents found it through ORCA_CHAT_VISUALS_DIR. The next PRs make it a real folder the user can open, edit and share from, and give it an expiry. Shipping those under a "visuals" name would put the wrong name into a path users see and into what agents are told.

User-facing change. Nothing visible yet. One side effect: inline visuals written before this change sit in the old folder, so they show "Visualization unavailable". Native chat has no real users yet, so this only touches dev data.

The one behaviour change beyond the rename: Pi chats no longer inherit the parent's scratch folder. Before, an Orca started from inside another chat passed that chat's folder variable on to every Pi process it launched; Pi gets no folder of its own, so it now drops both the new and the old variable.

Mechanism.

  • The folder is now <state dir>/chat-scratch/<first 32 hex of sha256(session id)>. Only the root segment changed; the hash is the same.
  • The storage module is native-chat-scratch-folder.ts (nativeChatScratchRootFor, nativeChatScratchFolderName, nativeChatScratchFolderFor). Code that renders, delivers or permits visuals keeps its visual names.
  • Agents get ORCA_CHAT_SCRATCH_DIR. The old ORCA_CHAT_VISUALS_DIR is never set. It is still removed from what every agent process inherits (Claude, Codex, ACP agents and Pi; on Windows, Claude's strip also ignores letter case, while the others remove the exact upper-case name Orca writes, as on main), because an Orca started from an older chat would otherwise pass that chat's folder on to every agent it launches. Pi gets no folder at all, so both names are removed for it.
  • The visuals skill names the new variable (POSIX and PowerShell) and adds two facts: the folder is temporary and may be removed after 30 days without chat activity or changes, and files meant to last belong in the workspace.
  • Unchanged: the ::orca-visual{file=...} reply line, the skill name orca-chat-visuals, the packaged plugin folder resources/native-chat-visuals/, folder creation, theme-variable fallbacks, and "a new file name each time".
  • The existing cleanup sweep now lists the new root. Folders left under the old root are removed by PR 5, which sweeps the old root once.

Why

The folder already holds more than visuals once PRs 3–5 land, so "scratch" is the honest name for a temporary per-chat working area, and "scratch" already means a temporary agent area elsewhere in Orca.

Alternatives considered:

  • chat-storage: "storage" promises keeping things, which contradicts deleting the folder after 30 idle days.
  • agent-session-scratch: matches the other agent-session-* folders on disk, but the agent-facing variable and skill already say "chat", and the path becomes user-visible in later PRs, so "chat" reads better there.

No compatibility code: no alias for the old variable and no reads of the old folder. Old folders only need a way to die, which PR 5 gives them.

Differences from the common pattern: none.

Linked Issue

N/A (maintainer PR, part of the chat-scratch stack).

Visual Proof

N/A: a rename of an internal folder and variable; nothing on screen changes except pre-rename inline visuals now showing "Visualization unavailable".

Testing

Size against PR 1's branch, both measurements:

  • git diff --numstat (git's default rename detection): production +92 / −66, tests +178 / −126.
  • git diff -M20% --numstat: production +76 / −50, tests +178 / −126.

They differ because the moved module (native-chat-visuals-folder.ts → native-chat-scratch-folder.ts) is only 38% similar (every line names the folder), below git's default 50%, so the default counts it as a whole-file add and delete. The test lines are mechanical renames in existing tests plus the regenerated launch parity snapshot (+90 / −49), where every agent's list of removed variables now names the old one. That puts tests above the plan's ≤45-line estimate and above the production lines; the design panel approved this as an exception for this PR only.

  • Updated the existing launch tests and the launch parity snapshot: every agent's child environment drops both the inherited ORCA_CHAT_SCRATCH_DIR (when the chat has no folder) and the old ORCA_CHAT_VISUALS_DIR, and Pi now drops both.

  • Native-chat, ACP, Codex, Claude launch, Pi and visual-read test suites pass; node typecheck clean; real Claude CLI tests run.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: paths built with path.join; on Windows, Claude's environment strip ignores letter case, while Codex, ACP agents and Pi remove the exact name Orca writes (unchanged from main). SSH/remote: the folder lives on the host that owns the chat, as before. Mobile: unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Live QA (M4Air, 2026-10-13)

Hidden Orca rig + a paired headless Orca server on the same Mac, real Claude chats, driven over CDP. Code under test: a local merge of PR 6 (80e42ed) and PR 5 (ec2ac14). All 7 QA rows passed.

  • A Claude chat on the paired server wrote its visual to the server's <state>/chat-scratch/<32 hex>/fruit-bars-3a9f.html (the folder name is the first 32 hex of sha256 of the session id; nothing was written into the repo), and it renders inline:

visual from the paired server renders inline

  • A visual written before the rename (its folder moved back under native-chat-visuals/) shows "Visualization unavailable"; the rest of the chat is unaffected:

pre-rename visual shows Visualization unavailable

A path that doesn't exist yet was authorized by walking up to the nearest
existing folder. A dangling symlink fails realpath with ENOENT, so the walk
stepped over it and approved the link's own path; the write then followed
the link and created its target outside the allowed folders. The walk now
continues from the link's target, and returns that real destination.
…atch folder

The per-chat folder agents write into is the chat's scratch space, not only
a visuals folder. Its root becomes <state>/chat-scratch/<hash> (the hash is
unchanged) and the agent variable becomes ORCA_CHAT_SCRATCH_DIR. The old
ORCA_CHAT_VISUALS_DIR is never set and is still stripped from what every
agent child inherits, Pi included. The visuals skill names the new variable
and says the folder is temporary.
…-write' into brennanb2025/cs-rename-chat-scratch
The launch parity snapshot already pins that every agent drops the
pre-rename variable.
Following a dangling link by hand resolved relative targets against the
lexical parent, not the link's real folder: through a folder link the walk
could loop forever or authorize the wrong file. Refuse instead: realpath
can't say where a dangling link leads, but a write would follow it.
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/cs-dangling-symlink-write to main October 14, 2026 02:08
@brennanb2025
brennanb2025 marked this pull request as ready for review October 14, 2026 02:32
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b602c127-792f-44a5-808e-e64ce112233d
📥 Commits

Reviewing files that changed from the base of the PR and between 9db7b8b and bbb94c5.

⛔ Files ignored due to path filters: 1
  • src/main/runtime/__snapshots__/structured-agent-launch-parity.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing: 33
  • resources/native-chat-visuals/skills/orca-chat-visuals/SKILL.md
  • src/main/acp/acp-structured-launch-resolution-omp.test.ts
  • src/main/acp/acp-structured-launch-resolution.ts
  • src/main/acp/acp-structured-launch-visuals.test.ts
  • src/main/acp/acp-structured-launch-visuals.ts
  • src/main/claude/claude-child-process-environment.ts
  • src/main/claude/claude-structured-launch-visuals.test.ts
  • src/main/claude/claude-structured-real-cli-visuals.test.ts
  • src/main/codex/codex-structured-launch-resolution.test.ts
  • src/main/codex/codex-structured-launch-resolution.ts
  • src/main/codex/codex-structured-real-cli-visuals.test.ts
  • src/main/codex/codex-structured-session-state.ts
  • src/main/codex/codex-structured-visuals.test.ts
  • src/main/ipc/filesystem-auth.test.ts
  • src/main/ipc/filesystem-auth.ts
  • src/main/native-chat/native-chat-inline-visuals-setting.test.ts
  • src/main/native-chat/native-chat-scratch-folder.ts
  • src/main/native-chat/native-chat-visual-file-read.test.ts
  • src/main/native-chat/native-chat-visual-file-read.ts
  • src/main/native-chat/native-chat-visuals-delivery.test.ts
  • src/main/native-chat/native-chat-visuals-delivery.ts
  • src/main/native-chat/native-chat-visuals-folder.ts
  • src/main/native-chat/native-chat-visuals-sweep.test.ts
  • src/main/native-chat/native-chat-visuals-sweep.ts
  • src/main/pi/rpc-launch.ts
  • src/main/runtime/native-chat-visuals-workspace-verdict.ts
  • src/main/runtime/rpc/methods/structured-agent-session-visual.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-visual.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-mobile-agent-session-methods.ts
  • src/main/runtime/structured-agent-launch-parity.test.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/shared/native-chat-visual-directive.ts
  • src/shared/rpc-contract/agent-session-visual-params.ts
💤 Files with no reviewable changes: 1
  • src/main/native-chat/native-chat-visuals-folder.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

Native-chat visual storage and delivery now use per-chat folders under chat-scratch and the ORCA_CHAT_SCRATCH_DIR environment variable. Launch cleanup removes the legacy visuals-directory variable, and visual-file reads resolve from scratch folders. Filesystem authorization now denies missing paths through dangling symbolic links.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to bbb94

No actionable merge-blocking issue was identified. The documented loss of previously saved inline visuals is an acknowledged compatibility tradeoff.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 31 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the primary change: renaming the per-chat visuals folder to the chat scratch folder.
Description check Passed The description is detailed and covers the change, rationale, user impact, linked-issue exception, testing, visual proof, compatibility, and checklist items. It also clearly states that manual testing…
Full details: Docstring Coverage

Explanation

Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 31 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit 9b1e83a into main Oct 14, 2026
64 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/cs-rename-chat-scratch branch October 14, 2026 05:09
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