fix(desktop): emit preview at envelope top level so cards actually render (v0.16.4) - #38
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
tui_gateway/server.py:1795— the gateway emits the tool result atpayload["result"] = json.loads(result)(the clawmes envelope{content, details}).apps/desktopchat-messages.ts:394spreads it:part.result = {...parsedEnvelope}→{content, details}.tool-fallback-model.ts:757toolPreviewTargetreadsfirstStringField(result, ['preview','url','target'])— i.e.result.preview, the envelope top level, notresult.details.preview.clawmes put the card path in
details, sotoolPreviewTargetnever 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_resultgainspreview=→ emits an envelope top-levelpreviewkey (sibling ofcontent/details).defi_balance(portfolio) +clawnch_launch(receipt) pass their card path viapreview=.attach_preview/will_auto_open/PREVIEW_TRIGGER_KEYS— they encoded the disproven "details.previewauto-opens" assumption.write_cardfilenames 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.*_urllinks surfaced correctly all along. This PR only fixes the card/preview path.Honest scope note
The live auto-open pane (
structuredPreviewCandidate, readspayload.previewat 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
ruff check+ruff format --checkclean repo-wideplugin.yamlbyte-identical