diff --git a/changelog.d/3140-approve-all-error-list.fixed.md b/changelog.d/3140-approve-all-error-list.fixed.md new file mode 100644 index 000000000..6f693df18 --- /dev/null +++ b/changelog.d/3140-approve-all-error-list.fixed.md @@ -0,0 +1 @@ +The **Approve all** line in a chat's approval dock now reports one entry per person: the same person failing twice is named once, and two people's failures are separated by a dot instead of running together, so a name is never read as the tail of the reason before it ([#3140](https://github.com/ThinkFlowLab/FlyBot/issues/3140)). diff --git a/docs/subsystems/social.md b/docs/subsystems/social.md index 19eeac764..46a08e779 100644 --- a/docs/subsystems/social.md +++ b/docs/subsystems/social.md @@ -44,7 +44,7 @@ At phone width (`<= 640 px`, the last block in `client.js's stylesheet`) this pa | `plugins/social/src/face-rooms.js` | Face-to-face REST client (join/list/get/start/leave/messages, mint/revoke/preview/join invites, `parseInviteLink` / `parseFaceInviteLink`), error mapping, event rendering, peer-string sanitization. Auto-send is MCP in `social.js`. | | `plugins/social/src/presence.js` | "Name is thinking…" for friends' Bots (#297): sends `set_presence` for my Bots' turns that answer a friend or run in an open face room (`turn.start` / `turn.end`, heartbeat), polls `list_presence` only while a social chat asks (`social/typing`), clears a line when that Bot's message arrives. Gated on the `presence` feature. | | `plugins/social/src/face-title.js` | Face-to-face room titles (`Face-to-face · Alice, Bob · 482913`). Ships in the plugin so a packaged install can import (#153); core keeps its own copy for hosted rooms. | -| `plugins/social/client.js` | Settings → **Bot Social** (`SocialServerSettings`, slot `flybot.settings.page`): the server form, and once connected a **Friends** list plus one **People with access** link per local Bot (#1074). `PeerThinking` dock line (`social-thinking`, order 60: one `bt-shimmer` line `Name is thinking…`). Social strip: **N to approve** badge, Add friend / Face-to-face panels from +, Past rooms; sidebar + Face-to-face room / Add friend (own handle line, per-Bot **Copy invite link**); in-chat Approve / Reject dock, waiting `flybot.room.overview` tile grid (6-digit code and its QR, then Leave / Enter chat), open room **Invite by link** card (link QR, Copy link, Withdraw link); a local group's Members card **Invite by link** row (`LocalInviteRow`, slot `flybot.room.members`: Create link / New link, the link's QR, Copy link, m:ss countdown, Withdraw link, through the core `room-invite*` endpoints via `__flybot__.host`); the Face-to-face dialog's link field and scan also take a group link of another FlyBot (`/r/@handle/ticket`): `room-invite-preview` → the shared preview card (**Join group**) → `room-invite-ask` with the picked Bots, one sentence per refusal (#876); Bot settings Sharing (Copy invite link) / Share with a friend / People with access (inside the host's titled **Sharing** card, so `BotSocialDetails` draws no title of its own, #406), or Auto-send + Remove this Bot on a friend's Bot. | +| `plugins/social/client.js` | Settings → **Bot Social** (`SocialServerSettings`, slot `flybot.settings.page`): the server form, and once connected a **Friends** list plus one **People with access** link per local Bot (#1074). `PeerThinking` dock line (`social-thinking`, order 60: one `bt-shimmer` line `Name is thinking…`). Social strip: **N to approve** badge, Add friend / Face-to-face panels from +, Past rooms; sidebar + Face-to-face room / Add friend (own handle line, per-Bot **Copy invite link**); in-chat Approve / Reject dock (its **Approve all** reports one failure entry per person, `Eve: the hold is stale · Bob: …`, a repeated reason named once), waiting `flybot.room.overview` tile grid (6-digit code and its QR, then Leave / Enter chat), open room **Invite by link** card (link QR, Copy link, Withdraw link); a local group's Members card **Invite by link** row (`LocalInviteRow`, slot `flybot.room.members`: Create link / New link, the link's QR, Copy link, m:ss countdown, Withdraw link, through the core `room-invite*` endpoints via `__flybot__.host`); the Face-to-face dialog's link field and scan also take a group link of another FlyBot (`/r/@handle/ticket`): `room-invite-preview` → the shared preview card (**Join group**) → `room-invite-ask` with the picked Bots, one sentence per refusal (#876); Bot settings Sharing (Copy invite link) / Share with a friend / People with access (inside the host's titled **Sharing** card, so `BotSocialDetails` draws no title of its own, #406), or Auto-send + Remove this Bot on a friend's Bot. | ## Entry points diff --git a/plugins/social/client.js b/plugins/social/client.js index 37cf5a510..c80e658d8 100644 --- a/plugins/social/client.js +++ b/plugins/social/client.js @@ -2753,20 +2753,28 @@ window.__ModuleLoader__.load({ // The click is the person acting, so this is where the previous line goes (#3071). setError('') const sent = [] - const failed = [] + // One entry per person, in the order the batch reached them, each reason named once: the same + // person failing twice is one entry, and two people are two entries separated by a dot, so a + // name never reads as the tail of the reason before it (#3093 follow-up). + const failed = new Map() for (const item of mine.filter(waiting)) { const outcome = await decide(item, 'approve') if (outcome === true) sent.push(item) else if (outcome?.error) { const name = typeof item.toName === 'string' ? item.toName.trim() : '' - failed.push(name ? `${name}: ${outcome.error}` : outcome.error) + const reasons = failed.get(name) ?? [] + if (!reasons.includes(outcome.error)) reasons.push(outcome.error) + failed.set(name, reasons) } } const reached = recipientNames(sent) if (reached.length) actions?.notify?.(tr('Sent to {to}', { to: reached.join(tr(', ')) })) // #3071: written once, after the last send, so no send in the batch can clear it again; the // receipt above still names only the people reached. - if (failed.length) setError(failed.join(' ')) + if (failed.size) { + const entries = [...failed].map(([name, reasons]) => (name ? `${name}: ${reasons.join(', ')}` : reasons.join(', '))) + setError(entries.join(' · ')) + } } // #3011: the button says what it will send and to whom, so the blast radius of a click that // cannot be undone is readable before it. diff --git a/plugins/social/test/approve-all-failure.test.js b/plugins/social/test/approve-all-failure.test.js index 78221b9ec..75fe585fa 100644 --- a/plugins/social/test/approve-all-failure.test.js +++ b/plugins/social/test/approve-all-failure.test.js @@ -126,13 +126,13 @@ const localHold = (id, handle, name) => ({ }) const holds = () => [localHold('l1', '@eve.home', 'Eve'), localHold('l2', '@bob.home', 'Bob')] -function harness({ decide }) { +function harness({ decide, holdList = holds() }) { const state = { calls: [], notes: [], decide } globalThis.__flybot__ = { call: (endpoint, payload) => { state.calls.push([endpoint, payload]) if (endpoint === 'social/status') return Promise.resolve({ approvals: [] }) - if (endpoint === 'approvals') return Promise.resolve(holds()) + if (endpoint === 'approvals') return Promise.resolve(holdList) if (endpoint === 'decide') { const answer = state.decide(payload) return answer instanceof Error ? Promise.reject(answer) : Promise.resolve(answer) @@ -224,3 +224,43 @@ test('#3093: a local reject is a decision, not a failed send', async () => { assert.deepEqual(state.notes, [], 'a rejected card is not receipted as sent') } finally { delete globalThis.__flybot__ } }) + +// The batch's own line, read where the person reads it: one alert under the button (#3071 keeps it out +// of the cards, whose own reason is #3093's record). +function errorLine(tree) { + const node = find(tree, byFlybot('chat-approval-error')) + return node ? drawn(node) : undefined +} + +test('a batch that fails two holds for one person names that person once', async () => { + const app = loadDock() + // The same reason twice is one thing that happened, not two: a line that says it twice reads as a + // stutter, and the person cannot tell it from a second, different failure. + const state = harness({ + holdList: [localHold('l1', '@eve.home', 'Eve'), localHold('l2', '@eve.home', 'Eve')], + decide: () => new Error('the hold is stale'), + }) + try { + const first = await openChat(app, state) + await find(first.tree, byFlybot('approve-all')).props.onClick() + const after = render(app.ChatApprovalDock, first.inst, state.props) + assert.equal(errorLine(after), 'Eve: the hold is stale', `one entry per person and reason, saw ${JSON.stringify(errorLine(after))}`) + assert.equal(findAll(after, byFlybot('chat-approval')).length, 2, 'both cards are still there to read') + } finally { delete globalThis.__flybot__ } +}) + +test('a batch that fails two people separates their reasons and keeps each name', async () => { + const app = loadDock() + // Two different failures no longer run together as "Eve: the hold is stale Bob: …", where the second + // person's name looked like part of the first person's reason. + const state = harness({ + holdList: [localHold('l1', '@eve.home', 'Eve'), localHold('l2', '@bob.home', 'Bob')], + decide: payload => new Error(payload.id === 'l1' ? 'the hold is stale' : 'Bot Social is unreachable'), + }) + try { + const first = await openChat(app, state) + await find(first.tree, byFlybot('approve-all')).props.onClick() + const after = render(app.ChatApprovalDock, first.inst, state.props) + assert.equal(errorLine(after), 'Eve: the hold is stale · Bob: Bot Social is unreachable', `each failure is its own entry, saw ${JSON.stringify(errorLine(after))}`) + } finally { delete globalThis.__flybot__ } +})