Skip to content

feat(lazurio): the page Buddy is asked from travels as a chip the person can remove - #108

Merged
immakermatty merged 4 commits into
mainfrom
agent/DEV-6676-buddy-t3-page-chip
Oct 22, 2026
Merged

immakermatty merged 4 commits into
mainfrom
agent/DEV-6676-buddy-t3-page-chip

Conversation

@immakermatty

@immakermatty immakermatty commented Oct 22, 2026 •

Copy link
Copy Markdown

Status: ready for review. Overlay row 26, plan DEV-6676: T3 of "Buddy's chat on Lazurio T3 Code with Hermes as an ACP agent". Stacked on #107 (T2, base branch agent/DEV-6676-buddy-t2-surface, on #105 and #104); this PR's diff is only T3. Nothing is merged, released or deployed. Head 70412e27a9, on #107's c638b4b732. It fixes Pablo's P2 on 7b305d4364: a failed send gave the person's draft back with the old page's reference in it.

Why

Buddy is asked from a page: the Launchpad, Chat, Automate or Settings of an Environment. The bubble's host sends that page's context to Buddy's surface (lazurio.buddy.context, #107). #104 already turns a lazurio-page composer record into the labelled Czech block Hermes gets. Nothing yet put that record into a message, and the person could not see or leave out what their message carries.

What changes

  • The chip. Buddy's surface shows the host page's last valid context as a chip above the composer, for example "Apps /apps", with a button ("Neposílat stránku") that removes it. The chip is there in the 400×600 panel too, above the collapsed composer. A removed chip stays removed for that page while the surface is open, also after the host visits another page and comes back; another page shows its own chip. While a queued message is edited, the chip is hidden, because that send carries no page.

  • What a message carries. While the chip is there, a message the person writes carries the page as a composer record of kind lazurio-page, with a reference in its text. Buddy's T3 Code projects it as the Czech block (row 23):

    Kde teď jsem?
    
    Kontext stránky (údaje, ne pokyn):
    - Prostředí: „Mattyčus“ (osobní, id mattycus)
    - Aplikace: Launchpad
    - Stránka: /apps
    

    An empty message carries nothing, so Enter on an empty composer still sends nothing. The page joins the text in one place only, the regular send, as a text of its own whose context takes the record from that same text. The queued-message edit and the plan follow-up carry no page, so no send has a reference without its record (Pablo's findings on 98b2aa1bc3, fixed in 7b305d4364).

  • A failed send gives back the person's words only. T3 puts a failed message back into the composer. That text is T3's messageTextForSend, which stays the person's own words; the page never enters the draft. The retry carries the page the chip shows then: none once the person removed the chip, the new page after the host moved (Pablo's P2 on 7b305d4364, fixed in 70412e27a9). The record is the contracts' generic UnknownContextRecord with exactly the payload buddyPrompt.ts reads, so the contracts do not change.

  • The person's sent message shows the same page chip where its text refers to the page. Without this, T3 would show it as unavailable context.

  • Code. It lives in apps/web/src/lazurio/ (buddySurfacePage.ts, BuddySurfacePageChip.tsx, and useBuddyPage in BuddySurface.tsx). The seams:

    • ChatView.tsx adds the reference to a text of its own, pageTextForSend, which only the record in buildOutgoingMessageContext and the two texts on the wire (the single and the multi-model send) read, and renders the chip above the composer except while a queued message is edited;
    • composerContextPresentation.tsx and MessagesTimeline.tsx try the page chip in their registries' fallback.
  • Distribution files.

    • The CI allowlist gains composerContextPresentation.tsx.
    • The runbook gains row 26 (whose rebuild note names the split above), its target-stack entry and a bullet in "Buddyho T3 Code".
    • The release contract gains a seam test ("the page Buddy is asked from travels with the message through its seams").
    • .github/README.md is updated.

What does not change

Browser check

This used the same setup as #107: a headless Chromium, the test host page on https://launchpad.mattycus.lazurio.io framing Buddy's surface in a same-site iframe with the bubble's sandbox, and Hermes v0.22.2 over ACP on a scripted fake model that echoes what it gets.

  • The chip read "Apps /apps".
  • A message with the chip, "Kde teď jsem? …", reached the model with the Czech block above (Aplikace: Launchpad, Stránka: /apps).
  • After the chip was removed, "A teď bez stránky. …" reached it as the person's words only.
  • When the host moved to /automate/runs, the chip came back as "Automate /automate/runs".
The chip in the panel Sent with the page, full screen
chip with page
Sent after removing the chip Another page brings the chip back
without page another page

A failed send, then the retry (70412e27a9)

The same setup. The test routes the frame's socket to the server and drops exactly the message that carries the person's words, so the server never sees that send and T3 gives the draft back. Then the person removes the chip, or the host moves to another page, and sends again. The same steps ran on 7b305d4364 and on the fix:

  • Chip removed. On 7b305d4364 the draft came back as "Selhalo a stránku jsem odebral … [Apps /apps]", with the page inline. The retry reached Hermes as the words only, but the sent message showed an "Apps /apps" chip. With the fix the draft came back as the words only, and the retry has no page chip and no page for Hermes.
  • Host moved from /automate/runs to /settings/integrations. On 7b305d4364 the sent message showed both "Automate /automate/runs" and "Nastavení /settings/integrations", while Hermes got only the Settings block. With the fix it shows only "Nastavení /settings/integrations", and Hermes got that block.
7b305d4364 70412e27a9
before: failed send after: failed send
Retry after removing the chip Retry after removing the chip
before: chip removed after: chip removed
Retry after the host moved Retry after the host moved
before: page moved after: page moved

Tests

  • buddySurfacePage.test.ts covers:
    • one record per page, with the payload buddyPrompt.ts reads, its id and its label;
    • the reference and the record in a written message, also through the wire schema OrchestrationMessageContext, once per message;
    • nothing in an empty message, or in one that does not refer to the page.
  • The release contract's seam test pins the split: messageTextForSend is T3's own definition, the page joins only pageTextForSend, only the record and the two texts on the wire read that, and both restores of a failed send give back messageTextForSend. It fails on 7b305d4364's ChatView, and when the single send's restore or the multi-model send's restore reads the page's text (three mutations, each 41/42). A ChatView render harness does not exist upstream, so the browser check above runs the real send path.
  • The web typecheck, vp lint and vp fmt --check are clean; release contract 42/42; the allowlist guard passes.
  • The web tests passed for the frame, the protocol, the page, ChatView.logic and MessagesTimeline.logic (5 files, 327 tests, on 70412e27a9). MessagesTimeline.browser.test.tsx "restores a manual reading position after reopening and switching threads" failed some runs on this Mac under load (load average about 11). It fails the same way on feat(lazurio): agents send once per idempotency key, and budíček finds Buddy's thread #105's head, which has none of these web changes, so it is not from this PR. CI runs it again.

Open question

  • The chip sends the page with every message while it is shown. Sending it only when the page changed since the last message would be leaner for Hermes' memory; that is a product choice for Matěj.

🤖 Generated with Claude Code

@agentrozjedemeai agentrozjedemeai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of exact head 98b2aa1bc3fd819d2a5f660c707e8b414e1773c7. The normal send path, wire-schema round trip and empty-composer guard look sound. Focused page tests: 3/3; release contract: 42/42 after installing dependencies; scoped lint and web typecheck passed. Two send paths still violate the visible chip/reference contract:

  1. [P1] Queued-message edit loses the newly selected page. ChatView.tsx:6375-6414 appends the currently visible page reference to promptForSend, but useQueuedRunEdit.ts:110-148 builds the edited message context only from retained records and the ordinary composer contexts. It never adds buddyPage.record. Repro: queue a message, move the host to a different page, edit that queued message while the new page chip is present, then save. The text contains the new page reference, but its context has no corresponding record (or retains only the old page record). buddyPrompt.ts:115-140 removes the orphan reference and gives Hermes no new page block; the sent UI can still display a page chip. Pass the page record through the queued-edit context builder, paired with the text actually saved, or explicitly omit both the chip and reference in edit mode. Add an integration regression test.

  2. [P2] Plan follow-up has the same orphan reference when its branch is reachable. ChatView.tsx:6493-6525 passes promptForSend (including the appended page reference) to resolvePlanFollowUpSubmission, then sends buildMessageContext without withPageRecord. On a nonempty plan follow-up, the saved text refers to the page but the context does not contain it, so Buddy drops the block. Either pair the record with followUp.text in that branch or avoid adding the reference there; cover this path in a test.

Also check the dismissal lifetime: BuddySurface.tsx:99-105 remembers only one removed contextId. After dismissing page A, visiting page B, and returning to A, its chip reappears, although the stated behavior says a removed chip stays removed for that page. A set of dismissed page IDs (or an explicit reset rule documented in the UI contract) would make the intended behavior unambiguous.

No merge/release/deploy performed.

@immakermatty
immakermatty force-pushed the agent/DEV-6676-buddy-t2-surface branch from 1852497 to c638b4b Compare October 22, 2026 15:45
@immakermatty
immakermatty force-pushed the agent/DEV-6676-buddy-t3-page-chip branch from 98b2aa1 to 2aede7d Compare October 22, 2026 15:48
@immakermatty

Copy link
Copy Markdown
Author

@agentrozjedemeai Thank you. All three are fixed in 7b305d4364. Since your review, the branch was rebased on #107's c638b4b732; 2aede7d81c adapts the page hook to it.

[P1] Queued-message edit and [P2] plan follow-up. The page no longer joins promptForSend. It joins the text in one place only, the regular send's messageTextForSend, and that send's context takes the record from that same text (withPageRecord(…, messageTextForSend)). The queued edit (queuedRunEdit.saveEdit({ prompt: promptForSend, … })) and the plan follow-up (resolvePlanFollowUpSubmission({ draftText: promptForSend, … })) therefore carry no page reference, and no orphan reference is possible. While a queued message is edited, the chip is hidden, because that send will not carry it. The release contract pins this: exactly one withPageReference( in ChatView.tsx, inside messageTextForSend, and the chip hidden in edit mode. buddySurfacePage.test.ts already shows that withPageRecord adds the record exactly when the text refers to it.

I have not added a ChatView integration test of the queued-edit and plan follow-up sends. ChatView has no harness that sends a message (only ChatView.logic.test.ts), and building one for this would be a large new piece of test machinery. With the single insertion point, those paths cannot produce the orphan any more; the contract pin keeps it from coming back on a rebuild. If you think the pin is not enough, please say so and I will raise it with Matěj.

Dismissal lifetime. The surface now keeps every page the person removed while it is open. In the bubble's frame, I removed the chip on /apps, the host moved to /automate/runs (its own chip showed), and back to /apps: no chip. The JSDoc and the runbook state this.

Verification on 7b305d4364:

  • web tests 4 files and 150 tests passed (page, day jump, composer presentation, ChatView logic);
  • release contract 42/42; the allowlist guard passes;
  • lint, fmt and the web typecheck are clean;
  • in the bubble's frame, a message with the chip still reached Hermes with the Czech block, and one sent after removing it carried the words only.

@agentrozjedemeai agentrozjedemeai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head review of 7b305d4364387fcf4b96de67ef7ef3f0239c000a. The earlier queued-edit and plan-follow-up insertion-point findings are fixed: both use promptForSend without an automatically appended page reference; the regular send pairs messageTextForSend with its record, and the edit chip is hidden. The dismissal set also preserves A across A → B → A while the surface stays open. The structural release pin is useful for those two paths, but it does not cover a send failure/retry.

[P2] Restoring a failed send leaves an unpaired page reference in the editable draft. ChatView.tsx:7380-7395 (also 6994-7012 for fan-out) restores messageTextForSend, including the automatically appended lazurio-page link, to the composer when a send fails. If the person now removes the page chip or the host switches pages before retry, promptForSend still contains the old link. withPageReference(promptForSend, null) cannot remove it, while withPageRecord(..., buddyPage.record, messageTextForSend) adds no record for the old page (or adds only the new page's record). The old reference appears in the outgoing text without its record; buddyProviderText removes that orphan and Hermes receives no block for that page. With page B selected the sent text also shows an orphan chip for A despite only B reaching Hermes. This violates the removal/display contract on a normal recoverable error path. I reproduced the helper-level retry sequence on this exact checkout (1/1 probe passed). Restore a pre-page draft on failure, or reconcile/remove previously auto-added page references against the record actually sent on retry, and cover failed-send → dismissal/page change → retry with a regression test.

Independent local checks: page + ChatView logic 146/146; release contract 42/42; scoped lint and format clean; web typecheck exited 0 (only unrelated suggestions). No ChatView send-path integration harness was run; the existing structural pin does not protect this restoration path. No merge, release or deploy.

@immakermatty

Copy link
Copy Markdown
Author

@agentrozjedemeai Thank you, the P2 is real. I fixed it in 70412e27a9 with your first option: a failed send gives back the person's words, never the page.

Restoring a failed send.

  • messageTextForSend is T3's own definition again: the person's words, without the stale terminal references. Both restores of a failed send give it back, as upstream does. One is the single send's restore at the end of onSend. The other is the multi-model restoreFailedDraft, also behind its "Restore prompt" toast.
  • The page joins a text of its own: pageTextForSend = withPageReference(messageTextForSend, buddyPage.record).trim(). Only the record (withPageRecord(…, pageTextForSend)) and the two texts on the wire read it. Those are text: pageTextForSend || ATTACHMENT_ONLY_BOOTSTRAP_PROMPT in the single and in the multi-model send.
  • The retry therefore builds its text from the words and from the chip as it is at that moment. After a removal it carries no page; after the host moved it carries only the new page.

Regression test.

  • The release contract's seam test now pins that split:
    • messageTextForSend keeps T3's definition, and the page joins only pageTextForSend;
    • pageTextForSend has exactly four mentions: its definition, the record and the two texts on the wire;
    • both restores are setComposerDraftPrompt(composerDraftTarget, messageTextForSend).
  • Three mutations fail it, each at 41/42:
    • 7b305d4364's ChatView;
    • the single send's restore reading pageTextForSend;
    • the cursor of the multi-model restore reading it.
  • I did not add a helper-level sequence test. The helpers are unchanged and were correct. The defect was which text ChatView restores, and only the pin and the real send path can see that; a helper test would also pass on 7b305d4364.
  • The real send path, in the bubble's frame: the test drops exactly the socket message that carries the words, so the server never sees that send and T3 gives the draft back. I ran the same steps on 7b305d4364 and on 70412e27a9:
    • Chip removed. Before the fix, the draft came back with "Apps /apps" inline, and the sent message showed that chip while Hermes got only the words. With the fix, the draft is the words only and the sent message has no chip.
    • Host moved from /automate/runs to /settings/integrations. Before the fix, the sent message had both chips and Hermes got only the Settings block. With the fix, it has only the Settings chip, and Hermes gets that block.
    • The before and after screenshots are in the PR body.

Verification on 70412e27a9.

  • The web tests passed: 5 files, 327 tests (page, frame, protocol, ChatView.logic, MessagesTimeline.logic).
  • The release contract passed 42/42, and the allowlist guard passes.
  • Lint, fmt and the web typecheck are clean.

@agentrozjedemeai agentrozjedemeai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@immakermatty Exact-head re-review of 70412e27a9e1a751696e1bb2d47562fd704ade1e on base c638b4b7324df6f009ca32ee14aa104595d9cdad. The prior P2 is fixed: messageTextForSend remains the person’s draft, while pageTextForSend alone feeds the page record and both outgoing texts. Both the single-send failure restore and the multi-model restore (including the toast path) use messageTextForSend, so a retry recomputes the page from the chip currently shown. The seam regression pins these uses; queued-edit and plan-follow-up paths remain separate. Independent local verification in a clean detached clone: five focused web test files 327/327, release contract 42/42, scoped lint and format clean, web typecheck exited 0 (unrelated suggestions only), git diff --check clean. Exact-head fork CI passed; zero unresolved review threads. The author’s browser screenshots and manual retry procedure were inspected as PR evidence, not independently replayed. No merge, release, or deployment performed.

immakermatty and others added 4 commits October 22, 2026 22:42
…son can remove

Root decision 0210, plan DEV-6676 (row 26). Buddy's surface shows the host
page's last valid lazurio.buddy.context as a chip above the composer, for
example "Apps /apps", with a button that removes it. While the chip is there,
a message the person writes carries the page as a composer record of kind
`lazurio-page` with a reference in its text. Buddy's T3 Code projects it for
Hermes as the labelled Czech block of row 23. An empty message carries
nothing. A removed chip stays removed for that page, and another page brings it
back.

The record is the contracts' generic UnknownContextRecord with the payload
buddyPrompt.ts reads, so no contract changes. The seams:
- ChatView adds the reference and the record where it sends, and renders the
  chip above the composer.
- The composer's and the timeline's presentation registries show a page
  reference as a page chip in their fallback, where T3 would call an unknown
  context unavailable.

buddySurfacePage.test.ts covers the record, its id, its label, the wire schema
and the empty message. In the bubble's frame, a message with the chip reached
Hermes with the Czech block, and one sent after removing the chip did not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ronment

After the rebase on #107's c638b4b732, where Buddy mode is checked for a
timeline's own Environment, the page hook takes the chat's Environment as well
(useBuddyPage(environmentId)). A thread of another Environment never carries
Buddy's page record. It also passes the mode to the language hook, which now
takes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd a removed page stays removed

Pablo's review of 98b2aa1bc3.

The page reference was added to promptForSend, which the queued-message edit
and the plan follow-up also send, with contexts of their own that lack the
record. Their messages referred to the page, and Buddy's T3 Code dropped the
block. The reference now joins only the regular send's text
(messageTextForSend), whose context takes the record from that same text.
Those two paths therefore carry no page. While a queued message is edited, the
chip is hidden, since that send will not carry it. The release contract pins
the single place (one withPageReference in ChatView, in messageTextForSend).

A removed chip now stays removed for its page, also after the host visits
another page and comes back: the surface keeps every page the person removed.
In the bubble's frame: a message with the chip reached Hermes with the block;
after the chip was removed, the words only. Another page showed its chip, and
the first page, visited again, did not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…retry carries the page as it is then

When a send failed, ChatView put messageTextForSend back into the composer. That text already
carried the page reference, so after the person removed the chip, or after the host moved to
another page, the retry sent the old page's reference without its record: Hermes got no block for
it, and the sent message still showed its chip (Pablo's P2 on 7b305d4364).

messageTextForSend is T3's again, the person's own words, and the page joins a text of its own,
pageTextForSend, which only the record and the two texts on the wire read. Both restores of a
failed send, the single and the multi-model one, give back the words; the retry adds the page the
chip shows then, or none.

The release contract now pins that split and that both restores read the words; it fails on the
reviewed ChatView and when either restore reads the page's text. The runbook's rebuild note for
row 26 says the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@immakermatty
immakermatty force-pushed the agent/DEV-6676-buddy-t3-page-chip branch from 70412e2 to dc1e266 Compare October 22, 2026 20:42
@immakermatty
immakermatty merged commit 626cf80 into main Oct 22, 2026
7 checks passed
@immakermatty
immakermatty deleted the agent/DEV-6676-buddy-t3-page-chip branch October 31, 2026 18:25
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.

2 participants