Registry Mirror
Skip to content

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Part of #808 (row 6: the owner answers secret and sign-in cards in the parent thread).

Finding. Upstream shows neither a child's secret card nor its link (pairing) card in the parent thread, so the fork's prompt mirror showed them read-only ("Only you can answer it, in the task's own thread on that machine"). But a secret card is answered by one client RPC to the machine that holds the request (answerSecretRequest with that environment's id), and this app already holds a connection to every machine it is connected to. So the fork side stays thin: the mirror's banner holds upstream's own card, bound to the task's machine. No new answering contract between machines, no server change.

What changes (fork web files only):

  • promptMirrorAnswer.logic.ts (pure): answerHere says where an open secret or pairing card is answered from this app: the task's thread (childThreadId) on its machine, when that machine is the parent's (machine: null) or in useConnectedEnvironmentIds() now. Questions, approvals, unknown cards and cards with no id never are (upstream's own cards and Prompt mirror: leave a prompt upstream shows answerable to its card (#808 row 5) #1433 cover questions and approvals). answerCardItem finds the task's own secret_request / link_request item by the card's id (the server's promptId is that turn item id), in any state.
  • PromptMirrorAnswer.tsx: reads the task's thread with useQuietThreadProjection (as upstream's child approval cards read a waiting child's detail) and renders upstream's SecretRequestCard or LinkRequestCard with the task's environmentId, the item and its visibility. Until that thread holds the card, nothing shows and the banner's text stands.
  • promptMirrorItems takes an optional answerCard callback; a secret or pairing card with an answer card says "Only you can answer it, here or in the task's own thread. It goes from this app straight to , never through the agents. Never paste the value in chat." and holds the card as the banner's children. Without one (machine not connected), the old text stays.
  • useForkPromptMirrorItems passes promptMirrorAnswerCard(parentRef, connectedIds).
  • Change file docs/fork/changes/app/808-answer-secret-link-cards-in-parent.md.

Where the value goes. The value is typed into upstream's card and sent by this app on the task machine's own connection, to the machine that asked. The parent's machine never receives it, and neither does the orchestrator's model, the mirror route or the thread history. The mirror route still carries labels only (unchanged). A reference answer (secret providers) follows upstream's rule on the task's machine (AuthProvidersManageScope there).

State question.

  • Answered twice (here and in the task's own thread, or two clients): the asking machine keeps the one record and refuses a second answer. Upstream's card shows its failure text. Nothing is stored here.
  • The link drops while the card is open: the machine leaves the connected set, so the banner loses the card and says "answered there". It comes back when the machine reconnects and the mirror still lists the card.
  • The task is gone, or the card is answered: the task's thread shows the card's outcome (Saved / Dismissed) until the next mirror read (10 s while cards show) drops the banner. A card not in the thread as loaded shows the banner alone.
  • The parent restarts: nothing is kept on the parent. The next mirror read rebuilds the banners.
  • Upstream later shows these cards in the parent: then this card would show twice. Dropping the mirror's copy follows Prompt mirror: leave a prompt upstream shows answerable to its card (#808 row 5) #1433's rule (drop what upstream shows answerable).

Left for #808: row 6's sign-in links that are not link cards (a provider sign-in on a linked machine) are row 7's "Waiting on you" rows (#1434). Rows 4, 5 and 7 are in their own open PRs.

Overlap. #1433 also edits promptMirrorItems.tsx and useForkPromptMirrorItems.ts (other lines: its drop rule). Whichever merges second needs a small rebase.

Tests (red on main: the new module and promptMirrorAnswerCard do not exist there, and the banner text differs):

  • promptMirrorAnswer.logic.test.ts (node): which cards are answered here and on which machine and thread, and which item is the card. Passes locally.
  • promptMirror.logic.test.tsx (node): the banner's text and card for a card answered here and one answered there, questions not asked for a card, and the callback binding the task's machine. Passes locally (23 tests across both files).
  • PromptMirrorAnswer.browser.test.tsx (browser): the banner holds the secret card bound to the task's machine (env-b), the link card for a task on this machine, no card and no thread read for a machine that is not connected, and the banner alone when the card is not in the thread. Not run locally: the browser cannot launch on this machine (local sockets are blocked). The existing useForkPromptMirrorItems.browser.test.tsx was not run here for the same reason. CI runs both.
  • vp run check:changed: format, lint, knip, typecheck and react compiler pass. Its test step fails only on the two browser files, which cannot launch here. The fork schema, upstream-files and seam checks pass.

🤖 Generated with Claude Code

…ad (#808 row 6)

A delegated task's secret or link (pairing) card now holds upstream's own
SecretRequestCard / LinkRequestCard in its prompt-mirror banner, read from
the task's thread and bound to the task's machine, so the value goes from
this app straight to the machine that asked. Only for a task on the
parent's machine or on a machine this app is connected to; otherwise the
banner keeps its "answered there" text.

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

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens r1) · read at: a45486a

blocker: none
major: none
minor: #1433 conflicts on the same lines, not "other lines": git merge-tree pr p1433 gives content conflicts in promptMirrorItems.tsx, promptMirror.logic.test.tsx (and touches useForkPromptMirrorItems.ts). Both PRs add a different second parameter to promptMirrorItems/entryItem (answerCard here, a required connected: ReadonlySet there). Whoever rebases second must keep both. They should also reuse one connected set (this PR uses an array, #1433 a Set), and give the not-connected secret text #1433's "Connect to this app to answer it here" so the two read the same.
minor: When the task's thread is not loaded yet, or does not hold the card, the banner still says "Only you can answer it, here or in the task's own thread…" but shows no card. children is always a truthy element, so an empty ComposerBanner.Children div renders too. The PR body says "the banner's text stands", but it is the new "here" text. Showing the "here" text only when answerCardItem finds the card (e.g. let PromptMirrorAnswer own the description) would make it exact. Cosmetic: nothing leaks and nothing is sent.

What I checked:

  • Where the value goes: PromptMirrorAnswer passes answer.threadRef.environmentId (the task's machine: entry.machine.environmentId, or the parent's own for machine: null) to upstream's SecretRequestCard/LinkRequestCard. Both send with answer({ environmentId: props.environmentId, input }), and the input is built from the item (secretRequestAnswerInput/linkRequestAnswerInput). Reference sources and AuthProvidersManageScope are read for that environment too. The fork code only reads (useQuietThreadProjection) and writes nothing. The mirror route, the server and the thread history are untouched, so the value never reaches the parent's machine (for a remote task), an agent or the mirror.
  • Ids line up: the server's mirror promptId is the turn item id on the task's machine (secret.itemId/pairing.itemId locally, item.id in remoteTaskPrompts.ts). answerCardItem matches id and type. Remote tasks list secrets only, so a pairing card is only ever bound to the parent's machine, as intended.
  • Machine not connected: answerHere returns null unless the environment is in connectedEnvironmentIdsAtom (connectionState "connected", which includes the primary). Then no element, no thread subscription and the old read-only text, which the browser test asserts (childRefs empty). A drop while the card is open: the next render leaves the connected set, so the card unmounts and the old text returns.
  • Duplicates: ChatView joins the items into one of two exclusive lists (draft hero or not), so one form shows. Upstream shows no child secret or link card in the parent (an inherited row would show "pending elsewhere" anyway).
  • Tests: logic and browser tests cover answered here or there, the bound machine, the link card on this machine and the card missing from the thread. They are red on main (the new module is missing). CI is green, browser tests included. I ran no tests: nothing suspected needed one beyond the merge-tree check above.

State question:

  • Runs again (10 s poll, re-render): the element is rebuilt each render, but the banner keeps its stable id key and its type, so the card's form state (typed values) survives polls. A second answer (here and in the task's thread, or two clients) is refused by the asking machine. Upstream's card shows the error. Nothing is stored here.
  • Stops half-way (connection drops mid-answer): upstream's in-flight handling applies. On failure the card puts the values back. On success the item turns answered and the next mirror read drops the banner.
  • Old or empty state: the thread is not loaded or the card is missing, so the banner shows alone (see the second minor). After a parent restart there is no fork state, and the next mirror read rebuilds the banners. With more cards than PROMPT_MIRROR_CARDS_SHOWN, a card pushed into the overflow line unmounts and loses typed text. This is rare and acceptable.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: security · reviewer: Claude Opus 5.5 (security lens r1) · read at: a45486a

blocker: none
major: the answer card is a <form> nested inside the composer's <form>, so saving a secret (Enter or "Save securely") also submits the parent composer. ChatComposer renders ComposerBannerStack items={shelfItems} inside its <form onSubmit={submitComposerStable}> (ChatComposer.tsx about line 3759 to 4320), and the mirror banner now holds upstream's SecretRequestCard / LinkRequestCard as children. Both cards' onSubmit only call event.preventDefault(), never stopPropagation(). The submit event bubbles in the DOM and through React's tree (also out of a portal), so submitComposer runs too. It does not check defaultPrevented, so it sends whatever draft the parent composer holds to the orchestrator's agent, or with an empty draft runs Resume. The secret value itself is not in that send (the composer reads its own draft), but answering a card must not post a message to the parent agent. Fix: stop propagation at the mirror's wrapper (<div onSubmit={(e) => e.stopPropagation()}> around the card in PromptMirrorAnswer), plus a browser test where the banner sits in an outer form whose submit spy must stay uncalled. Not reproduced here: this machine had no capacity for a browser run for over 30 minutes. Found by reading the code; the repro test is below.
minor: the banner says the value goes "straight to " using the mirror's label (sent by the parent's server), while the card is bound to entry.machine.environmentId. Naming the machine from this app's own record for that environment id would keep the text true even if the two ever differ.

Repro (browser project; expected to fail on this head):

const items = promptMirrorItems([secretEntry], () => (
  <form onSubmit={(e) => { e.preventDefault(); saved(); }}>
    <input aria-label="secret" type="password" />
    <button type="submit">Save securely</button>
  </form>
));
await using screen = await render(
  <form onSubmit={composerSubmit}><ComposerBannerStack items={items} /></form>, { router: false });
await screen.getByRole("button", { name: "Save securely" }).click();
expect(saved).toHaveBeenCalledTimes(1);
expect(composerSubmit).not.toHaveBeenCalled(); // fails: the submit bubbles

Where the value can go (checked). The card is upstream's own and gets the task's environmentId. The item comes from that machine's own thread projection (useQuietThreadProjection(answer.threadRef)), and answerSecretRequest / peerLinkEnvironment.answerRequest go out on that environment's connection. The parent's server, the mirror route, its model and thread history never get the value. The mirror route still carries labels only. The typed value lives in the card's React state only: it is not in a draft store or localStorage, autoComplete="off", and the failure cause is kept out of the console (reportFailure: false). Drag and drop into the composer's capture handlers only claims app-internal mention types, so text dragged into the secret field is not taken. Reference answers and link minting still follow the task machine's own scopes (AuthProvidersManageScope, AuthAccessWriteScope, answerRequest.permissionAtom). Another viewer of the parent sees the card only if their own app is connected to that machine, and answers with their own scopes there.

Forged or stale card. A wrong mirror entry (a bad childThreadId, promptId or machine id) can at worst show a real open card of another thread, on a machine this app is already connected to, under a misleading banner title. The answer still goes to the machine that holds that request, never somewhere the entry names, and the card shows its own label. A card id that is not in that thread shows nothing (answerCardItem matches id and type). A stale entry (up to one 10 s poll) shows the live card's outcome (Saved / Dismissed) instead of a form.

State question.

  • Runs again / answered twice (here and in the task's thread, or two clients): the asking machine keeps the one record and refuses the second answer; upstream's card shows the failure. Nothing is stored here.
  • Stops half-way (the link drops while typing, or the mirror read fails): the machine leaves the connected set, or the entries go away, so the card unmounts and the typed value is dropped from memory, not kept. A send already in flight finishes or fails on that machine's connection only.
  • Old or empty state: no entries or no thread ref give no banners. A machine not connected keeps the old read-only text, and its thread is not read. The task gone, or the card not in the thread as loaded, gives the banner alone. Nothing is kept on the parent across a restart.

🤖 Generated with Claude Code

…this app does

Upstream's secret and link cards are forms, and the mirror banner sits inside
the composer's form, so saving a card (Enter or "Save securely") also submitted
the composer (sent its draft or ran Resume). The mirror's wrapper now stops the
submit at the card.

The banner's "goes straight to <machine>" text now uses this app's own name for
the machine the card is bound to (its environment id as fallback), not the
label the parent's server sent.

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

Copy link
Copy Markdown
Owner Author

Fix round 1 (security lens r1), head 48eef8e:

  • Major, a card's submit also submitted the composer: fixed. PromptMirrorAnswer wraps the card in <div className="contents" onSubmit={stopPropagation}>, so Enter or "Save securely" submits only the card. Test: PromptMirrorAnswer.browser.test.tsx › "saving the card does not submit the composer's form around the banner". The banner sits inside an outer form; the test clicks "Save securely" and presses Enter in the field, and the outer submit spy must stay uncalled. The card stubs are now forms, like upstream's cards.
  • Minor, the banner named the machine with the parent server's label: fixed. "It goes from this app straight to …" now uses this app's own name for the bound environment id (PromptMirrorMachineName, which reads useEnvironment(id)?.label) and falls back to the id. The title still says where the task runs. Tests: PromptMirrorAnswer.browser.test.tsx › "says the value goes to the machine as this app names it, not as the parent's server does" and › "names the machine by its id when this app has no name for it". promptMirror.logic.test.tsx › "a secret or pairing card answered here holds…" and › "the answer card is the task's own card on its machine…" check that the name comes from the answer callback and is bound to env-b.

Checks: the node tests pass (23). I ran them against the old source and the two updated node tests fail there. vp run check:changed passes format, lint, knip, typecheck and react compiler. The browser tests were not run locally: Chromium cannot launch on this machine (libnspr4.so is missing), so I could not watch the three new browser tests fail first. CI runs them. On the old head the outer-form test should fail (the React submit bubbles), and the two name tests should fail too (the old text said "Build box").

🤖 Generated with Claude Code

Chromium stops a nested form's submit at the form around it, before it
reaches React's root. The card in the parent's banner sits inside the
composer's form, so its React submit handler never ran and the browser
submitted for real: "Save securely" or Enter reloaded the page and saved
nothing (the browser test file crashed on CI with "Cannot connect to the
iframe").

The card now renders through a portal set inside the banner. React listens
on a portal's own node, so it gets the submit there, below the composer's
form; the card stays in the same React tree, and keepSubmitInCard still
keeps the submit from the composer's handler.

Tests: the submit test keeps the page on a real submit so the failure is
an assertion (saved 0 times without the fix); the two machine-name tests
render in a wide column, since the banner hides its detail line in the
phone-wide test page.

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

Copy link
Copy Markdown
Owner Author

Fixed the red Fork tests run (Test Web 3): Chromium stopped the card's submit at the composer's form before React saw it, so saving reloaded the page. The card now renders through a portal inside the banner (15a9839); the PromptMirrorAnswer browser tests all pass locally.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: security · reviewer: Claude Opus 5.5 (security lens r2) · read at: 15a9839

blocker: none
major: none
minor: on a narrow column (phone width) the banner hides its description line, so the "goes from this app straight to " text, now named by this app, is not shown there. The only machine name left is the title's ("… on waits on …"), which still comes from the parent server's mirror label. The card itself is still bound to the right machine and shows its own label, so nothing goes to the wrong place. Only the text a phone user reads could name a different machine if the two labels ever differ. A fix, if wanted: name the machine in the title with PromptMirrorMachineName too, when an answer card is present.

Round 1, fixed (verified in the browser): a card's submit no longer reaches the composer. I ran PromptMirrorAnswer.browser.test.tsx in Chromium:

  • head 15a9839: 7/7 pass, including "saving the card does not submit the composer's form around the banner" (click and Enter: card saved twice, composer spy never called).
  • the head's test against the 48eef8e component (stop wrapper, no portal): that test fails, expected "vi.fn()" to be called 1 times, but got 0 times at the first save. The card's own handler never runs, so the portal commit is needed, as the writer found on CI. React also warns " cannot be a descendant of " there.
  • the a45486a component (no fix at all) cannot load the head's test file (no PromptMirrorMachineName export). A run with only the portal and wrapper taken out did not get machine capacity in about 20 minutes. Round 1's reading of that case stands.

Round 1 minor, fixed: the description names the machine through useEnvironment(id)?.label, with the id as fallback. The two tests pass (with the wide column). See the minor above for the title.

Other paths for the value or a submit (checked, none found):

  • Submit: with the portal, React gets the card's submit at the portal node. The wrapper's stopPropagation stops it in React's tree and in the DOM, so neither the composer's onSubmit nor React's root sees it. LinkRequestCard's buttons outside its form are type="button" (and Button defaults to type="button"). Its form and its form={formId} submit button sit in a dialog portal outside the composer's DOM, and that dialog's React submit also bubbles up to the wrapper and stops there.
  • Paste and typing: paste-to-focus and type-to-focus (shouldRedirectInputToComposer) skip any event whose path holds an input or [data-v2-item-type="secret_request"], which is upstream's SecretRequestCard form itself. So a pasted or typed value is never moved into the composer draft. The dictation submit shortcut skips input targets. The composer's paste-as-text keydown only arms a flag and reads no value.
  • Drafts, history, model: the value lives only in the card's React state (autoComplete="off"). It is not in the composer draft store, localStorage or the mirror route, and it is sent only by upstream's card on the task machine's connection, as in round 1. The composer's form-level onKeyDown (Escape cancels a held send) and its focus/blur capture still hear events from the card through React's tree. They only change focus state or cancel a held send and never read the value: harmless.

State question.

  • Runs again / answered twice (here and in the task's own thread, or two clients): the asking machine keeps one record and refuses the second answer. Upstream's card shows the failure. Nothing is stored on the parent.
  • Stops half-way (the link drops while typing, the mirror read fails, the banner unmounts): the portal and card unmount with the banner, so the typed value is dropped from memory. A save already in flight finishes or fails on the task machine's connection only. The first render shows no card until the portal node is set (one extra render). No half-shown form can submit to the composer.
  • Old or empty state: no entries or no thread ref give no banners. A machine that is not connected keeps the read-only text, and its thread is not read. A card id not in the thread as loaded gives the banner alone. An answered card shows its outcome until the next mirror read drops it. Nothing is kept across a restart.

🤖 Generated with Claude Code

@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 30, 2026
@scuttletoby

Copy link
Copy Markdown
Owner Author

Merge conveyor: head 15a9839dd218 does not merge cleanly on main 9983982c4c2e (conflicts in apps/web/src/components/fork/promptMirror/promptMirror.logic.test.tsx, apps/web/src/components/fork/promptMirror/promptMirrorItems.tsx, apps/web/src/components/fork/promptMirror/useForkPromptMirrorItems.ts): fork:merge-ready swapped for fork:merge-blocked. Merge main into the branch (a writer may already be queued for it), then add fork:merge-ready again.

@scuttletoby scuttletoby added fork:merge-blocked Merge conveyor: did not merge, needs a look (PRs) and removed fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) labels Nov 30, 2026
Main brought #808 row 5 (prompt mirror leaves questions and approvals
upstream already shows to upstream's cards; not-connected wording).
Both sides kept: promptMirrorItems takes main's `connected` set and the
branch's answer card; the hook filters with entriesNotShownHere, then
lets secret/link cards on connected machines hold the task's own card.

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

Copy link
Copy Markdown
Owner Author

Rebase

Merged main (9983982) into the branch. This is a merge commit, with no force-push. The new head is d8ad1d6.

What conflicted: main brought #808 row 5 (#1433). That change leaves questions and approvals that upstream already shows to upstream's own cards, and adds the "not connected" wording. This branch's secret/link answer card touched the same three files:

  • promptMirrorItems.tsx: I kept both sides.
    • It keeps main's ShownChild / UpstreamShows / entriesNotShownHere / answerWhere and the branch's PromptMirrorAnswerHere / PromptMirrorAnswerCard.
    • promptMirrorItems(entries, connected, answerCard = NO_ANSWER) and entryItem(entry, connected, answerCard) take both parameters. Secret/pairing cards with an answer card hold it; the rest keep main's descriptions.
    • I merged the header comment.
  • useForkPromptMirrorItems.ts: the hook runs main's upstream filtering first (useChildThreadInputs, run-stop atom, entriesNotShownHere). It then passes the kept entries to promptMirrorItems along with the connected set and promptMirrorAnswerCard(...). I shortened the header comment to stay within the comment-length lint.
  • promptMirror.logic.test.tsx: I kept both import sets. Main's cards() helper now takes an optional answer card, and the branch's answer-card tests call it.

One more change: the branch's PromptMirrorAnswer.browser.test.tsx now also mocks useChildThreadInputs (empty) and environmentThreadDetails.runStopAtom (null). The hook reads both since main's change, and main's own browser test mocks them the same way.

Checks:

  • promptMirror.logic.test.tsx and promptMirrorAnswer.logic.test.ts: 30 tests passed.
  • Web typecheck passed.
  • The three fork-checks script test suites (201 tests) passed, and the schema, upstream-files and seam checks ran against main and passed.
  • vp run check:changed passed format, lint, knip, typecheck and react compiler.
  • The two browser tests could not run here because headless Chromium is missing a system library on this machine. CI covers them.

@scuttletoby scuttletoby added fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) and removed fork:merge-blocked Merge conveyor: did not merge, needs a look (PRs) labels Nov 30, 2026
@scuttletoby
scuttletoby merged commit 13930dd into main Nov 30, 2026
30 checks passed
@scuttletoby
scuttletoby deleted the fork/808-row6-secret-cards branch November 30, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant