Skip to content
Merged
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/1810-settings-workflows-poll.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Settings → Workflows follows a live run instead of freezing at the moment the page opened: while any workflow has work running the page re-reads `workflow/state` every 2 seconds — the room drawer's own beat — so a step that goes running → done changes its chip without reopening the page, an edit in progress suspends the refresh, and the page stops asking when the last run finishes or it is closed ([#1810](https://github.com/ThinkFlowLab/FlyBot/issues/1810)).
19 changes: 17 additions & 2 deletions core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15072,6 +15072,7 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
// src/client/workflows.js
var import_react36 = require("react");
var READ_MS = 8e3;
var POLL_MS6 = 2e3;
var WORKFLOW_PLUGIN_HINT = "The Workflow plugin is not installed or not enabled. A default install includes @flybot/workflow.";
var COLORS = { Planner: "#8b5cf6", Writer: "#f0509a", Coder: "#1fbf6a", Reviewer: "#f5a524", Tester: "#14b8a6", Deployer: "#2f7cf6" };
function workflowCallMissing(failure) {
Expand Down Expand Up @@ -15559,6 +15560,20 @@ function WorkflowsPage({ call: call5, roster }) {
gone = true;
};
}, []);
const live = (pack?.workflows ?? []).some((item) => (item.activeCount ?? 0) > 0);
(0, import_react36.useEffect)(() => {
if (!live || editing) return void 0;
let gone = false;
const timer = setInterval(() => {
readWorkflows(invoke).then((settled) => {
if (!gone) apply2(settled);
});
}, POLL_MS6);
return () => {
gone = true;
clearInterval(timer);
};
}, [live, editing]);
const retry = () => {
setPhase("loading");
setError("");
Expand All @@ -15567,8 +15582,8 @@ function WorkflowsPage({ call: call5, roster }) {
};
const open = (item, source) => {
if (source === "factory") {
const live = (pack?.workflows ?? []).find((workflow) => workflow.id === item.id);
setOpened(live ? { source: "own", id: live.id, fromFactory: item.id } : { source: "factory", id: item.id });
const live2 = (pack?.workflows ?? []).find((workflow) => workflow.id === item.id);
setOpened(live2 ? { source: "own", id: live2.id, fromFactory: item.id } : { source: "factory", id: item.id });
setEditing(false);
return;
}
Expand Down
17 changes: 17 additions & 0 deletions core/src/client/workflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { t } from './i18n.js'

export const READ_MS = 8000

// The room's Workflow drawer re-reads a live run on this beat; Settings shows the
// same data, so it moves at the same speed instead of freezing at mount (#1810).
export const POLL_MS = 2000

// Shown when @flybot/workflow is not registered. A default install includes it;
// the page says so instead of the host's "Unknown FlyBot endpoint workflow/…" string.
const WORKFLOW_PLUGIN_HINT = 'The Workflow plugin is not installed or not enabled. A default install includes @flybot/workflow.'
Expand Down Expand Up @@ -418,6 +422,19 @@ export function WorkflowsPage({ call, roster }) {
return () => { gone = true }
}, [])

// The page used to read once, so a running step's chip kept the colour it had at
// mount. While any workflow is live it asks again on the room's beat; an edit
// suspends that, because a refresh would land in the middle of one (#1810).
const live = (pack?.workflows ?? []).some((item) => (item.activeCount ?? 0) > 0)
useEffect(() => {
if (!live || editing) return undefined
let gone = false
const timer = setInterval(() => {
readWorkflows(invoke).then((settled) => { if (!gone) apply(settled) })
}, POLL_MS)
return () => { gone = true; clearInterval(timer) }
}, [live, editing])

const retry = () => {
setPhase('loading')
setError('')
Expand Down
Loading
Loading