Skip to content

Commit 523a384

Browse files
authored
client: put the read-only Reload where the sentence is (#2510)
Fixes #2502 Owner: Dev-1 Reviewer: Birfy Written-by: FlyBot Dev-1 Claim-Id: 41446521c1724173bfcc99f75889b209 Risk tier: T1 Base: b38ec01 ## What changed In a read-only window the room tells the reader to reload to pick up new permissions, and the sidebar carries that Reload — but the Settings header, the details drawer, the Inbox and the Memory panel only print the read-only sentence. A reader looking at one of those four faces has to close and reopen the window. After: one helper, `core/src/client/read-only.js`, renders the sentence and its Reload at every place the sentence appears: - `settings.js` header, on all 12 settings pages - `details-drawer.js` — group overview, group settings, Bot overview, Bot settings - `inbox.js` - `memory-panel.js` `role="status"` wraps only the sentence and the button sits outside it, so a screen reader does not re-announce the whole line when the sentence changes. A click calls only `actions.reloadTeam()`; a rejection goes to `actions.reportError(error, 'reload')`. No write path is touched. A writable window draws neither the sentence nor the button. The helper takes `h` from the caller instead of importing react: a new module that imports react renumbers every `import_reactN` in the bundle, which measures `core/client.js` 2274/2248 for the same source instead of 39/14. The module header records that reason. Because the sentence and the button come from one place, this adds no further hand-written copy of the read-only reason. Hand-written files: `core/src/client/read-only.js` (new), `core/src/client/settings.js`, `core/src/client/details-drawer.js`, `core/src/client/inbox.js`, `core/src/client/memory-panel.js`, `core/src/client/styles.js`, `docs/subsystems/core-client.md`, `changelog.d/2502-readonly-reload.added.md`, `core/test/readonly-reload-lines.test.js` (new), `core/test/details-bot-settings-readonly.test.js`. `core/client.js` and `patches/ds-bot/*` are regenerated, never hand-edited: `node scripts/build-client.mjs`, then `node scripts/ds-bot-patches.mjs generate`. ## Verification at the tip Tip SHA: 0318eaa (tree 21657b4), parent b38ec01 (live main), rebuilt from local a8969814… — same tree, the push path re-commits. Ran: - failing test first, on a clean `b38ec011` tree with only `core/test/readonly-reload-lines.test.js` added: `# tests 7 / # pass 1 / # fail 6`. The six red are the Settings header page by page, the four drawer faces, Inbox, Memory, one shared sentence with the button outside `role="status"`, and a click that reaches only `reloadTeam` with the failure going to `reportError`. The one green is a writable or blank window drawing no control. - `TZ=UTC npm run verify` → exit 0: core **2924/2924**, social 577, tree 137, timeline 141, workflow 440, `.github` + policy 671, interop 37, live-e2e 26; oxlint and `arch-docs: OK (20 changed file(s))`, `build-client --check`, `ds-bot-patches check` and `canonical` all green. - `git diff --numstat b38ec01...HEAD`: `core/client.js` 39/14, `patches/ds-bot/0008-client-bundle.patch` 106/80; 20 files, +750/−124. - after replaying onto `b38ec011`: the rebase conflicted only in `patches/ds-bot/0008-client-bundle.patch` (one hunk; `core/client.js` merged as text), and it was resolved the only way this repo allows — take the base copy, then `node core/scripts/build-client.mjs` followed by `node scripts/ds-bot-patches.mjs generate` rewrote it from the new tree. `generate` a second time leaves `git status` empty, `build-client --check` exits 0 and `check`/`canonical` are green, so the committed bundle and patches are exactly what the generators produce from this source. Not run (and why): the two-Bot live smoke, which needs a running instance; the window behaviour here is covered by the component tests above. This is a draft, and later commits on the branch add their own measurements. ## Checkpoint <!-- flybot:checkpoint --> ```json {"pr":2510,"claim":"Dev-1","issue":2502,"summary":"In a read-only window the Settings header, the details drawer, the Inbox and the Memory panel printed the read-only sentence but offered no way to reload, so the reader had to close and reopen the window. One helper, core/src/client/read-only.js, now renders the sentence and its Reload at all six call sites and keeps the button outside role=\"status\". A click calls only actions.reloadTeam() and a rejection goes to actions.reportError(error, 'reload'); a writable window draws neither. core/client.js and the patches are regenerated from that source, not hand-edited.","files":["core/src/client/read-only.js","core/src/client/settings.js","core/src/client/details-drawer.js","core/src/client/inbox.js","core/src/client/memory-panel.js","core/src/client/styles.js","core/test/readonly-reload-lines.test.js","core/test/details-bot-settings-readonly.test.js","docs/subsystems/core-client.md","changelog.d/2502-readonly-reload.added.md","core/client.js","patches/ds-bot/0008-client-bundle.patch"],"checks":{"ran":"failing test first on clean b38ec01 (7 tests, 6 red); TZ=UTC ARCH_DOCS_BASE=b38ec011 npm run verify exit 0, core 2924/2924; build-client --check; ds-bot-patches check + canonical","result":"green","at":"0318eaac689ed16beb6dee23eec875b6c627e40e"},"next":"none — lead holds this draft until the core client lane reaches #2502; no review requested yet"} ``` <!-- /flybot:checkpoint -->
1 parent b38ec01 commit 523a384

20 files changed

Lines changed: 750 additions & 124 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Settings header, the details drawer, the Inbox and the Memory panel now draw a **Reload** beside the host's read-only sentence, so a window that was told to reload can do it where it stands instead of closing the panel and reaching for the sidebar ([#2502](https://github.com/ThinkFlowLab/FlyBot/issues/2502)).

‎core/client.js‎

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5238,6 +5238,13 @@ button.bt-q-opt:active{background:var(--bt-active)}
52385238
.bt-option-sub{font-size:11px;line-height:15px;color:var(--bt-ink-2);white-space:normal;overflow-wrap:anywhere}
52395239
.bt-option-icon{width:22px;height:22px;border-radius:50%;background:var(--bt-hover);color:var(--bt-ink-2);display:inline-flex;align-items:center;justify-content:center;flex:none}
52405240
.bt-hint{padding:14px;text-align:center;font-size:13px;color:var(--bt-ink-2)}
5241+
/* #2502: the host sentence and its Reload entry share one row; the sidebar's own rule sizes
5242+
the button, this only places it beside the sentence instead of under it. */
5243+
.bt-readonly-line{display:flex;align-items:center;gap:8px}
5244+
.bt-readonly-line>.bt-hint{flex:1 1 auto;min-width:0}
5245+
.bt-readonly-line>.bt-read-only-reload{flex:none;margin:0}
5246+
.bt-readonly-line-head{padding:0 20px 8px}
5247+
.bt-readonly-line-head>.bt-hint{padding:0;text-align:left}
52415248
.bt-nc-spacer{flex:1}
52425249
.bt-nc-compose{padding:0 16px 14px;display:flex;justify-content:center}
52435250
.bt-nc-card{display:flex;align-items:flex-end;gap:6px;width:100%;max-width:var(--dsh-chat-content-width,748px);min-height:44px;padding:4px 6px;border-radius:22px;border:1px solid var(--bt-line-2);background:var(--bt-main);box-shadow:0 2px 8px -2px rgba(0,0,0,.06);box-sizing:border-box}
@@ -6885,7 +6892,7 @@ function useInlineEntry(policy) {
68856892
}
68866893
function HeldReplyActions({ held, actions, roster }) {
68876894
const locked = lockedWindow(roster);
6888-
const readOnlyLine = () => (0, import_react10.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly));
6895+
const readOnlyLine2 = () => (0, import_react10.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly));
68896896
const custom = useInlineEntry(held?.by);
68906897
const [busy, setBusy] = (0, import_react10.useState)(false);
68916898
const [error, setError] = (0, import_react10.useState)("");
@@ -6915,7 +6922,7 @@ function HeldReplyActions({ held, actions, roster }) {
69156922
(0, import_react10.createElement)("span", null, held.status === "approved" ? t("Sent to {to}", { to: held.toName }) : held.status === "auto" ? t("Auto-sent to {to}", { to: held.toName }) : failed ? t("Not sent: delivery failed") : t("Not sent")),
69166923
// #968: the terminal answer comes from one predicate, not from `status === 'failed'` here and a
69176924
// different field elsewhere. A failure that can never succeed draws no button on any surface.
6918-
failed && canRetry(held) ? locked ? readOnlyLine() : (0, import_react10.createElement)("button", { type: "button", className: "bt-held-retry", disabled: busy, onClick: () => decide("retry") }, t("Retry")) : null,
6925+
failed && canRetry(held) ? locked ? readOnlyLine2() : (0, import_react10.createElement)("button", { type: "button", className: "bt-held-retry", disabled: busy, onClick: () => decide("retry") }, t("Retry")) : null,
69196926
error ? (0, import_react10.createElement)("span", { className: "bt-flybot-approval-error", role: "alert" }, error) : null
69206927
);
69216928
}
@@ -6928,7 +6935,7 @@ function HeldReplyActions({ held, actions, roster }) {
69286935
(0, import_react10.createElement)("div", { className: "bt-held-head" }, t("Waiting for your approval"), age),
69296936
(0, import_react10.createElement)("div", { className: "bt-flybot-approval-origin" }, t("{from} → {to}", { from: held.from ?? t("A Bot"), to: held.toName })),
69306937
reason ? (0, import_react10.createElement)("div", { className: "bt-flybot-approval-reason", title: reason.title }, reason.text) : null,
6931-
locked ? readOnlyLine() : (0, import_react10.createElement)(
6938+
locked ? readOnlyLine2() : (0, import_react10.createElement)(
69326939
"div",
69336940
{ className: "bt-flybot-approval-actions" },
69346941
(0, import_react10.createElement)("button", { type: "button", disabled: busy, onClick: () => decide("reject") }, t("Reject")),
@@ -8725,6 +8732,24 @@ function progressOf(task) {
87258732
return Math.max(0, Math.min(100, Math.round(value)));
87268733
}
87278734

8735+
// src/client/read-only.js
8736+
var readOnlySaid = (roster) => typeof roster?.readOnly === "string" && roster.readOnly.trim() !== "";
8737+
function readOnlyLine(h50, roster, actions, { key, className, style, reload = true } = {}) {
8738+
if (!readOnlySaid(roster)) return null;
8739+
return h50(
8740+
"div",
8741+
{ key, className: ["bt-readonly-line", className].filter(Boolean).join(" "), style },
8742+
h50("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)),
8743+
reload ? h50("button", {
8744+
type: "button",
8745+
className: "bt-read-only-reload",
8746+
onClick: () => {
8747+
void Promise.resolve(actions?.reloadTeam?.()).catch((error) => actions?.reportError?.(error, "reload"));
8748+
}
8749+
}, t("Reload")) : null
8750+
);
8751+
}
8752+
87288753
// src/client/inbox.js
87298754
var import_react15 = require("react");
87308755
var KEEP_MS = 7 * 864e5;
@@ -9359,7 +9384,7 @@ function InboxDialog({ roster, useWork, useSessions, actions, leaving = false })
93599384
(0, import_react15.createElement)(
93609385
"div",
93619386
{ className: "bt-mem-body bt-inbox-body" },
9362-
...locked ? [(0, import_react15.createElement)("p", { key: "readonly", className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly))] : [],
9387+
...locked ? [readOnlyLine(import_react15.createElement, roster, actions, { key: "readonly" })] : [],
93639388
(0, import_react15.createElement)("div", { className: "bt-inbox-feedback", role: "status", "aria-live": "polite" }, feedback),
93649389
GROUPS.map((group) => {
93659390
const settled = group.id === "done" ? model.doneAll ?? groups.done : null;
@@ -10719,7 +10744,7 @@ function TeamSidebar(props) {
1071910744
return entries2.sort((a, b) => Number(Boolean(b.item.pinned)) - Number(Boolean(a.item.pinned)) || Number(foreign(a)) - Number(foreign(b)) || b.at - a.at);
1072010745
}, [roster, updated]);
1072110746
const main = roster.byId[roster.mainBotId];
10722-
const readOnlySaid = typeof roster.readOnly === "string" && roster.readOnly.trim() !== "";
10747+
const readOnlySaid2 = typeof roster.readOnly === "string" && roster.readOnly.trim() !== "";
1072310748
const readOnlyReload = (0, import_react19.createElement)("button", {
1072410749
type: "button",
1072510750
className: "bt-read-only-reload",
@@ -10758,10 +10783,10 @@ function TeamSidebar(props) {
1075810783
(0, import_react19.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
1075910784
(0, import_react19.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react19.createElement)(PlusIcon))
1076010785
),
10761-
wide && readOnlySaid ? (0, import_react19.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
10762-
wide && readOnlySaid ? readOnlyReload : null,
10763-
!wide && readOnlySaid ? (0, import_react19.createElement)("div", { className: "bt-hint bt-read-only", role: "status", title: hostText(roster.readOnly), "aria-label": hostText(roster.readOnly) }, hostText(roster.readOnly)) : null,
10764-
!wide && readOnlySaid ? readOnlyReload : null,
10786+
wide && readOnlySaid2 ? (0, import_react19.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
10787+
wide && readOnlySaid2 ? readOnlyReload : null,
10788+
!wide && readOnlySaid2 ? (0, import_react19.createElement)("div", { className: "bt-hint bt-read-only", role: "status", title: hostText(roster.readOnly), "aria-label": hostText(roster.readOnly) }, hostText(roster.readOnly)) : null,
10789+
!wide && readOnlySaid2 ? readOnlyReload : null,
1076510790
(0, import_react19.createElement)(InboxRow, { wide, useRoster, useWork: props.useWork, useUi, actions }),
1076610791
(0, import_react19.createElement)(KanbanRow, { wide, useUi, actions }),
1076710792
(0, import_react19.createElement)(ProjectsNav, { wide }),
@@ -14604,7 +14629,7 @@ function MemoryDialog({ bot, actions, roster, leaving = false }) {
1460414629
(0, import_react28.createElement)(
1460514630
"div",
1460614631
{ className: "bt-mem-body" },
14607-
locked ? (0, import_react28.createElement)("p", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
14632+
readOnlyLine(import_react28.createElement, roster, actions),
1460814633
error ? (0, import_react28.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, hostText(error)) : null,
1460914634
view === null ? error ? null : (0, import_react28.createElement)(Skeleton) : page === "entries" ? (0, import_react28.createElement)(Entries, { bot, view, remove: locked ? null : remove }) : (0, import_react28.createElement)(Summary, { bot, view, regenerate })
1461014635
),
@@ -19566,7 +19591,7 @@ function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = false
1956619591
// A window that holds the team read-only still opens every page here, so the header says
1956719592
// why nothing can be changed, in the host's own sentence and above the refusal below it:
1956819593
// the standing state first, the answer to one pressed control closest to that control.
19569-
typeof roster?.readOnly === "string" && roster.readOnly.trim() ? (0, import_react42.createElement)("div", { className: "bt-hint bt-read-only", role: "status", style: { padding: "0 20px 8px", textAlign: "left" } }, hostText(roster.readOnly)) : null,
19594+
readOnlyLine(import_react42.createElement, roster, actions, { key: "readonly", className: "bt-readonly-line-head" }),
1957019595
shown === "usage" ? null : errorLine,
1957119596
shown === "usage" ? null : (0, import_react42.createElement)(
1957219597
"div",
@@ -20199,7 +20224,7 @@ function GroupOverview({ room: room2, roster, actions, usage, useWork, openSetti
2019920224
// P-544: the group overview's writes are gone in a locked window, so it says why once, above
2020020225
// the reads it still draws. The approval card used to carry its own copy (#2381); one page,
2020120226
// one sentence.
20202-
locked ? (0, import_react44.createElement)("div", { key: "read-only", className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
20227+
readOnlyLine(import_react44.createElement, roster, actions, { key: "read-only" }),
2020320228
(0, import_react44.createElement)(FlyBotRoomOverview, { key: "plugin-overview", room: room2, roster, actions }),
2020420229
invited && room2.sharedFrom && !face ? (0, import_react44.createElement)(
2020520230
"div",
@@ -20340,7 +20365,7 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
2034020365
{ key: "set-body", className: "bt-drawer-body bt-set-body", "data-move": move },
2034120366
// #2387: the lock is the window's, not the Bot's — a read-only window draws the host's sentence
2034220367
// in place of a group's form too, exactly as it already did for a Bot's.
20343-
lockedWindow(roster) ? (0, import_react44.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : bot ? (0, import_react44.createElement)(BotSettingsForm, { bot, roster, actions, run }) : (0, import_react44.createElement)(GroupSettingsForm, { room: room2, roster, actions, run, onDeleted: close })
20368+
lockedWindow(roster) ? readOnlyLine(import_react44.createElement, roster, actions) : bot ? (0, import_react44.createElement)(BotSettingsForm, { bot, roster, actions, run }) : (0, import_react44.createElement)(GroupSettingsForm, { room: room2, roster, actions, run, onDeleted: close })
2034420369
)
2034520370
];
2034620371
}
@@ -20434,7 +20459,7 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
2043420459
// locked window refuses every one of them. Say so once at the top and draw the read half only,
2043520460
// which is the values themselves (P-547) — the name above is already text, and the settings
2043620461
// gear still opens the page that explains the window.
20437-
lockedWindow(roster) ? (0, import_react44.createElement)("div", { key: "read-only", className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
20462+
lockedWindow(roster) ? readOnlyLine(import_react44.createElement, roster, actions, { key: "read-only" }) : null,
2043820463
lockedWindow(roster) ? (0, import_react44.createElement)(ReadOnlyOverview, { key: "read", bot, roster }) : null,
2043920464
lockedWindow(roster) ? null : (0, import_react44.createElement)(
2044020465
"div",

‎core/src/client/details-drawer.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import { MemoryRow } from './memory-panel.js'
1313
import { RoomSchedules, ScheduleSummary, lockedWindow } from './schedules.js'
1414
import { Segmented, useGlide, useMorph } from './motion.js'
1515
import { MemberWork, useMemberWork } from './member-status.js'
16-
import { hostText, t } from './i18n.js'
16+
import { t } from './i18n.js'
1717
import { remoteBotTitle, roomTitle, copiedToClipboard } from '../shared/remote-label.js'
1818
import { FlyBotRoomOverview, FlyBotDetails } from './flybot-slots.js'
1919
import { call } from './api.js'
20+
import { readOnlyLine } from './read-only.js'
2021

2122
const TAB_LABELS = { details: 'Details', browser: 'Browser' }
2223

@@ -221,7 +222,7 @@ function GroupOverview({ room, roster, actions, usage, useWork, openSettings })
221222
// P-544: the group overview's writes are gone in a locked window, so it says why once, above
222223
// the reads it still draws. The approval card used to carry its own copy (#2381); one page,
223224
// one sentence.
224-
locked ? h('div', { key: 'read-only', className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,
225+
readOnlyLine(h, roster, actions, { key: 'read-only' }),
225226
h(FlyBotRoomOverview, { key: 'plugin-overview', room, roster, actions }),
226227
invited && room.sharedFrom && !face
227228
? h('div', { key: 'from', className: 'bt-shared-from' },
@@ -330,7 +331,7 @@ export function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, ro
330331
// #2387: the lock is the window's, not the Bot's — a read-only window draws the host's sentence
331332
// in place of a group's form too, exactly as it already did for a Bot's.
332333
lockedWindow(roster)
333-
? h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly))
334+
? readOnlyLine(h, roster, actions)
334335
: bot ? h(BotSettingsForm, { bot, roster, actions, run }) : h(GroupSettingsForm, { room, roster, actions, run, onDeleted: close })),
335336
]
336337
}
@@ -411,7 +412,7 @@ export function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, ro
411412
// locked window refuses every one of them. Say so once at the top and draw the read half only,
412413
// which is the values themselves (P-547) — the name above is already text, and the settings
413414
// gear still opens the page that explains the window.
414-
lockedWindow(roster) ? h('div', { key: 'read-only', className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,
415+
lockedWindow(roster) ? readOnlyLine(h, roster, actions, { key: 'read-only' }) : null,
415416
lockedWindow(roster) ? h(ReadOnlyOverview, { key: 'read', bot, roster }) : null,
416417
lockedWindow(roster) ? null : h('div', { key: 'model', className: 'bt-drawer-model' },
417418
h('div', { className: 'bt-section-title' }, t('Model')),

‎core/src/client/inbox.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { hostText, t } from './i18n.js'
1919
import { failureSentence } from '../shared/failure-copy.js'
2020
import { columnOf } from '../shared/task-board.js'
2121
import { lockedWindow } from './schedules.js'
22+
import { readOnlyLine } from './read-only.js'
2223

2324
// Done (and a failed task) ages out after 7 days.
2425
export const KEEP_MS = 7 * 86_400_000
@@ -661,7 +662,7 @@ export function InboxDialog({ roster, useWork, useSessions, actions, leaving = f
661662
h('div', { className: 'bt-mem-body bt-inbox-body' },
662663
// #2284: one sentence at the top of the dialog, in the host's own words, so a window that
663664
// draws no write says why instead of leaving the reads silent about it.
664-
...(locked ? [h('p', { key: 'readonly', className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly))] : []),
665+
...(locked ? [readOnlyLine(h, roster, actions, { key: 'readonly' })] : []),
665666
h('div', { className: 'bt-inbox-feedback', role: 'status', 'aria-live': 'polite' }, feedback),
666667
GROUPS.map(group => {
667668
// #2050: the model keeps every finished row, so the group can draw the page's remainder

‎core/src/client/memory-panel.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { dateLocale, hostText, t } from './i18n.js'
88
import { memoryBlockedNotice, memoryEmptyNotice } from './memory-empty.js'
99
import { summaryBlocks } from './text.js'
1010
import { useLinger } from './motion.js'
11+
import { readOnlyLine } from './read-only.js'
1112

1213
const POLL_MS = 1500
1314
const MENU_EXIT_MS = 120
@@ -321,7 +322,7 @@ export function MemoryDialog({ bot, actions, roster, leaving = false }) {
321322
h('button', { type: 'button', role: 'menuitem', disabled: count === 0 || view?.summarizing, onClick: regenerate },
322323
h('span', { className: 'bt-menu-label' }, t('Regenerate summary')))) : null),
323324
h('div', { className: 'bt-mem-body' },
324-
locked ? h('p', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,
325+
readOnlyLine(h, roster, actions),
325326
error ? h('div', { className: 'bt-error', role: 'alert', style: { padding: 0 } }, hostText(error)) : null,
326327
view === null ? (error ? null : h(Skeleton))
327328
: page === 'entries' ? h(Entries, { bot, view, remove: locked ? null : remove })

‎core/src/client/read-only.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// #2502: the host's sentence tells the reader to close the other window and reload. The sidebar
2+
// (#2247) and the refusal toast (#2265) grew that entry; the Settings header, the drawer, the
3+
// Inbox and the Memory panel kept the sentence with nothing to answer it, and inside the Inbox
4+
// modal the sidebar's own button cannot be reached at all. This is the shared piece those
5+
// surfaces draw: the host's own words under `role="status"`, and one Reload outside that node (a
6+
// live region must stay text), running the same `actions.reloadTeam` read the sidebar runs — never
7+
// a page reload, which would drop the composer.
8+
import { hostText, t } from './i18n.js'
9+
10+
// A sentence of nothing but whitespace says nothing, so it draws nothing. Read the way the
11+
// sidebar reads it (#2247), so the two surfaces cannot disagree about which window is locked.
12+
export const readOnlySaid = roster => typeof roster?.readOnly === 'string' && roster.readOnly.trim() !== ''
13+
14+
// `reload: false` keeps the sentence and drops the control, for a view that already carries one:
15+
// one Reload per screen, on the topmost sentence. The caller passes `h` rather than this module
16+
// importing react: one more react import would renumber every module's binding in the generated
17+
// `client.js`, turning a five-line change into a two-thousand-line diff of the bundle.
18+
export function readOnlyLine(h, roster, actions, { key, className, style, reload = true } = {}) {
19+
if (!readOnlySaid(roster)) return null
20+
return h('div', { key, className: ['bt-readonly-line', className].filter(Boolean).join(' '), style },
21+
h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)),
22+
reload
23+
? h('button', {
24+
type: 'button',
25+
className: 'bt-read-only-reload',
26+
onClick: () => { void Promise.resolve(actions?.reloadTeam?.()).catch(error => actions?.reportError?.(error, 'reload')) },
27+
}, t('Reload'))
28+
: null)
29+
}

0 commit comments

Comments
 (0)