Skip to content

fix(desktop): emit preview at envelope top level so cards actually render (v0.16.4) - #38

Merged
clawnchdev merged 1 commit into
mainfrom
fix/desktop-preview-envelope
Jun 2, 2026
Merged

fix(desktop): emit preview at envelope top level so cards actually render (v0.16.4)#38
clawnchdev merged 1 commit into
mainfrom
fix/desktop-preview-envelope

Conversation

@clawnchdev

Copy link
Copy Markdown
Owner

The bug (found by the production-readiness source audit)

Verifying #34's card mechanism against the actual NousResearch/hermes-agent source proved the cards never rendered — the preview path was one level too deep.

The trace:

  1. tui_gateway/server.py:1795 — the gateway emits the tool result at payload["result"] = json.loads(result) (the clawmes envelope {content, details}).
  2. apps/desktop chat-messages.ts:394 spreads it: part.result = {...parsedEnvelope}{content, details}.
  3. tool-fallback-model.ts:757 toolPreviewTarget reads firstStringField(result, ['preview','url','target']) — i.e. result.preview, the envelope top level, not result.details.preview.

clawmes put the card path in details, so toolPreviewTarget never found it → cards never became in-app preview attachments. (They only showed as external-open File artifacts via the Artifacts view's deep recursion.)

The fix

  • json_result gains preview= → emits an envelope top-level preview key (sibling of content/details).
  • defi_balance (portfolio) + clawnch_launch (receipt) pass their card path via preview=.
  • Removed attach_preview / will_auto_open / PREVIEW_TRIGGER_KEYS — they encoded the disproven "details.preview auto-opens" assumption.
  • write_card filenames get a random suffix (collision-proof for same-ms renders).

What was NOT broken

Link enrichment — the desktop Artifacts view deep-recurses the result JSON, so details.*_url links surfaced correctly all along. This PR only fixes the card/preview path.

Honest scope note

The live auto-open pane (structuredPreviewCandidate, reads payload.preview at the event top level) remains gateway-only — a plugin can't reach it. With this fix, cards render as click-to-open preview attachments in the chat tool-card, which is the reachable mechanism. Command-emitted cards (/connect, /research) remain external-open File artifacts (commands return strings, not envelopes).

Verification

  • 4562 passed, 8 skipped
  • 100% line coverage (16,215 statements, 0 missing)
  • ruff check + ruff format --check clean repo-wide
  • plugin.yaml byte-identical

…nder (v0.16.4)

A source-level audit of NousResearch/hermes-agent found the v0.16.0 card
mechanism placed the preview path one level too deep.

Trace:
* tui_gateway/server.py:1795 emits the tool result at payload["result"] =
  the parsed clawmes envelope {content, details}.
* The desktop spreads that into part.result (chat-messages.ts:394), so
  part.result == {content, details}.
* The chat tool-card extractor (tool-fallback-model.ts toolPreviewTarget)
  reads result.preview / result.url — the envelope TOP LEVEL — not
  result.details.preview.

clawmes was putting the card path in details, so cards never rendered as
in-app preview attachments (only as external-open File artifacts via the
Artifacts view's deep recursion).

Fix:
* json_result gains preview= which emits an envelope top-level "preview"
  key (sibling of content/details).
* defi_balance (portfolio) + clawnch_launch (receipt) pass their card path
  via preview= instead of burying it in details.
* Removed attach_preview / will_auto_open / PREVIEW_TRIGGER_KEYS from
  ui_artifacts — they encoded the disproven assumption.
* write_card filenames get a random suffix so same-millisecond renders
  can't collide.

Link enrichment was correct all along (the Artifacts view deep-recurses the
result JSON, so details.*_url links surface); this only fixes the card path.

Verification: 4562 passed, 8 skipped; 100% line coverage (16,215 stmts, 0
missing); ruff check + format clean repo-wide; plugin.yaml byte-identical.
@clawnchdev
clawnchdev merged commit caa9160 into main Jun 2, 2026
4 checks passed
@clawnchdev
clawnchdev deleted the fix/desktop-preview-envelope branch June 2, 2026 20:35
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