Skip to content

Commit aa1f51c

Browse files
committed
client: show a plugin that is not installed as not installed, and surface chief.error (replay of #2894)
Mechanical replay of #2894 onto main: the fork tip cannot be updated (422 merge conflict after #2890 regenerated core/client.js and patches/ds-bot/0008-client-bundle.patch), so the same change set is rebuilt here on a branch this repository owns. #2890's read-only Project board copy is kept; both generated files come from the generator, not from a hand merge. Fixes #2869 Owner: Dev Reviewer: Reviewer Written-by: Dev Replayed-by: Replay ff53 Docs: docs/subsystems/core-client.md updated with the #2869 behaviour.
1 parent f9ce2a4 commit aa1f51c

10 files changed

Lines changed: 7127 additions & 6231 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Settings → Plugins now draws a plugin this profile never installed as a plain "Not installed in this profile." row with the command that installs it, instead of an ON switch for a domain the running process does not have; a Project whose Chief failed now shows the host's error under its row instead of looking empty. See [#2869](https://github.com/ThinkFlowLab/FlyBot/issues/2869).

‎core/client.js‎

Lines changed: 74 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var ZH = {
5454
"Reading workflows…": "正在读取工作流…",
5555
"Could not read workflows": "读不到工作流。",
5656
"The Workflow plugin is not installed or not enabled. A default install includes @flybot/workflow.": "工作流插件没有安装,或没有启用。默认安装包含 @flybot/workflow。",
57+
"Not installed in this profile.": "当前 profile 未安装。",
5758
"Could not copy this workflow": "这个工作流复制不了。",
5859
"Could not save this workflow": "这个工作流保存不了。",
5960
"Could not rename this workflow": "这个工作流改不了名。",
@@ -1472,6 +1473,7 @@ var ZH = {
14721473
"Member unbound.": "已解除成员的绑定。",
14731474
"Project Assistant": "项目助手",
14741475
"Project Chief": "项目 Chief",
1476+
"Project Chief: {error}": "项目 Chief:{error}",
14751477
"Chief of this Project": "本项目的 Chief",
14761478
"Pause the daily digest": "暂停每日摘要",
14771479
"Assistant settings saved.": "助手设置已保存。",
@@ -19419,6 +19421,43 @@ var NOTIFY_KINDS = [
1941919421
["finished", "Finished"],
1942019422
["failed", "Failed"]
1942119423
];
19424+
function PluginsView({ answer = null, error = "", onFlip }) {
19425+
const plugins = answer?.plugins ?? [];
19426+
return (0, import_react43.createElement)(
19427+
"div",
19428+
null,
19429+
(0, import_react43.createElement)(
19430+
SetSection,
19431+
{ title: t("Plugins") },
19432+
error ? (0, import_react43.createElement)("p", { className: "bt-set-hint", role: "alert" }, error) : null,
19433+
answer === null && !error ? (0, import_react43.createElement)("p", { className: "bt-set-hint" }, t("Loading…")) : null,
19434+
plugins.map((plugin) => plugin.installed === false ? (0, import_react43.createElement)(
19435+
"div",
19436+
{ key: plugin.id, className: "bt-set-row bt-set-missing", "data-plugin": plugin.id, "data-installed": "false" },
19437+
(0, import_react43.createElement)(
19438+
"div",
19439+
{ className: "bt-set-copy" },
19440+
(0, import_react43.createElement)("span", null, plugin.name),
19441+
(0, import_react43.createElement)("span", { className: "bt-set-hint" }, `${plugin.package} — ${t(plugin.purpose)}`),
19442+
(0, import_react43.createElement)(
19443+
"span",
19444+
{ className: "bt-set-hint", role: "status" },
19445+
t("Not installed in this profile."),
19446+
" ",
19447+
(0, import_react43.createElement)("code", { className: "bt-install-command" }, `dsh plugin add ${plugin.package}`)
19448+
)
19449+
)
19450+
) : (0, import_react43.createElement)(SwitchRow, {
19451+
key: plugin.id,
19452+
label: plugin.name,
19453+
hint: `${plugin.package} — ${t(plugin.purpose)}`,
19454+
on: plugin.enabled !== false,
19455+
onChange: (enabled) => onFlip?.(plugin.id, enabled)
19456+
})),
19457+
(0, import_react43.createElement)("p", { className: "bt-set-hint" }, answer?.pendingRestart === true ? t("Restart FlyBot to apply the switches you changed.") : t("A switch takes effect the next time FlyBot starts."))
19458+
)
19459+
);
19460+
}
1942219461
function PluginsPage({ call: call4 }) {
1942319462
const [answer, setAnswer] = (0, import_react43.useState)(null);
1942419463
const [error, setError] = (0, import_react43.useState)("");
@@ -19440,25 +19479,7 @@ function PluginsPage({ call: call4 }) {
1944019479
setError("");
1944119480
}).catch((failure) => setError(failure?.message ?? String(failure)));
1944219481
};
19443-
const plugins = answer?.plugins ?? [];
19444-
return (0, import_react43.createElement)(
19445-
"div",
19446-
null,
19447-
(0, import_react43.createElement)(
19448-
SetSection,
19449-
{ title: t("Plugins") },
19450-
error ? (0, import_react43.createElement)("p", { className: "bt-set-hint", role: "alert" }, error) : null,
19451-
answer === null && !error ? (0, import_react43.createElement)("p", { className: "bt-set-hint" }, t("Loading…")) : null,
19452-
plugins.map((plugin) => (0, import_react43.createElement)(SwitchRow, {
19453-
key: plugin.id,
19454-
label: plugin.name,
19455-
hint: `${plugin.package} — ${t(plugin.purpose)}`,
19456-
on: plugin.enabled !== false,
19457-
onChange: (enabled) => flip(plugin.id, enabled)
19458-
})),
19459-
(0, import_react43.createElement)("p", { className: "bt-set-hint" }, answer?.pendingRestart === true ? t("Restart FlyBot to apply the switches you changed.") : t("A switch takes effect the next time FlyBot starts."))
19460-
)
19461-
);
19482+
return (0, import_react43.createElement)(PluginsView, { answer, error, onFlip: flip });
1946219483
}
1946319484
function GeneralPage({ roster, actions, run }) {
1946419485
const prefs = roster.prefs ?? {};
@@ -19817,36 +19838,41 @@ function ProjectsList({ projects, roster, call: call4, reload }) {
1981719838
(0, import_react43.createElement)(
1981819839
SetSection,
1981919840
{ key: "projects", title: t("Projects · {count}", { count: projects.length }) },
19820-
projects.length === 0 ? (0, import_react43.createElement)("div", { className: "bt-set-row" }, (0, import_react43.createElement)("div", { className: "bt-set-copy" }, (0, import_react43.createElement)("span", null, t(locked ? "No Project yet." : "No Project yet — create one.")))) : projects.map((project) => (0, import_react43.createElement)(
19821-
SetRow,
19822-
{
19823-
key: project.id,
19824-
label: project.name,
19825-
hint: project.workDir === null || project.workDir === void 0 ? void 0 : project.workDir
19826-
},
19827-
(0, import_react43.createElement)(
19828-
"div",
19829-
{ className: "bt-project-row-controls" },
19830-
(0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => openProjectBoard(project.id) }, t("Open board")),
19831-
locked ? null : (0, import_react43.createElement)(
19832-
"select",
19833-
{
19834-
className: "bt-select",
19835-
"aria-label": t("Bind to {name}", { name: project.name }),
19836-
value: "",
19837-
onChange: (event) => {
19838-
void bind(event.target.value, project);
19839-
}
19840-
},
19841-
(0, import_react43.createElement)("option", { value: "" }, t("Bind a Bot or group")),
19842-
members.map((member) => (0, import_react43.createElement)(
19843-
"option",
19844-
{ key: `${member.kind}:${member.id}`, value: `${member.kind}:${member.id}` },
19845-
`${member.kind === "group" ? t("Group") : t("Bot")} · ${member.name}`
19846-
))
19841+
projects.length === 0 ? (0, import_react43.createElement)("div", { className: "bt-set-row" }, (0, import_react43.createElement)("div", { className: "bt-set-copy" }, (0, import_react43.createElement)("span", null, t(locked ? "No Project yet." : "No Project yet — create one.")))) : projects.flatMap((project) => {
19842+
const chiefError = typeof project.chief?.error === "string" ? project.chief.error.trim() : "";
19843+
const row = (0, import_react43.createElement)(
19844+
SetRow,
19845+
{
19846+
key: project.id,
19847+
label: project.name,
19848+
hint: project.workDir === null || project.workDir === void 0 ? void 0 : project.workDir
19849+
},
19850+
(0, import_react43.createElement)(
19851+
"div",
19852+
{ className: "bt-project-row-controls" },
19853+
(0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => openProjectBoard(project.id) }, t("Open board")),
19854+
locked ? null : (0, import_react43.createElement)(
19855+
"select",
19856+
{
19857+
className: "bt-select",
19858+
"aria-label": t("Bind to {name}", { name: project.name }),
19859+
value: "",
19860+
onChange: (event) => {
19861+
void bind(event.target.value, project);
19862+
}
19863+
},
19864+
(0, import_react43.createElement)("option", { value: "" }, t("Bind a Bot or group")),
19865+
members.map((member) => (0, import_react43.createElement)(
19866+
"option",
19867+
{ key: `${member.kind}:${member.id}`, value: `${member.kind}:${member.id}` },
19868+
`${member.kind === "group" ? t("Group") : t("Bot")} · ${member.name}`
19869+
))
19870+
)
1984719871
)
19848-
)
19849-
))
19872+
);
19873+
if (chiefError === "") return [row];
19874+
return [row, (0, import_react43.createElement)("div", { key: `${project.id}:chief`, className: "bt-project-chief-error", role: "alert" }, t("Project Chief: {error}", { error: chiefError }))];
19875+
})
1985019876
),
1985119877
bound2.length === 0 ? null : (0, import_react43.createElement)(
1985219878
SetSection,

‎core/src/client/i18n.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const ZH = {
1919
'Could not read workflows': '读不到工作流。',
2020
'The Workflow plugin is not installed or not enabled. A default install includes @flybot/workflow.':
2121
'工作流插件没有安装,或没有启用。默认安装包含 @flybot/workflow。',
22+
'Not installed in this profile.': '当前 profile 未安装。',
2223
'Could not copy this workflow': '这个工作流复制不了。',
2324
'Could not save this workflow': '这个工作流保存不了。',
2425
'Could not rename this workflow': '这个工作流改不了名。',
@@ -1426,6 +1427,7 @@ const ZH = {
14261427
'Member unbound.': '已解除成员的绑定。',
14271428
'Project Assistant': '项目助手',
14281429
'Project Chief': '项目 Chief',
1430+
'Project Chief: {error}': '项目 Chief:{error}',
14291431
'Chief of this Project': '本项目的 Chief',
14301432
'Pause the daily digest': '暂停每日摘要',
14311433
'Assistant settings saved.': '助手设置已保存。',

‎core/src/client/settings.js‎

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ const NOTIFY_KINDS = [
5050
// Settings → Plugins (#2564): the four feature plugins, each with one switch. The
5151
// switch writes FlyBot's state.json; the packages stay installed and the next start
5252
// reads the answer, so nothing unloads from the session that flipped it.
53+
// A plugin this profile does not have is not drawn as a switch (#2869): flipping one would
54+
// claim a domain the process does not have. The row says so and names the command that
55+
// installs the package, the way the Workflows page names its own (#1381). Project surfaces
56+
// themselves are gated by #2877, so this page is the one place that still tells the owner
57+
// the package is missing.
58+
export function PluginsView({ answer = null, error = '', onFlip }) {
59+
const plugins = answer?.plugins ?? []
60+
return h('div', null,
61+
h(SetSection, { title: t('Plugins') },
62+
error ? h('p', { className: 'bt-set-hint', role: 'alert' }, error) : null,
63+
answer === null && !error ? h('p', { className: 'bt-set-hint' }, t('Loading…')) : null,
64+
plugins.map(plugin => plugin.installed === false
65+
? h('div', { key: plugin.id, className: 'bt-set-row bt-set-missing', 'data-plugin': plugin.id, 'data-installed': 'false' },
66+
h('div', { className: 'bt-set-copy' },
67+
h('span', null, plugin.name),
68+
h('span', { className: 'bt-set-hint' }, `${plugin.package} — ${t(plugin.purpose)}`),
69+
h('span', { className: 'bt-set-hint', role: 'status' }, t('Not installed in this profile.'), ' ',
70+
h('code', { className: 'bt-install-command' }, `dsh plugin add ${plugin.package}`))))
71+
: h(SwitchRow, {
72+
key: plugin.id,
73+
label: plugin.name,
74+
hint: `${plugin.package} — ${t(plugin.purpose)}`,
75+
on: plugin.enabled !== false,
76+
onChange: enabled => onFlip?.(plugin.id, enabled),
77+
})),
78+
h('p', { className: 'bt-set-hint' }, answer?.pendingRestart === true
79+
? t('Restart FlyBot to apply the switches you changed.')
80+
: t('A switch takes effect the next time FlyBot starts.'))))
81+
}
82+
5383
function PluginsPage({ call }) {
5484
const [answer, setAnswer] = useState(null)
5585
const [error, setError] = useState('')
@@ -65,21 +95,7 @@ function PluginsPage({ call }) {
6595
.then(value => { setPluginAnswer(value ?? {}); setAnswer(value ?? null); setError('') })
6696
.catch(failure => setError(failure?.message ?? String(failure)))
6797
}
68-
const plugins = answer?.plugins ?? []
69-
return h('div', null,
70-
h(SetSection, { title: t('Plugins') },
71-
error ? h('p', { className: 'bt-set-hint', role: 'alert' }, error) : null,
72-
answer === null && !error ? h('p', { className: 'bt-set-hint' }, t('Loading…')) : null,
73-
plugins.map(plugin => h(SwitchRow, {
74-
key: plugin.id,
75-
label: plugin.name,
76-
hint: `${plugin.package} — ${t(plugin.purpose)}`,
77-
on: plugin.enabled !== false,
78-
onChange: enabled => flip(plugin.id, enabled),
79-
})),
80-
h('p', { className: 'bt-set-hint' }, answer?.pendingRestart === true
81-
? t('Restart FlyBot to apply the switches you changed.')
82-
: t('A switch takes effect the next time FlyBot starts.'))))
98+
return h(PluginsView, { answer, error, onFlip: flip })
8399
}
84100

85101
// General is Appearance and Notifications; the switch to classic Agent mode is the account menu's (#393).
@@ -357,19 +373,26 @@ export function ProjectsList({ projects, roster, call, reload }) {
357373
// `project-create`, so it says only that there is none rather than pointing at the
358374
// control it just removed. The shared key stays for the board's own empty state (#2489).
359375
? h('div', { className: 'bt-set-row' }, h('div', { className: 'bt-set-copy' }, h('span', null, t(locked ? 'No Project yet.' : 'No Project yet — create one.'))))
360-
: projects.map(project => h(SetRow, {
361-
key: project.id, label: project.name,
362-
hint: project.workDir === null || project.workDir === undefined ? undefined : project.workDir,
363-
},
364-
h('div', { className: 'bt-project-row-controls' },
365-
h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => openProjectBoard(project.id) }, t('Open board')),
366-
locked ? null : h('select', {
367-
className: 'bt-select', 'aria-label': t('Bind to {name}', { name: project.name }), value: '',
368-
onChange: event => { void bind(event.target.value, project) },
376+
: projects.flatMap(project => {
377+
const chiefError = typeof project.chief?.error === 'string' ? project.chief.error.trim() : ''
378+
const row = h(SetRow, {
379+
key: project.id, label: project.name,
380+
hint: project.workDir === null || project.workDir === undefined ? undefined : project.workDir,
369381
},
370-
h('option', { value: '' }, t('Bind a Bot or group')),
371-
members.map(member => h('option', { key: `${member.kind}:${member.id}`, value: `${member.kind}:${member.id}` },
372-
`${member.kind === 'group' ? t('Group') : t('Bot')} · ${member.name}`))))))),
382+
h('div', { className: 'bt-project-row-controls' },
383+
h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => openProjectBoard(project.id) }, t('Open board')),
384+
locked ? null : h('select', {
385+
className: 'bt-select', 'aria-label': t('Bind to {name}', { name: project.name }), value: '',
386+
onChange: event => { void bind(event.target.value, project) },
387+
},
388+
h('option', { value: '' }, t('Bind a Bot or group')),
389+
members.map(member => h('option', { key: `${member.kind}:${member.id}`, value: `${member.kind}:${member.id}` },
390+
`${member.kind === 'group' ? t('Group') : t('Bot')} · ${member.name}`)))))
391+
// The Chief a Project got at creation is stored on the record; a failure is written
392+
// there and nothing else ever showed it (#2869), so the row carries the host's words.
393+
if (chiefError === '') return [row]
394+
return [row, h('div', { key: `${project.id}:chief`, className: 'bt-project-chief-error', role: 'alert' }, t('Project Chief: {error}', { error: chiefError }))]
395+
})),
373396
bound.length === 0 ? null : h(SetSection, { key: 'bindings', title: t('Bindings') },
374397
bound.map(member => h(SetRow, {
375398
key: `${member.kind}:${member.id}`, label: member.name,

0 commit comments

Comments
 (0)