Skip to content

feat(desktop): make Markdown file references in sessions openable - #3845

Closed
nagarwal-godaddy wants to merge 3 commits into
apache:mainfrom
nagarwal-godaddy:feat/issue-2664-markdown-refs-openable
Closed

feat(desktop): make Markdown file references in sessions openable#3845
nagarwal-godaddy wants to merge 3 commits into
apache:mainfrom
nagarwal-godaddy:feat/issue-2664-markdown-refs-openable

Conversation

@nagarwal-godaddy

Copy link
Copy Markdown

Summary

Markdown file references in session transcripts (e.g. [Guide](docs/notes.md),
including percent-encoded space/CJK spellings) were rendered inert. They are now
actionable in Desktop: clicking stages a preview request and opens the workbar
generated-files tab, where the file is shown read-only through the existing
artifact text viewer
— no second document viewer. The pane header offers two
explicit user actions: "Open locally" and "Reveal in folder" (main-process shell).
Every failure mode (missing/moved, outside-workspace, oversize, unavailable)
renders as an inline, non-destructive notice; the conversation stays mounted with
its scroll position.

Trust model (unchanged boundaries):

  • @maka/ui only gains an additive file-ref destination kind carrying the raw
    reference text; it never resolves paths, and links stay inert wherever no
    dispatcher is installed (TUI/eval surfaces unchanged). file:// and all other
    schemes remain excluded from this path.
  • Resolution + sandbox enforcement happen only in desktop main against the
    session's Runtime Host workspace root via @maka/runtime/path-containment
    (isPathInside over realpath'd root/canonical target): ../ traversal,
    out-of-root absolutes, and symlink escapes are rejected with typed errors;
    reads are Markdown-only and size-capped.
  • Open/reveal go through injected main-process shell wrappers; the external-link
    guard and its closed allowlist are untouched.
  • Remote hosts get typed workspace_unavailable failures.

Fixes #2664

Verification

  • New main tests (workspace-file-refs-ipc-main.test.ts, 9 cases): inside-root
    reads incl. raw space/CJK + percent-encoded refs; ../ escape rejected;
    out-of-root absolute rejected; symlink escape rejected; missing → typed
    not_found; non-Markdown/scheme/control-char refs rejected; size cap;
    open/reveal resolve through the same boundary check and never reach the shell
    on refusal; remote-host and unknown-session failures.
  • New @maka/ui tests: recognition of relative/absolute/percent-encoded/CJK
    refs; scheme rejection; actionable rendering only with a dispatcher installed;
    inert rendering without one and for file://.
  • Gates run locally, all green from repo root: npm run lint,
    npm run format:check, npm run typecheck, npm --workspace @maka/ui test
    (234 pass), desktop main suite (1495 pass, incl. the workbar feature-boundary
    tests), npm run build, npx knip --workspace apps/desktop,
    npx knip --workspace packages/ui.
  • Claim-check note: the issue had a verbal claim from 2026-08-17 with no PR; a
    status-check comment was posted before starting
    (feat(desktop): make Markdown file references in sessions openable #2664 (comment)) and the
    claimant had not replied nor opened a PR by the time this was filed.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: implemented end-to-end by "pi" (coding agent); commits carry
Generated-by: pi trailers.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…ations

Extend `MakaUriDest` additively with a `file-ref` kind that carries the raw
reference text exactly as written — no decoding, no resolution, no boundary
decisions in the UI package. Relative/absolute `.md`/`.markdown` destinations
become actionable only when a dispatcher is installed, so TUI and eval
surfaces sharing this package keep today's inert rendering; every URI scheme
(including `file://`) stays out of the file-reference path entirely.
Percent-encoded spellings of space/CJK references are recognized identically
to their raw forms.

Generated-by: pi
Add `workspace-files:readText` / `openLocally` / `revealInFolder`, following
the reconnectable-read artifacts pattern. Resolution and sandbox-boundary
enforcement happen only in desktop main, against the session's Runtime Host
workspace root via the shared `@maka/runtime/path-containment` authority:

  - realpath'd-root containment rejects `../` traversal and out-of-root
    absolute paths;
  - symlink escapes fail because canonical targets are resolved before
    containment is decided;
  - reads are Markdown-only, size-capped, and strictly read-only;
  - open/reveal reach injected main-process `shell` wrappers only — the
    external-link guard and its closed allowlist are untouched;
  - remote hosts and unknown sessions get typed failures.

The renderer never receives absolute paths, mirroring the artifact pane
contract. Main-process tests cover each rejection plus space/CJK and
percent-encoded references.

Generated-by: pi
Route `MakaUriDest` kind `file-ref` through the EXISTING workbar generated-
files pane so there is no second document viewer: clicking a recognizable
workspace `.md` reference stages a one-shot preview request, opens the files
tab (which never unmounts the transcript, keeping conversation scroll
intact), and renders the file read-only through the shared text preview
surface. Failures — missing/moved, outside-workspace, oversize — render as
inline non-destructive notices; "Open locally" and "Reveal in folder" are
explicit user actions forwarded to main-process shell wrappers over IPC.
Adds en + zh-CN copy for the new surface.

Generated-by: pi
@nitishagar

Copy link
Copy Markdown

Closing to re-create this PR from my personal account (nitishagar) with a corrected branch name — no code changes.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this head and found no blocking issues.

Makes transcript Markdown file references openable via additive file-ref kind, main-side realpath sandboxed open/reveal (1MB, md only, no file://), hosted fallback to non-destructive notice.

No P0-P3. Note: exact head currently has no hosted checks — needs CI green before merge.

简体中文该头无阻断,待 CI。

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.

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.

feat(desktop): make Markdown file references in sessions openable

3 participants