Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3192.fixed.md
Original file line number Diff line number Diff line change
@@ -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)).
2 changes: 1 addition & 1 deletion docs/subsystems/social.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<approval id>:<session id>` — 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 `<approval id>:<session id>` — 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).

Expand Down
2 changes: 1 addition & 1 deletion plugins/social/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@
function qrRsGenerator(degree) {
let poly = [1]
for (let i = 0; i < degree; i += 1) {
const next = new Array(poly.length + 1).fill(0)

Check warning on line 723 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-new-array)

Do not use `new Array(singleArgument)`.
for (let j = 0; j < poly.length; j += 1) {
next[j] ^= poly[j]
next[j + 1] ^= qrMul(poly[j], QR_GF_EXP[i])
Expand All @@ -731,7 +731,7 @@
}
function qrRsRemainder(bytes, degree) {
const gen = qrRsGenerator(degree)
const res = new Array(bytes.length + degree).fill(0)

Check warning on line 734 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-new-array)

Do not use `new Array(singleArgument)`.
for (let i = 0; i < bytes.length; i += 1) res[i] = bytes[i]
for (let i = 0; i < bytes.length; i += 1) {
const factor = res[i]
Expand Down Expand Up @@ -805,8 +805,8 @@
}
function qrSkeleton(version) {
const size = version * 4 + 17
const modules = Array.from({ length: size }, () => new Array(size).fill(0))

Check warning on line 808 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-new-array)

Do not use `new Array(singleArgument)`.
const fixed = Array.from({ length: size }, () => new Array(size).fill(false))

Check warning on line 809 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-new-array)

Do not use `new Array(singleArgument)`.
const set = (x, y, dark) => { modules[y][x] = dark ? 1 : 0; fixed[y][x] = true }
const finder = (cx, cy) => {
for (let dy = -4; dy <= 4; dy += 1) {
Expand Down Expand Up @@ -1070,7 +1070,7 @@
return out
}
const cleanRoomName = (value, fallback = '') => stripUntrustedMarkers(value)
.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, ' ')

Check warning on line 1073 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

eslint(no-control-regex)

Unexpected control characters
.replace(/[[\]"<>`@]/g, '')
.replace(/\s+/g, ' ')
.trim()
Expand Down Expand Up @@ -1114,7 +1114,7 @@
let matrix
try { matrix = qrMatrix(text) } catch { return null }
const size = matrix.size
return h('div', { className: 'fs-qr', 'data-flybot': kind, 'data-modules': size, ...(attrs ?? {}) },

Check warning on line 1117 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-useless-fallback-in-spread)

Empty fallbacks in spreads are unnecessary
h('svg', {
className: 'fs-qr-svg', width: size, height: size, viewBox: `0 0 ${size} ${size}`,
role: 'img', 'aria-label': label, shapeRendering: 'crispEdges',
Expand Down Expand Up @@ -1420,7 +1420,7 @@
const next = id || null
if (next === this.roomId) return
this.roomId = next
for (const fn of [...this.listeners]) fn()

Check warning on line 1423 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-useless-spread)

Using a spread operator here creates a new array unnecessarily.
},
subscribe(fn) {
this.listeners.add(fn)
Expand Down Expand Up @@ -2486,7 +2486,7 @@
const dockRecords = new Map()
const dockRecordListeners = new Set()
const dockRecordKey = (sessionId, id) => `${id}:${sessionId}`
const dockRecordChanged = () => { for (const fn of [...dockRecordListeners]) fn() }

Check warning on line 2489 in plugins/social/client.js

View workflow job for this annotation

GitHub Actions / plugins (social)

unicorn(no-useless-spread)

Using a spread operator here creates a new array unnecessarily.
const dockRecordOf = (sessionId, id) => dockRecords.get(dockRecordKey(sessionId, id))
const dockFailuresOf = (sessionId) => {
const out = {}
Expand Down Expand Up @@ -2849,7 +2849,7 @@
? 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.
Expand Down
26 changes: 26 additions & 0 deletions plugins/social/test/approve-all-failure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__ }
})
Loading