diff --git a/changelog.d/3192.fixed.md b/changelog.d/3192.fixed.md new file mode 100644 index 000000000..d666808d1 --- /dev/null +++ b/changelog.d/3192.fixed.md @@ -0,0 +1 @@ +The approve-all failure row is now drawn in the dock's own error tone instead of plain body text, so a batch whose sends failed stands out under the button the way every other status line in Bot Social does ([#3192](https://github.com/ThinkFlowLab/FlyBot/issues/3192)). diff --git a/docs/subsystems/social.md b/docs/subsystems/social.md index 30ac01eb5..552db1ab7 100644 --- a/docs/subsystems/social.md +++ b/docs/subsystems/social.md @@ -14,7 +14,7 @@ Bot Social plugin for chatting with friends' Bots (send middleware `social` with A saved server choice that exists but cannot be read or parsed refuses instead of reading as "nothing saved yet" (#2717), and that refusal is answered on the plugin's own endpoints — the three `social/server*` endpoints and the UI endpoint list — and written once to the diagnostics log, so a damaged `flybot-social-server.json` shows its path and reason on the settings page and in Settings → Feedback instead of making Bot Social look uninstalled (#2945). -The chat dock's own memory lives outside the component: `conversation.input.dock` is session-scoped, so opening another chat unmounts the dock and coming back mounts a new one. What a failed send says, and which Retry already went out, are kept in a module-level record keyed `:` — the Map + listener shape `core/src/client/approval-claims.js` uses — and the dock only subscribes; otherwise the way back drew a failed card as a fresh wait and offered a Retry that had already gone out. Every card kind draws its reason from that record, a local hold included: the host describes a send that failed, but not a decision it refused, and the batch's one line is cleared by the next click and lost with the chat (#3093). A failure record goes when its id leaves the two lists the dock reads; a spent Retry is kept instead — at most 50 spent records, earliest-inserted dropped first — because the send did go out and the poll that still writes the hold back as failed would otherwise offer it again (#3082). That one line is bounded: it names at most three people and then counts the rest in the window's words, and a reason the host passes through whole is cut at 200 code points with a marked ellipsis, so one batch cannot fill the alert. +The chat dock's own memory lives outside the component: `conversation.input.dock` is session-scoped, so opening another chat unmounts the dock and coming back mounts a new one. What a failed send says, and which Retry already went out, are kept in a module-level record keyed `:` — the Map + listener shape `core/src/client/approval-claims.js` uses — and the dock only subscribes; otherwise the way back drew a failed card as a fresh wait and offered a Retry that had already gone out. Every card kind draws its reason from that record, a local hold included: the host describes a send that failed, but not a decision it refused, and the batch's one line is cleared by the next click and lost with the chat (#3093). A failure record goes when its id leaves the two lists the dock reads; a spent Retry is kept instead — at most 50 spent records, earliest-inserted dropped first — because the send did go out and the poll that still writes the hold back as failed would otherwise offer it again (#3082). That one line is bounded: it names at most three people and then counts the rest in the window's words, and a reason the host passes through whole is cut at 200 code points with a marked ellipsis, so one batch cannot fill the alert. The row is drawn as the plugin's own status line in its error tone (`fs-status` with `data-tone=error`), so a failed batch does not read as ordinary dock text (#3192). A second, read-only window starts the social layer from the credentials file the writable window owns, so friends and messages stay visible, but it never onboards a home and never writes that file: the plugin start is a lifecycle path (`apply` → `ready` → `launch`), not an API endpoint, so the core's read-only guard cannot stop it and `startSocial` reads `config.readOnly` itself (#2675). diff --git a/plugins/social/client.js b/plugins/social/client.js index d089f00d1..5f10cfdde 100644 --- a/plugins/social/client.js +++ b/plugins/social/client.js @@ -2849,7 +2849,7 @@ window.__ModuleLoader__.load({ ? h('div', { className: 'fs-chat-actions' }, h('button', { type: 'button', className: 'fs-btn fs-btn-sm', 'data-flybot': 'approve-all', disabled: !!busy, onClick: approveAll, title: approveAllTitle }, approveAllLabel)) : null, - error ? h('div', { className: 'fs-chat-error', role: 'alert', 'data-flybot': 'chat-approval-error' }, error) : null, + error ? h('div', { className: 'fs-status', 'data-tone': 'error', role: 'alert', 'data-flybot': 'chat-approval-error' }, error) : null, mine.map(item => h(ChatApproval, { // #3044: a decision in flight locks every card, not only its own. // #3071: a click on one card clears the previous line here, where the person acted. diff --git a/plugins/social/test/approve-all-failure.test.js b/plugins/social/test/approve-all-failure.test.js index 1437237cb..bfc2abab7 100644 --- a/plugins/social/test/approve-all-failure.test.js +++ b/plugins/social/test/approve-all-failure.test.js @@ -321,3 +321,29 @@ test('a reason longer than a paragraph is cut inside the line', async () => { assert.ok(!/\p{Surrogate}/u.test(line), 'no lone surrogate survives the cut') } finally { delete globalThis.__flybot__ } }) + +// #3192: the row was a bare `div` carrying a class no stylesheet ever wrote — so a role="alert" +// sentence about a failed batch read exactly like ordinary dock text, in no error colour and none of +// the plugin's own line height. It is drawn as the plugin's status line in its error tone instead; +// the alert role and the data-flybot hook stay, and #3158's cap and cut are untouched. +test('#3192: the failure row is drawn in the dock\'s own error tone, not as bare text', async () => { + const source = readFileSync(new URL('../client.js', import.meta.url), 'utf8') + const css = /const CSS = `([\s\S]*?)`\n/.exec(source)?.[1] ?? '' + assert.ok(css.includes('.fs-status{padding:0;font-size:12px;line-height:17px;'), + 'the shared status line still carries the type the row leans on') + assert.ok(css.includes('.fs-status[data-tone=error]{color:#e5484d}'), + 'and the plugin\'s own error colour is the tone this row takes') + + const app = loadDock() + const state = harness({ decide: () => new Error('the hold is stale') }) + try { + const first = await openChat(app, state) + await find(first.tree, byFlybot('approve-all')).props.onClick() + const row = find(render(app.ChatApprovalDock, first.inst, state.props), byFlybot('chat-approval-error')) + assert.ok(row, 'the batch draws its one failure row') + assert.equal(row.props.role, 'alert', 'the row still announces itself to the reader') + assert.match(String(row.props.className), /\bfs-status\b/, `the row takes the status line, saw ${JSON.stringify(row.props.className)}`) + assert.equal(row.props['data-tone'], 'error', 'in the error tone, so it does not read as ordinary dock text') + assert.match(drawn(row), /the hold is stale/, 'and still says what failed') + } finally { delete globalThis.__flybot__ } +})