Skip to content

feat(fork): a Petal's asks sit above its composer, one at a time, with its status and one-click answers - #374

Merged
NoahHendrickson merged 9 commits into
customfrom
t3/digest-status-answers
Nov 19, 2026
Merged

NoahHendrickson merged 9 commits into
customfrom
t3/digest-status-answers

Conversation

@NoahHendrickson

@NoahHendrickson NoahHendrickson commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

A Petal's digest was hard to glance at. It read like a log in the Threads panel, packed several asks into one line, and never said whether anything needed you.

  • In the chat column: on a Petal's own conversation, its asks sit just above the composer (BotDigestAsks, one fenced line in ChatView beside upstream's ChildThreadApprovals, inside the composer stack so the transcript inset counts it). The Threads panel now lists threads only.
  • Composer's double vessel: the digest wears the composer's vessel, box and surface stamps, so each theme paints it as its composer. The vessel's top strip holds the Petal's Status: line (else "Needs you"), "Show N dismissed", and a pager: previous, one dot per ask with the current one a rounded dash, then next. The ask on show is the surface inside.
  • One ask at a time: the stack never grows with the list, so there's no scroll area. Each ask has an X that dismisses it on this device (keyed by the ask's text, so a rewritten ask comes back), and "Show N dismissed" undoes it.
  • The card: a 32px tile in the ask's colour leads it: the state of the pull request it is about (open, draft, merged or closed, in the app's PR tones), else the sidebar's needs-input colour. Then the question (splitBotDigestAsk: the first sentence that asks one), muted detail clamped to two lines, its thread and PR links, and the actions below.
  • One-click answers: an ask can end with up to four short answers after an arrow: → Push | Hold. Clicking one queues the ask, quoted, plus the answer as the owner's message to the Petal (startTurn, dispatchMode: "queue"). The buttons show "Sent" until the Petal settles a run after the send. A failed send restores that card's buttons and shows an error toast. Reply quotes the ask into the composer, or opens a linked thread that is waiting on a question.
  • Petal instructions: the seeded CLAUDE.md teaches the status line, question-first asks, and the arrow answers, and says they show above the composer. BOT_RULES_VERSION goes to 4 so existing Petals get the new instructions. New and In progress stay in DIGEST.md for the Petal's own memory and are not drawn.
  • Removed: the right-panel digest machinery (resize rule, Updates fold) and the vertical-edge fences it had added to useResizeDrag, which is back to upstream.

Tests: parser cases for answers (including after a bare PR URL), arrow prose, long answers, the status line, and the question/detail split. Guards pin the ChatView mount, the panel without a digest, and the seeded instructions.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol on high. Sol verdict: changes requested. Fixed: answers after a bare PR URL, the rules-version bump, an unbounded stack, stale "Sent" states (expiry, carry-over between Petals) and the failed-send rollback. Declined (S5): a late send failure can clear a newer answer to the same ask if a run settled and the ask was re-answered while the first send was pending. It's rare, and the error toast already reports it. The dots, dismiss and double-vessel layout came after the loop.

Model and harness: Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…ick answers, updates fold

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list. labels Nov 19, 2026

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed 8b059ed114d3e16384d8cbba5c196047ae8409f8 against the PR diff for base 0aa266b5588dc1ea3532a268cf34bde406d98f81. A focused parser check reproduced both parsing issues below. I traced the send state through command handling and the panel lifecycle in source.

.filter(Boolean) ?? [];
if (
match === null ||
!/[?.!)>]$/.test(line.slice(0, match.index).trimEnd()) ||

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[P2] Recognize answers after a bare PR URL

The seed tells Petals to append the full PR URL before the answer arrow. An ask such as Merge now? https://github.com/acme/app/pull/21 → Merge | Hold ends in a digit before the arrow, so the parser returns zero answers and displays the options as prose. This also happens when a Markdown thread link precedes the PR URL. Recognize supported trailing links in the boundary check and cover a bare PR URL in the parser test.


function parseItem(line: string): BotDigestItem {
const source = unmarked(line);
const split = splitAnswers(unmarked(line));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[P2] Restrict answer parsing to Needs you items

parseItem also parses the headline and update rows. For example, Status: Migrated the job (cron) → scheduler becomes Migrated the job (cron), silently losing the destination. The same happens in New and In progress, where the extracted suffix is never rendered and is excluded from the dismissal key. Only split answer suffixes on Needs you items so status and updates keep their original text.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
);
// The answer each ask was given here, for the digest as it read then: once the bot rewrites it,
// an ask it kept offers its answers again.
const [sentFor, setSentFor] = useState<{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[P2] Keep sent answers when the Threads panel closes

Closing the panel unmounts BotDigest once the exit transition finishes. If the answer is queued behind an active turn, reopening the panel before the Petal edits the digest shows the same buttons again. A second click creates a new message ID and queues a duplicate or conflicting answer to the same ask. Keep the acknowledgement outside the panel component and scope it to the Petal, digest contents and ask.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
const updateCount = updates.reduce((count, section) => count + section.items.length, 0);
// An answer goes to the bot as the owner's reply, quoting its ask, behind whatever it is doing.
const answer = async (item: BotDigestItem, choice: string) => {
setSent((previous) => new Map(previous).set(item.source, choice));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[P2] Report send failures in the digest

The row shows “Sent” before the command returns, then silently brings back the buttons if it fails. For example, a connection with filesystem read access but without orchestration operate access can see and click the buttons, and the command returns an authorization failure without a user-facing message. Show a pending state until the command succeeds, surface failures so users know to retry, and disable sending where the connection lacks permission.

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Thermo-nuclear code-quality review of 8b059ed114d3e16384d8cbba5c196047ae8409f8. Not approving. No file crosses 1k lines (BotDigest.tsx is now 467 lines, botDigestSections.ts 211), so size is fine. The problems are about structure and where the logic lives.

Blocking

  1. Answers are parsed in the wrong layer, and that loses words. splitAnswers runs inside parseItem, which handles every line: Needs you, New, In progress, section headings and the status line. Only Needs you renders answers, but every item's source/text gets cut. So an In progress line Deploy v2 (beta) → stable shows as Deploy v2 (beta), and a status of Ship it? → Yes | No shows as Ship it?. The "finished ask" check /[?.!)>]$/ makes this worse. It counts any ) or > as a finished ask, so prose like Migrate (staging) → prod turns into a prod button. Answers belong to Needs you only, so split them only there. Decide "after its links" with the link-run walk parseItem already does, not a second regex that guesses at link endings.

  2. useTellBot copies the tell function in useSetBotWork.ts. Both do readThreadShell → startTurn with dispatchMode: "queue" and the shell's modes. Move it into one custom/bots/useTellBot.ts that both callers use. The copies have already drifted: the new one doesn't check for an archived bot, and only the new one reports failure. One send-to-bot path, one set of rules.

  3. The "Sent" state is a hand-built reset-on-key. sentFor + setSent + NO_ANSWERS compare contents in two places and copy Maps, all to say "forget this when the file changes". React already does that: move the per-ask state into a BotDigestRequest item component (useState<string | null>) and key the Needs you list by contents. sentFor, setSent, NO_ANSWERS, the sent prop, the answer closure and the Map rollback all go away, and behavior stays the same.

Strong suggestions

  1. One parse, one model. The component calls parseBotDigest and parseBotDigestStatus behind the same file === null || file.exists === false guard, and the effect parses a third time. One parser is told to skip Status: lines and the other is told to find them. Have parseBotDigest return { status, sections } (or { status, needsYou, updates }). Then the shown.map(… ? … : null) ternary, the second updates filter and the duplicated guard all disappear, and the empty check becomes one property.

  2. Fold and dismiss now both hide the same updates. Updates are folded by default, and each card keeps its per-bot dismissal: localStorage, the pruning useEffect, hiddenCount, "Show N dismissed" and botDigestSectionKey. With everything dismissed you get an "Updates 0" header with only "Show N dismissed" inside. Folding seems to replace dismissal; if so, removing dismissal deletes a whole layer. Please choose one on purpose rather than keep both.

Smaller

  1. The prompt prop now holds a nested ternary (answers.length === 0 ? null : given !== undefined ? … : …), and the Reply variant repeats the same condition. Pull out a BotDigestAnswers component and derive offering once. The > ${item.source}\n\n quote is also built twice (answer and reply), so give it one helper.
  2. splitAnswers was added between parseItem's doc comment and parseItem. The result is two doc comments stacked on splitAnswers, and parseItem has none.

Not covered by tests: the send/rollback path, and the misparse cases above. Add rows for Migrate (staging) → prod and for an arrow inside an In progress item.

— Claude Opus 5.5 in Claude Code


function parseItem(line: string): BotDigestItem {
const source = unmarked(line);
const split = splitAnswers(unmarked(line));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This runs for every line: updates, headings and the status line, not only Needs you. It cuts → … out of their text: - Deploy v2 (beta) → stable under In progress shows as Deploy v2 (beta). Answers are a Needs-you concept, so split them only for that section's items, and keep parseItem a plain line parser.

.filter(Boolean) ?? [];
if (
match === null ||
!/[?.!)>]$/.test(line.slice(0, match.index).trimEnd()) ||

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

) and > are standing in for "a link ended here", but they match any closing paren: Migrate (staging) → prod gives a prod button. parseItem already works out the trailing link run and the sentence end (SENTENCE_END, BETWEEN_LINKS). Use that instead of a second guess at link endings.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
/** Queues `text` as the owner's message to the bot, behind whatever it is doing; false when it
could not be sent. */
function useTellBot(): (botRef: ScopedThreadRef, text: string) => Promise<boolean> {
const startTurn = useOrchestrationCommand(threadEnvironment.startTurn);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This copies tell in useSetBotWork.ts (same readThreadShell → startTurn queue call). Move it into one useTellBot module that both use. The copies already differ: this one doesn't check archivedAt.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
);
// The answer each ask was given here, for the digest as it read then: once the bot rewrites it,
// an ask it kept offers its answers again.
const [sentFor, setSentFor] = useState<{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This builds "reset when the file changes" by hand (sentFor, setSent, two contents comparisons, Map copies). Move the state into a per-ask component and key the Needs you list by contents: React resets it for you, and this block, NO_ANSWERS, the sent prop and the rollback Map edits go away.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
});
const file = AsyncResult.getOrElse(result, () => null);
const sections = file === null || file.exists === false ? [] : parseBotDigest(file.contents);
const status =

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The same file guard and a second pass over the file. Let parseBotDigest return { status, sections } so there's one parse and one model, and the empty check and the shown.map(… : null) partition below become simple reads.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
Show {hiddenCount} dismissed
</Button>
</div>
{updates.length === 0 && hiddenCount === 0 ? null : (

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Updates now have two ways to hide (a global fold plus per-bot dismissal with its pruning effect), and with everything dismissed this draws "Updates 0" with only "Show N dismissed" inside. If the fold replaces dismissal, removing dismissal deletes a whole layer. Either way, choose one on purpose.

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code review of 8b059ed (Claude Code, single pass).

The parser tests and the fork-bots guard pass on this commit (18/18). I found three problems, inline below. The first one breaks the main feature for asks that carry a pull request:

  1. High: answers are never parsed when the ask ends with its PR URL, and the seeded CLAUDE.md tells Petals to write exactly that.
  2. Medium: a Status: line anywhere in the file becomes the headline and is dropped from its section.
  3. Low: "Sent" lives only in component state, so after a remount the buttons come back and a second click queues a second answer.

🤖 Generated with Claude Code

.filter(Boolean) ?? [];
if (
match === null ||
!/[?.!)>]$/.test(line.slice(0, match.index).trimEnd()) ||

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

High: answers are lost when an ask ends with its PR URL. The finished-ask check only accepts ?, ., !, ) or > before the arrow. A bare URL ends in a digit, so the check fails. The seeded CLAUDE.md tells Petals to end each item with the thread link and then the PR's full URL, with answers after the links. So any ask about a pull request, which is the main case for → Push | Hold, gets no buttons.

It is worse than no buttons: because the arrow text stays in the line, the trailing links stop being dropped as well. I checked this on the PR head:

- Merge #482? [Fix search](t3-thread://v2/env-1/thread-1) https://github.com/acme/app/pull/482 → Merge | Wait
→ text: "Merge #482? Fix search #482 → Merge | Wait", answers: []
- Merge #483? https://github.com/acme/app/pull/483 → Merge | Wait
→ text: "Merge #483? #483 → Merge | Wait", answers: []

A possible fix: when the text before the arrow ends in a bare URL token (TOKEN's bare-URL group), count it as a finished ask. Or run the test against the line's words after the trailing links are stripped. A test row with a thread link plus a PR URL plus answers would cover it.

/** The digest's status line in plain words (`Status: Waiting on you · next scan Thu 8:00`), or
null when the bot wrote none. */
export function parseBotDigestStatus(contents: string): string | null {
for (const raw of contents.split(/\r?\n/)) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Medium: a Status: line inside a section becomes the headline. parseBotDigestStatus returns the first Status: line anywhere in the file. parseBotDigest (line 176) skips every such line in every section. So an unbulleted item like Status: CI red on #9 under In progress does two things: it disappears from its section (which then counts as empty and is dropped), and it shows as the digest's headline. I confirmed this on the PR head. The new test even accepts a Status: line inside Needs you and silently ignores it.

The instructions put the status line under the title. Reading it, and skipping it, only before the first ## heading would keep section content intact.

Comment thread apps/web/src/custom/bots/BotDigest.tsx Outdated
);
// The answer each ask was given here, for the digest as it read then: once the bot rewrites it,
// an ask it kept offers its answers again.
const [sentFor, setSentFor] = useState<{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Low: "Sent" is forgotten on remount, so an answer can go twice. sentFor is plain useState. Closing and reopening the Threads panel or sheet, or switching to another Petal and back, clears it while the digest file is still unchanged. The bot hasn't run its queued turn and rewritten the digest yet, so the buttons come back, and a second click queues a second > ask\n\nanswer turn. The PR description says the buttons give way to "Sent" until the Petal rewrites its digest, which doesn't hold across a remount.

One option is to keep it beside dismissed, in localStorage keyed by the bot and the digest contents. Another is to derive it from the bot's queued or pending user messages.

xxxxxxxxxxxxx and others added 2 commits November 18, 2026 19:39
… the Threads panel lists threads only

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NoahHendrickson NoahHendrickson changed the title feat(fork): a Petal's digest leads with its status, asks offer one-click answers, updates fold feat(fork): a Petal's asks sit above its composer, lead with its status, and offer one-click answers Nov 19, 2026
@github-actions github-actions Bot added size:XL and removed size:L labels Nov 19, 2026
xxxxxxxxxxxxx and others added 5 commits November 18, 2026 19:52
…, and its actions below

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…equest's state or by needs-input

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…op fixes for answers, rules refresh and Sent state

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…strip carrying the status and pager

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NoahHendrickson NoahHendrickson changed the title feat(fork): a Petal's asks sit above its composer, lead with its status, and offer one-click answers feat(fork): a Petal's asks sit above its composer, one at a time, with its status and one-click answers Nov 19, 2026
…e status sits under the title, one send-to-bot path, and sent answers outlive a remount

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

Copy link
Copy Markdown
Owner Author

These reviews were of 8b059ed, the first version that lived in the Threads panel. Since then the digest has moved above the composer, so some points no longer apply. Status against the current head 1a29719609:

Fixed

  • Answers after a bare PR URL: fixed earlier (→ after a bare URL, Markdown link or autolink counts), with a test row.
  • Answers split from every line: only Needs you items read answers now (parseItem(line, withAnswers)). Status and update lines keep their → text.
  • ) / > read as a finished ask: the check is now FINISHED_ASK. That means sentence punctuation, a Markdown link ](…), an autolink <scheme://…>, or a bare URL. Migrate (staging) → prod stays prose, with a test row.
  • Status: anywhere becomes the headline: parseBotDigestStatus reads only under the title, and a Status: line inside a section stays that section's item, with test rows.
  • useTellBot copied tell: there's now one custom/bots/useTellBot.ts, used by both useSetBotWork and the digest. It keeps the archived check and reports failure.
  • "Sent" forgotten on remount: each bot's sent answers live in a module map beside the component, so leaving and returning before the bot answers no longer offers the ask twice. They expire once the bot settles a run after the send.
  • Send failures silent: a failed send restores that card's buttons and shows an error toast.
  • Stacked doc comments: parseItem has its own again.

No longer applies: the Updates fold and the per-section dismissal (Updates aren't drawn any more; each ask has its own dismiss), and the old sentFor/contents keying.

Declined

  • One parse returning { status, sections }: the two parsers read different parts of the file (the title block and the sections) and each stays small. Merging them isn't a fix.
  • Disabling sends without orchestration permission: a viewer without the operate scope is an edge case here. The failure toast covers it.

🤖 Generated with Claude Code

@NoahHendrickson
NoahHendrickson merged commit 98a68b4 into custom Nov 19, 2026
30 checks passed
@NoahHendrickson
NoahHendrickson deleted the t3/digest-status-answers branch November 19, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants