feat: Seatbelt docker, Mermaid (TUI + web), harness notices, completion and paste fixes #73

Closed
Taha wants to merge 0 commits from taha/review-followups into main AGit
Contributor

Follow-ups after #72. Sandbox: docker inside macOS Seatbelt via an explicit device grant on one unix socket (never default-on; daemon, SSH agent and signing sockets refused; frozen profile; sandbox-generated DOCKER_CONFIG without credentials, so pulls are anonymous and buildx state stays in the sandbox); sandbox home writes through dirfds; plugin generation bindings, mcp.connect gate, safe grant sweep. TUI: image paste never fails silently (wl-paste/xclip/osascript, file URIs and Finder copies, FIFO/size guards, Ctrl+V); Mermaid flowcharts drawn as text (subgraphs, edges between subgraphs,
boxes, correct junctions, lanes for outside nodes, top-down fallback); OpenUI salvage parser; table width floors; wrapped code lines copy as one line; slash completion opens arguments on the space, fuzzy + Tab cycling for arguments only, Enter accepts then runs; Tab on an @ directory opens its contents; harness notices for automatic wakes. Web: Mermaid diagrams (lazy, securityLevel strict, CSP unchanged) with a full-screen pan/zoom viewer; harness notices; wide markdown tables no longer shift right; @ directory accept keeps the menu open. Reviews: two security reviews and one TUI review, findings fixed with red-before-fix tests. Checks: check.sh build/vet/gofmt/plugin-API/web-stamp pass; go test ./... pass except a load flake (TestQueuedMessageEndsPrecedeIdleSnapshot passes alone 7/7 and in its package); -race passes except internal/app hitting the 10-minute default timeout (known, left as is); web svelte-check 0 errors, 332 tests pass; Mac Seatbelt smoke: aws, saml2aws, gcloud, kubectl, helm, k9s, talosctl, gh, docker version/compose/hello-world/build and clipboard (PNG, Finder file, text) pass. Limits: sandboxed docker registry auth is anonymous; mermaid adds about 5 MB to the binary; TUI line budget raised to 49300; two macOS sandbox tests already fail on the base (TrustedConfigEnvironment, SystemCertificateBundle); not verified in a real browser.

Follow-ups after #72. Sandbox: docker inside macOS Seatbelt via an explicit device grant on one unix socket (never default-on; daemon, SSH agent and signing sockets refused; frozen profile; sandbox-generated DOCKER_CONFIG without credentials, so pulls are anonymous and buildx state stays in the sandbox); sandbox home writes through dirfds; plugin generation bindings, mcp.connect gate, safe grant sweep. TUI: image paste never fails silently (wl-paste/xclip/osascript, file URIs and Finder copies, FIFO/size guards, Ctrl+V); Mermaid flowcharts drawn as text (subgraphs, edges between subgraphs, <br/> boxes, correct junctions, lanes for outside nodes, top-down fallback); OpenUI salvage parser; table width floors; wrapped code lines copy as one line; slash completion opens arguments on the space, fuzzy + Tab cycling for arguments only, Enter accepts then runs; Tab on an @ directory opens its contents; harness notices for automatic wakes. Web: Mermaid diagrams (lazy, securityLevel strict, CSP unchanged) with a full-screen pan/zoom viewer; harness notices; wide markdown tables no longer shift right; @ directory accept keeps the menu open. Reviews: two security reviews and one TUI review, findings fixed with red-before-fix tests. Checks: check.sh build/vet/gofmt/plugin-API/web-stamp pass; go test ./... pass except a load flake (TestQueuedMessageEndsPrecedeIdleSnapshot passes alone 7/7 and in its package); -race passes except internal/app hitting the 10-minute default timeout (known, left as is); web svelte-check 0 errors, 332 tests pass; Mac Seatbelt smoke: aws, saml2aws, gcloud, kubectl, helm, k9s, talosctl, gh, docker version/compose/hello-world/build and clipboard (PNG, Finder file, text) pass. Limits: sandboxed docker registry auth is anonymous; mermaid adds about 5 MB to the binary; TUI line budget raised to 49300; two macOS sandbox tests already fail on the base (TrustedConfigEnvironment, SystemCertificateBundle); not verified in a real browser.
Taha added 16 commits 2026-11-14 17:24:43 +00:00
Follow-up to the final review of PR #72:
- mkdirSSHDirReplace checked the directories top-down, but writeAtomic then
  resolved the path by name again, so a worker that swapped a directory for
  a symlink between the check and the write (two sessions of one workspace
  share the sandbox home) redirected ssh_proxy.py, the ssh config and the
  wrappers elsewhere - the host's ~/.ssh included. Every daemon write into
  the sandbox home (the ssh transport files, the copied ssh files, the
  generated git config and signer) now walks from the home with directory
  descriptors: openat with O_NOFOLLOW per component, mkdirat when missing,
  unlinkat and mkdirat for a link or a non-directory, and files written with
  openat O_CREAT|O_EXCL|O_NOFOLLOW, fsync and renameat. Unix only; other
  platforms keep the previous path.
- lowerHostPattern took an escaped \] inside a character class for its end,
  so [\]A-Z] matched lower case; classes are parsed the way path.Match does.

TestWriteAtomicReplacesADirSwappedAfterTheCheck,
TestWriteGitConfigReplacesADirSwappedAfterTheCheck and
TestNetworkHostPatternParsesEscapedClassMembersLikePathMatch fail on the old
code.
Follow-up to the final review of PR #72:
- A plugin generation cancelled or failed during start, never published,
  kept the bindings its plugins made with events.subscribe, so a live plugin
  could change the MCP override of a session it never declared. reloadPlugins
  forgets the bindings of every generation it staged but did not publish.
- mcp.connect, mcp.reconnect and mcp.verify restarted the shared client
  behind a session's runtime disable, as mcp.reload did; they refuse for a
  disabled lineage now.
- The startup grant sweep could delete the live session grants of another
  daemon sharing the state directory with a different database (grants carry
  no database identity). It sweeps nothing while another daemon is live there
  (a connectable socket or a held lock); stale artifacts do not block it.
- docs/plugin-api.json still advertised mcp.add, mcp.update, mcp.remove,
  mcp.set_global_server and mcp.flush_settings to plugins with the admin
  grant, which the daemon refuses. They are client-only in the generator's
  tables now; the surface is regenerated (5 exposure fields; the Python SDK
  is unchanged).

plugin_generation_unpublished_test.go, mcp_runtime_disabled_restart_test.go,
grant_sweep_shared_state_test.go and the surface exposure test fail on the
old code.
A sandboxed command can now reach a docker daemon on macOS: docker build,
docker run and docker compose work once the user approves the daemon's unix
socket with a device grant. The docker socket is root-equivalent on the VM,
so nothing is on by default.

- The device permission is enforced on Seatbelt for exactly one existing unix
  socket (or a symlink to one, such as Docker Desktop's /var/run/docker.sock).
  The profile gets a network-outbound unix-socket rule for that path, read
  access to the CLI bundle behind the docker symlink, and DOCKER_HOST is
  pinned to the approved socket.
- Socket paths are validated once when the grant is compiled and the profile
  is frozen at worker build; a later symlink swap is denied, not redirected.
  A planted non-socket fails the grant closed; a missing path stays inert.
- The daemon's state dir, its control socket at a custom --socket or
  YAZI_SOCKET_PATH, the SSH agent socket and the git sign-broker socket can
  never be granted.
- scripts/smoke-seatbelt-cloud.sh gains opt-in SMOKE_DOCKER=1 probes.
- The agent's permission guide advises the session scope for device on
  Seatbelt, as for network.private.
clipboard.Read collapsed every failure into "no image, no error", so a
missing helper, a file-manager copy, an unsupported format, an oversized
payload or a timeout all did nothing and showed nothing.

- Every failure now returns an explanatory error that the composer shows.
- wl-paste reads the default target and sniffs magic bytes; xclip probes every
  offered type; text/uri-list, gnome-copied-files and plain paths resolve to
  image files; TIFF and BMP convert to PNG; macOS gains an osascript fallback.
- Image files are read only when they are regular files, opened non-blocking,
  checked on the opened descriptor, read through a size limit and bounded by
  the caller's deadline, so a FIFO or /dev/zero cannot hang or exhaust memory.
- clipboard.Text backs a text fallback for the paste chord.
- Ctrl+V joins Alt+V as a default paste-image chord.

- flake.nix: vendorHash updated; the non-blocking open imports golang.org/x/sys/unix, which the vendored module set did not contain yet.
- New package internal/tui2/widgets/mermaid renders flowchart/graph blocks
  (TD/TB/LR/BT/RL, node shapes, solid/dotted/thick edges with labels, chains,
  &, subgraphs) as box-drawing text with a layered layout. Anything it cannot
  draw, or that does not fit, falls back to the source as a code block.
- OpenUI blocks with small syntax errors no longer lose their menu: statements
  are salvaged one by one, reflowed lines are rejoined, quotes and brackets
  repaired, and only @ToAssistant revives a button action. What cannot be
  read is shown as raw text, never dropped. The agent's OpenUI prompt lists
  the common pitfalls.
- Tables: a wide (emoji/CJK) glyph in a column shrunk below its width
  overflowed the row and clipped the last column, which looked empty. Columns
  keep at least their widest grapheme; pipes inside code spans no longer split
  cells.
- Code lines wrap at the width instead of being clipped; continuation rows
  carry a soft-wrap marker on render.Cell so copy can rejoin them.
A mermaid fence in an assistant message renders as an SVG diagram through
the mermaid package (12.3.0, MIT), loaded lazily so the main bundle grows by
about 6 kB. securityLevel strict and htmlLabels off keep model-written diagram
text from injecting markup; the CSP is unchanged. Diagrams follow the light
and dark theme, an unfinished fence shows its source while streaming, and a
diagram that fails to render falls back to the source with a note.
Subagent completions, process wakes and other prompts the harness queues
rendered like the user's own messages. The queue item's origin and a short
label now travel with the stored notice to the TUI transcript and the web
chat, which show a compact "harness" row instead. The model still receives
the same prompt text.

- Old sessions: only entries stored as notices use the legacy prefix
  fallback; a user-typed message starting with "[subagent completed]" stays
  the user's.
- Labels strip control and bidi characters and cap the agent-chosen name, so
  a subagent cannot write a long trusted-looking headline.
- Accepting a command left a hold that suppressed the argument menu until
  the next letter; the menu now opens on the accepted space.
- Commands and arguments match fuzzily (filemention.Fuzzy), prefix and word
  boundary first. Tab and Shift+Tab cycle candidates with wraparound.
- Enter on a fresh argument menu runs the bare command; a typed, cycled or
  arrow-selected candidate is accepted first and the next Enter runs it.
- Shift+Tab with the @ file menu open panicked (index out of range); it now
  steps back through the files.
- Copying a wrapped code line joins its continuation rows without a newline
  or the layout inset, so a long command copies as the original line.
- A pasted image path becomes an attachment only into an empty draft;
  the paste-image chord inserts clipboard text when there is no image.
- Wires harness-notice events and the image paste into the root, rebuilds
  the web assets, and raises the TUI line budget (measured 48269).
On the Mac, docker run failed with "error getting credentials (-50)": the
credsStore "desktop" helper reads the macOS keychain, which the sandbox
denies. docker build failed writing ~/.docker/buildx/activity.

When the docker socket grant is active the worker now gets a generated
DOCKER_CONFIG in the sandbox home: the host config.json without credsStore,
credHelpers and auths, contexts copied (regular files, capped), and
cliPluginsExtraDirs naming the Docker.app and ~/.docker plugin directories the
profile can read. Pulls are anonymous and buildx state stays in the sandbox;
the keychain is never reachable. The copy keeps one empty auths entry for
the reserved host yazi-sandbox.invalid: with no credential entry at all the CLI
picks docker-credential-osxkeychain as a default store and fails the same way. Allowing the helper's keychain lookups was
rejected because it would expose every item the helper can read.

The macOS-only test failures came from /tmp vs /private/tmp spellings and the
104-byte sun_path limit; the tests now use short, resolved temp dirs.
A Finder Cmd+C puts a file URL on the pasteboard. The osascript type listing
failed on that clipboard and the file probe read only the legacy furl flavour,
so the paste was lost and the notice claimed the clipboard was empty.

The listing now also reports the file's POSIX path (each part in its own try,
scripting additions loaded), and the file probe always runs: legacy furl
first, then NSPasteboardTypeFileURL. The path goes through the same
regular-file, size and magic-byte checks as any pasted path. Notices now tell
an empty clipboard apart from one whose contents could not be listed.
Tab cycling and fuzzy matching belong to the argument menu. On the command
menu they made Tab hop between unrelated commands and pulled in names that
only contained the letters (/hs offered /hotkeys). Command names match by
prefix again, in the registry's order, and Tab completes the highlighted
command and opens its argument menu; Shift+Tab only moves the highlight.
Arguments keep fuzzy matching and Tab/Shift+Tab cycling.

Tests: TestCommandMatchingIsByPrefix and TestTabCompletesTheHighlightedCommand
replace the fuzzy command tests (both fail on the previous behaviour).
AssistantMarkdown breaks a 4+ column table out of the message column with a
negative margin-left and a matching padding-left. AssistantMessage's own
.md-table rule outranks it through Svelte's scope class, and its `margin: 16px
0` shorthand reset the negative margin while the padding stayed, so every wide
table started a full lead to the right of the text. The rule sets block
margins only now; a layout test pins that no .md-table rule there sets an
inline margin or padding (red on the shorthand). Web assets rebuilt.
Completing @direc to @directory/ set the same hold a file accept sets, so the
menu stayed closed until the next keystroke and the directory's entries could
not be picked with the arrows or another Tab. A directory is a step into it:
the terminal client refreshes the menu on its contents right away and the web
composer drops the hold (holdAfterAccept), so the listing appears at once. A
file accept keeps the hold, so the next Enter still sends.

Tests: TestTabOnADirectoryOpensItsContents (red: the menu was nil after Tab)
and the directory case in web/tests/mentions.test.ts. Web assets rebuilt.
A dependency chart with two subgraphs, a fan-in node and a <br/> label came
out garbled in the TUI:

- `Infra -.->|x| Core` created plain nodes named Infra and Core. An edge that
  names a subgraph now runs from its exit node to the other's entry node,
  across both borders, keeping its label and dotted style.
- Subgraph borders overwrote wires and labels ("│││", the label left as stray
  letters). Borders now join the wires they cross, gaps between subgraphs
  hold both borders (per nesting level) and the wire's channel, and labels
  are placed last on free cells, or the chart is refused.
- Every wire cell set all four directions at a run's ends, so turns became
  T-pieces and runs started one cell past the corner ("│──", "─┼"). Runs now
  share corner cells and set only the directions they use, so turns are
  corners and merges are junctions.
- <br/> became literal text; it now makes a multi-line box.
- Nested subgraphs were clamped onto each other at the grid edge; the drawing
  shifts instead. Boxes that would overlap or enclose a non-member are
  refused (the caller shows the source).
- A left-to-right chart wider than the terminal is drawn top-down instead of
  falling back to source.

The goldens are regenerated: the old ones froze the same junction bugs.
New tests (all red on the previous code): TestEdgeBetweenSubgraphsLinksTheBoxes,
TestLineBreakInALabelMakesATallerBox, TestFanInJoinsWithJunctions,
TestWideLeftToRightChartStacksTopDown; plus TestOverlappingSubgraphBoxesAreRefused.
FuzzRender: 45 s, 3.4M execs, no crashers. TUI line budget raised to 49300
(measured 48804).
The real dependency chart still showed only its source: APPS, a node outside
all subgraphs fed from inside Core, was placed in Core's layer column under
Core's nodes, so Core's box would have enclosed it and the render was
refused. Each top-level subgraph, and the group of outside nodes, now gets its
own cross-axis lane where their layers overlap (groups on disjoint layers
share a lane and stay aligned).

Also:
- An edge between boxes of different heights (a <br/> box next to a
  one-line box) jogged out of the taller box's centre ("──┐ └▶"); it now runs
  straight on a row both boxes share.
- A quoted dotted/pipe label (`-. "Makefile order" .->`) kept its quotes.

Tests (red on the previous commit): TestRealDependencyChartRenders (the
model's exact chart, at 400 and 228 columns) and
TestDifferentHeightBoxesConnectStraight. One golden lost a needless jog.
Large charts (a dependency graph with dozens of nodes) were unreadable at the
message column's width. A full-screen button in the diagram toolbar opens a
modal <dialog> with the diagram at its natural size, fitted to the window:
the wheel zooms around the pointer, a left or middle drag pans, a double
click switches between fit and 100%, + - 0 1 and the arrows do the same from
the keyboard, and Esc closes it. The toolbar shows the zoom level (10%-800%).

The keys are catalog rows in lib/keys.ts (so the shortcuts dialog lists them
and no component spells a key); the pan/zoom math is lib/panzoom.ts, pinned
by tests/panzoom.test.ts. Web assets rebuilt.
Taha force-pushed taha/review-followups from c0e9a75183 to 5a6b808bc9 2026-11-15 16:44:03 +00:00 Compare
The footer showed "4308 tok/s" after tool rounds. The per-round timing
was right (tool runs and tool output are never inside a call's window);
the quotient was not: a call's output count includes the reasoning
tokens a reasoning model never streams, divided by the window from the
first visible delta to the end, so a round that mostly thought read in
the thousands. A replayed burst after a mid-stream attach did the same
to the live estimate.

usage.MaxPlausibleOutputRate (1000 tok/s) is applied to the TUI's exact
sample, its live estimate, and the store's branch-rate summaries (which
feed the web usage bar and the TUI's fallback average): such a sample is
not shown and not averaged; token totals are unchanged.

docs/footer-statistics.md explains what the number measures.
Since 702a1288 a walk that cannot enumerate a pid's children refuses
(exit 45, ErrNotKilled). In an image without procps every kill of a live
tree then failed: round 1 walked the tree through the children file and
killed it, round 2 re-walked every seen pid, the dead ones had no /proc
entry, so the walk fell through to BLIND and the script refused a kill it
had completed. Five package tests failed on main for this reason.

- tree() treats a pid with no /proc entry that kill -0 also reports gone
  as having no children: a dead pid cannot fork, and every child it had
  was enumerated in an earlier round. Blind is now only declared for a
  live pid whose descendants no source can find.
- A third source between the children file and ps: one pass over
  /proc/[0-9]*/stat builds the parent map with shell builtins (the ppid
  is read after the LAST ')' of the line, so a comm with ')' and spaces
  cannot shift it). It needs nothing but /proc, so kernels without the
  children file and images without procps still kill whole trees.
- The walk's /proc root is a Manager field baked into the script text for
  tests, never read from the environment; identity and liveness always
  use the real /proc.

Tests: the stat scan kills a three-level tree with the children file and
ps unavailable (fixture comms attack the ppid parse), and a walk with no
usable /proc still refuses. docs/ops-safety.md describes the sources.
The footer's tok/s divided a call's whole output count, which includes
reasoning tokens a model never streams, by the window from the first
visible delta: a round that mostly thought read in the thousands. The
previous commit hid such samples behind a 1000 tok/s cap; this replaces
the cap with a rate whose numerator and window describe the same
interval.

- model.Usage gains ReasoningTokens, parsed where the provider reports a
  split: OpenAI chat completion_tokens_details, OpenAI Responses/Codex
  output_tokens_details, ACP thoughtTokens, plugin providers. Gemini's
  candidatesTokenCount already excludes thoughts and Anthropic/Bedrock
  stream thinking as deltas, so they keep 0.
- The daemon decides once per provider call (usage.SpeedSample):
  reasoning streamed -> Output over the first-any-delta window; reasoning
  hidden with a reported count -> Output-ReasoningTokens over the
  first-visible-delta window; otherwise Output over the first-output
  window; under the minimum span or with nothing to count -> no sample.
  The pair travels on the usage event and is stored (migration 030:
  reasoning_tokens, rate_tokens, rate_span_ms; NULL keeps the old rule
  for rows written before it). The TUI sample and the three store
  summaries only read it.
- MaxPlausibleOutputRate is gone. The 41670 tok/s live estimate came from
  events replayed before the first snapshot at attach; the host marks
  them Replay and the estimate ignores them.

docs/footer-statistics.md explains the rule per provider.
- Web: the composer caps the total image payload per message at 6 MiB
  (base64, under the bridge's 8 MiB frame): a refused image is announced,
  the draft and its chips stay, and the send guard covers undo-restored,
  fetched and pasted tokens. Two ~3 MiB screenshots used to overflow the
  frame and lose the draft. The bridge's refusal of text parts in
  session.prompt is documented (text goes in prompt).
- TUI: a plain click on the splash banner no longer copies the first
  message (the code comment said it never does); drags from the banner
  are unchanged.
- TUI: on a daemon that does not know the model_efforts preference the
  /model effort choice stops writing it after the first refusal instead
  of showing an error block on every selection; the effort still applies.
- Sandbox: the startup grant sweep resolves a relative YAZI_SOCKET_PATH,
  so a second daemon spelled that way is detected instead of its grants
  being left alone.
- Mermaid: subgraphs nested deeper than 64 levels fall back to the source
  rendering with the documented error, instead of spending seconds of CPU
  on pathological nesting.
- Line budget raised with measurements (50590→51100, app 22290→22520).
- docs/mcp.md: the disabled-lineage gate covers disconnect too;
  docs/mermaid-web.md's license sentence matches the real licenses of
  mermaid's dependencies (MIT, ISC, MPL-2.0, EPL-2.0);
  docs/permissions.md and docs/mermaid.md updated for the fixes above.
Review follow-up to b9240729.

- kill -0 fails the same way for a dead pid and for a live one whose
  signals are denied (EPERM); with its stat unreadable too (hidepid, an
  LSM), the "gone" rule read such a live descendant as dead and the
  script reported a kill that left it running. A pid is now treated as
  gone only if the script reached it itself: signalled it successfully,
  kill -0 answered for it, or its own stat was readable, recorded at the
  moment of contact (the walk emits "ok <pid>" markers, the stat map
  counts, and each pid is signalled on its own). Any other pid keeps the
  blind refusal.
- The /proc stat map is built once per round, before the walk, and only
  when some seen pid would take the stat branch; tree() reused to build
  it once per seen pid, a full /proc pass each.
- The children-file read goes through the procRoot seam like the branch
  test that picks it.

Tests: a gone pid the script never signalled refuses with exit 45, and
the stat map runs once per round. docs/ops-safety.md describes the rule;
docs/footer-statistics.md notes that rows written before migration 030
keep the old rate rule and that the Responses/Codex reasoning window is
approximate.
efc68411's message promised the web image total cap, the bridge text-part
documentation and the license sentence, but those changes never made it
into the commit. They are here, with the rest of the reviewer's findings.

- Web: the composer caps the total image payload of a message at 6 MiB
  (base64, under the bridge's 8 MiB frame). An image that would exceed it
  is refused with a notice and the draft and its chips stay; the send
  guard covers undo-restored, fetched and pasted tokens. Two ~3 MiB
  screenshots used to overflow the frame, drop the connection and lose
  the draft.
- docs/remote.md: the bridge refuses type:"text" parts in session.prompt;
  text goes in prompt, images in parts.
- Kill: the ps walk printed a root the ps table does not list as if it
  had no children, so the script exited 0 while a descendant of an
  invisible pid ran. Such a root is now blind (exit 45). The
  children-file read applies 2>/dev/null before the < redirection, so a
  missing file's open error no longer leaks into the ErrNotKilled text.
- TUI: a stream reset forgets the remembered model_efforts refusal, so a
  daemon restarted into a newer version is asked again.
- docs/mcp.md: a plugin must name session_id for mcp.connect, reconnect,
  disconnect and verify (the user's session-less call is unaffected).
- docs/mermaid-web.md: the dependency licenses are stated as they are
  (MIT, ISC, MPL-2.0/Apache-2.0, EPL-2.0/GPL-3.0), and the sanitizing
  sentence says what mermaid actually sanitizes.

Web assets rebuilt.
Taha closed this pull request 2026-11-16 06:16:42 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kreato/yazi!73
No description provided.