* fix(workspace-path): address opened files by absolute path `fileAddressFor` rewrote an absolute path inside the Session's directory into a relative address. A Sidebar tab opened that way named another file, or none, once the Session's directory moved and the page reloaded. The address now carries the absolute path whenever one is known: an absolute path is kept and a relative path is joined to the directory the caller supplies. A relative path stays relative only while that directory is unknown. * fix(ui-chat): resolve relative images from the Session's current directory A relative Markdown image used the Session header directory, so an image written while the Session worked in a worktree did not load. It now uses the directory the Session works in, the base relative file links already use. * fix(ui-reference): write picked and dropped files as absolute mentions A file or folder picked from the `@` list was sent as a path relative to the Session's directory, and a Desktop drop inside that directory was rewritten to a relative path. After the directory moved, the sent message named another file or none. A settled pick now joins the listed path to the Session's current directory, and a dropped or pasted file keeps the path the shell reports. Drill text stays relative. Hand-typed relative mentions are unchanged. * fix(deliverables): ask for absolute Markdown link and image targets The file-reference guidance allowed targets relative to the working directory. A relative target in an earlier reply named another file once the Session's directory moved, and a model working in a worktree sometimes wrote targets relative to the original project. The guidance now asks for absolute targets. The expected system prompts that assemble this section carry the new wording. * docs(notes): record how conversation file references survive directory moves * docs(notes): cite the earlier per-message implementation and its revert * test(snapshots): carry the absolute-target guidance into the session-send-message prompt * test(snapshots): add the subagent concurrency sentence to the timeline-follow-chat prompt The scenario's expected system prompt on master predates the subagent guidance sentence that states the shared concurrency limit, so its replay fails on master and on every branch that merges it. * docs(ui-conversation): remove the stale sentence on relative dropped paths --------- Co-authored-by: imccyu <[email protected]>
4.0 KiB
description, kind
| description | kind |
|---|---|
| Browser-safe Workspace path helpers for joining relative paths, abbreviating POSIX homes, and deriving display titles. | package-library |
dsh-util-workspace-path
English | 中文
Summary
Browser-safe path helpers shared by Workspace-facing client and controller packages. The package joins Workspace-relative paths, abbreviates POSIX home directories for display, derives Workspace titles from POSIX or Windows paths, splits a path into its directories and final segment for display, and owns the dsh-resource://file/… address grammar that names a workspace file across the Sidebar and the resource model. relativizeToCwd removes the workspace prefix for display while preserving paths outside that directory. It has no Cordis service or runtime state.
Table of Contents
File addresses
A resource address is dsh-resource://<type>/…, and the type — the URI host — is the resource protocol key (file, or one a plugin declares in ResourceProtocolMap); any other scheme is a navigation protocol, defined elsewhere. dsh-resource://file/session/<sessionId>/<path> names the Session that authorizes the Host read and a workspace-relative or absolute path. Leading slashes remain part of the path: /etc/hosts is dsh-resource://file/session/s//etc/hosts, a Windows drive is dsh-resource://file/session/s/C:/x/y.txt, and UNC is dsh-resource://file/session/s///server/share/y.txt. The Host resolves paths and enforces access. The absolute/<path> form remains parseable but carries no authorizing Session, so the file provider cannot read it and Preview does not claim it; neither current nor Tab Session is borrowed. The grammar lives in src/file-address.ts; the path helpers stay in src/index.ts, which re-exports it.
sessionFileAddress(sessionId, path) normalizes \ to / and drops leading ./, but preserves leading / characters. Every id and path segment is component-encoded with : kept literal. fileAddressFor(sessionId, cwd, path) always builds a Session address and puts the absolute path in it whenever one is known, so the address names the same file after the Session's directory moves: an absolute path is kept, and a relative path is joined to cwd. A relative path stays relative only while cwd is unknown; the Host then resolves it against the Session's directory at each read. absoluteFileAddress(absolutePath) builds only the Session-less form. parseFileAddress(address) checks the exact file-address prefix, ignores query and fragment suffixes, decodes each segment, and returns { scope, sessionId, path } for a Session address or { scope, path } for the Session-less form. Another type or scheme, an unknown scope, a missing id or path, or a malformed escape returns undefined.
fileMediaUrl(base, path) builds an authenticated file-route URL from an already-decoded absolute path. It accepts HTTP(S) application bases and the Desktop dsh-app://app/ origin, preserves literal percent signs and deployment prefixes, and rejects other application bases, relative paths, network-path prefixes, and control characters. Markdown owners decode authored URLs before calling it; native file-card paths are passed unchanged.
Known Limitations and Deferred Work
- Resolution is lexical — it recognizes POSIX absolute paths, Windows drive paths, and UNC paths, preserves the Workspace path's separator when joining a relative path, and does not access a filesystem or canonicalize
.and..segments. - Home abbreviation is POSIX-only — Windows paths remain unchanged because a portable browser cannot infer Windows home-path equivalence safely.
Dev Note
Working context for maintainers — click to expand
None.