Repository navigation
feat(workbench,workspace-files): open external file links in read-only Stage preview - #7599
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
The read-only Stage view is a useful distinction from the explicit desktop open action. The main concern is that the new preview path also changes an existing file-access exclusion. Please keep protected paths separate from ordinary files outside the workspace before merging.
I checked the Host, desktop and web routing, the generated method, and the user-facing file states. The three focused JavaScript suites passed 42/42 on this commit and 41/41 on its base. The browser parser also handled ordinary file URLs and line-range anchors in isolation. The fast PR check passed, but it did not run the native file-access tests. This commit conflicts with current main in CurrentFile.tsx, so I have not verified the combined desktop flow or mixed-version Host calls.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
| }; | ||
| let workspace = |candidate: &Path| -> io::Result<Option<FileReadPath>> { | ||
| if self.excluded(candidate) || has_git_segment(candidate) { | ||
| return Ok(None); |
There was a problem hiding this comment.
[P2] Keep explicit filesystem exclusions separate from external preview eligibility. This branch now puts product-private paths and ordinary out-of-workspace files into the same category. Making the editor read-only does not preserve the original access rule. Keep the hard exclusion in the Host policy shared by preview, reveal, and open, and add a negative authorization test alongside the normal external-file case.
| let line: number | null = null; | ||
| let endLine: number | null = null; | ||
| let column: number | null = null; | ||
| const anchorMatch = /^[Ll](\d+)(?:[Cc:](\d+))?(?:-[Ll]?(\d+))?$/.exec(fragment.trim()); |
There was a problem hiding this comment.
[P3] The browser still treats a normal desktop-style link such as src/locate.ts:7:4 as a literal filename. I checked the actual parser separately from the Stage test, which mocks the link resolver. Please reuse the desktop line-and-column contract or add a browser test documenting that only fragment anchors are supported.
…y Stage preview Previously, clicking any agent-emitted file link outside the active session workspace went through the Agent sandbox read policy and read_external_image, causing every non-image external file (code, Markdown, binary, directory) to fail with "This file is not a supported image." or "This conversation cannot read that path." Fix the contract end-to-end: - Enforce user-client identity (Native/Remote, rejecting Agent/Background/ BrowserLease) on resolveFileLink, readFile, and resolveRevealTarget instead of applying the Agent's sandbox policy to user-activated link clicks. - Replace read_external_image with read_external_file (with first-chunk binary short-circuiting, symlink resolution, directory/missing reporting, and ~ home expansion in resolve_link). - Extend WorkspaceFileReveal.path to FileReadPath and add openWorkspaceFile on the local desktop Host binding so users can explicitly reveal or open both workspace and external files without auto-executing clicked links. - Support FileReadPath in WorkspaceFileTarget, Stage tabs/history, and CurrentFile in read-only mode (showing the full external path, line anchor highlights, read-only Markdown/Editor views, and explicit Reveal / Open in default app actions). - Align webHost.parseMarkdownLink with file://, #L anchors, and base64 pathBytes, regenerate plugin-sdk contracts, and update locales & tests. Generated-by: Maka
7b99d85 to
1d6b3b8
Compare
jackwener
left a comment
There was a problem hiding this comment.
Approved at M4n5ter's direction for commit 1d6b3b869079a9cf7df2f31b18cf494a08bee446.
The browser parser now handles file links with line and column suffixes. All 43 focused Workbench and Web tests, the localization check, and the required GitHub check passed. The commit applies cleanly to main at e86d744a. My verification covered the source and automated checks. The native Host tests and live desktop interactions are outside that coverage.
The previously reported concern about product-private paths remains. Please preserve the Host's existing path exclusions across preview, reveal, and open, and add an authorization regression test. The commit attributes substantive assistance to Maka. Please also record its scope in the PR description.
Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.
Summary
Previously, clicking an agent-emitted local file link outside the active session workspace failed for almost all files:
resolveFileLink/readFileapplied the Agent's sandbox policy to user-activated clicks instead of enforcing user-client identity.host.openLinkreused the inline-image pipeline (read_external_image) and threwThis file is not a supported image.for every non-image external file (source code, Markdown, binaries, directories).CurrentFileandresolveRevealTargetonly accepted workspace-relativeWorkspacePath.This PR fixes the contract cleanly without auto-executing clicked links (preserving click-to-RCE safety against prompt-injected links):
workspace-files/engine,agent/api,agent/native):Native | Remote, rejectingAgent | Background | BrowserLease) onresolveFileLink,readFile, andresolveRevealTarget, decoupling human clicks from the Agent's managed sandbox policy (while keepingSandbox::Externalrejection for non-local workspaces).~/~/expansion inDirectory::resolve_linkand map paths outside the editable workspace (including.gitmetadata) to read-onlyFileReadPath::External.read_external_imagewithDirectory::read_external_file(UTF-8 text, validated images, first-chunk binary short-circuit to avoid buffering large binaries, symlink resolution, and cleanDirectory/Absentstates).WorkspaceFileReveal.pathtoFileReadPath(wire-compatible untagged enum), addDirectory::reveal_external_target, and exposeopenWorkspaceFileon local desktop bindings via the sameresolveRevealTargetlocal-Host verification.workbench,workspace-files/ui,web-nsh,plugin-sdk,locales):This file is not a supported image.restriction fromhost.openLink; route both workspace and externalFileReadPathtargets into StageCurrentFile.Editor readOnly, read-only formatted Markdown viaTextView, nowatchFiles/saveFile/ workspace LSP), display the full external path, preserve#Lline-anchor highlights, and provide explicit Reveal in Finder / Show in File Explorer and Open in default app actions on local desktop.webHost.parseMarkdownLinkto parsefile://,#Lanchors, and base64pathBytes, regeneratepackages/plugin-sdk, and sync all 12 locale catalogs.Verification
cargo test -p maka-fs-tools(60/60 passed, including external text/binary/directory/missing/symlink/~expansion/reveal tests)cargo test -p maka-agent-native --lib -- owner::filesnode --test products/maka/workbench/tests/conversation-resources.test.mjs products/maka/workbench/tests/session-links.test.mjs products/maka/web-nsh/tests/web-foundation.test.mjs(42/42 passed)node scripts/ci.mjs run contracts,node scripts/i18n/check.mjs, andbiome check--root /tmp/...) clicking external code (#L8-L12), Markdown, binary, and directory links:External Rust source with
#L8-L12anchorExternal Markdown document (read-only formatted preview)
External binary file (full path + Reveal / Open in default app)