0170: Native actions and chat links share one versioned contract, and text they carry is sent at once¶
- Implementation partial
Context and Problem Statement¶
Native entry points have no versioned contract. Mac menu actions are unversioned strings with a claim and an
acknowledgement, App Shortcuts set a pending route with no acknowledgement or error, Electron knows only
heinzel://connect, and the links of 0147 name a workspace, not a
chat. A Shortcut that fails says nothing, and no link can open one Heinzel's chat. What do the shells send the page,
what does the page answer, and what may a Shortcut or link do with text it carries?
Decision Drivers¶
- One contract for the Swift shell, Electron and links, so they can't drift apart.
- A failure is told, in a closed set of reasons, never silent.
- A re-delivered action runs once.
- The owner's answer: a Shortcut or link that carries text sends it at once, within the chat's limits.
Considered Options¶
- A v1 envelope with an acknowledgement, and text sent at once (chosen)
- Text prefilled, the person presses Send: one step more for every Shortcut; not what the owner chose.
- Open the chat only, no text: a Shortcut can't ask anything.
- Keep the ad-hoc strings: errors stay invisible and the shells drift apart.
- URL only: no acknowledgement.
Decision Outcome¶
Chosen option: a v1 envelope with an acknowledgement, and text sent at once, because it tells every failure, runs each delivery once and does what the owner asked.
- Envelope
{v: 1, id, action, args}.idis a UUID and the dedupe key: the page remembers the last 64 ids for 10 minutes and answers a re-delivery with the acknowledgement it gave, without running the action again. Anot-readyanswer is not remembered, so the shell may retry the same id once the page is ready. - Acknowledgement
{id, ok: true}or{id, ok: false, reason}. Reasons are a closed set:unsupported-version,unknown-action,not-ready,busy,not-found,refused,invalid. - v0: today's menu action strings stay accepted as they are, so 0.9.57 and 0.9.58 shells keep working.
- v1 actions:
open-chat {heinzel, session?}opens that Heinzel's chat;compose {heinzel, text}opens it and sendstextat once as the person's message;play-soundscape {name}stays with the shell's own soundscape intents and the page answers itunknown-action. - Within the chat's limits:
textis at most the composer's 4,000 characters, elseinvalidand nothing is sent; a composer that already holds a draft or a message on its way is never sent over: the text is added to the draft, not sent, and the answer isbusy; a retired Heinzel or a chat that can't take a message answersrefused. - Chat link
https://<launch>/open#w=<origin>&chat=<slug>[/<session>][&text=<text>], orheinzel://open?chat=…, read by the page as#chat=<slug>[&text=<text>]once it is the confirmed workspace. The slug is the Heinzel's name in lower case with every run of other characters a-. An unknown slug answersnot-foundwithout naming any Heinzel. A link's text is sent at once likecompose, once per page load. - Negotiation: the page publishes
window.heinzelNativeContract = {versions: [1], deliver}; a shell sends v1 only when the page lists 1, else v0 strings. - Shortcuts: "Open a Heinzel" (an AppEntity over the roster) is
open-chat; "Ask" becomescomposewith the text the person gave the Shortcut; "Play soundscape" keeps its intents.
Consequences¶
- Good: a Shortcut or link that fails says why; Electron and Swift speak one contract.
- Good: one step from a Shortcut to an answer.
- Bad: a link with text can send a message the person didn't type in the app. It only works inside the confirmed workspace (0147 keeps its confirmation when the workspace changes), never over a draft, at most once per delivery id and page load, and the message shows in the chat as sent; no secret goes in the fragment.
- Bad: the shells must build the envelope; until they do, they send v0 strings (still accepted).
Confirmation¶
Vitest of the page handler fails when an envelope of another version, an unknown action, a re-delivered id, an over-long text or a composer with a draft does anything but the stated answer, and when a link's unknown slug names a Heinzel. Swift and Node tests of the shells' envelope and dedupe are to come with their builds.
More Information¶
Built in 0.9.59: the page side (envelope, acknowledgement, dedupe, open-chat, compose sending at once, the
#chat= link). Still to build: the Swift shell's and Electron's envelope senders, the "Open a Heinzel" AppEntity,
heinzel://open in Electron, and a Playwright phone journey that opens #chat=.