-
Notifications
You must be signed in to change notification settings - Fork 22
feat(tui): Workflows screen list, trigger, inspect, and cancel workflow runs from terminal #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaeko44
wants to merge
6
commits into
main
Choose a base branch
from
task/4567dec9f7e3-feat-tui-workflows-screen-list-trigger-inspect-a
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ffa25cf
chore: auto-commit agent work (4567dec9-f7e)
jaeko44 c8c62c6
chore: auto-commit agent work (4567dec9-f7e)
jaeko44 b7657c5
Merge origin/main into task/4567dec9f7e3-feat-tui-workflows-screen-li…
jaeko44 c09ae01
Merge branch 'main' into task/4567dec9f7e3-feat-tui-workflows-screen-…
jaeko44 108760c
Merge remote-tracking branch 'origin/main' into HEAD
jaeko44 3794f1e
Merge remote-tracking branch 'origin/main' into HEAD
jaeko44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { resolve } from "node:path"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| describe("tui workflow status bridge architecture", () => { | ||
| it("forwards workflow status events through the UI websocket broadcast path", () => { | ||
| const monitorSource = readFileSync(resolve(process.cwd(), "infra/monitor.mjs"), "utf8"); | ||
| const uiServerSource = readFileSync(resolve(process.cwd(), "server/ui-server.mjs"), "utf8"); | ||
|
|
||
| expect(monitorSource).toContain("workflow:status"); | ||
| expect(uiServerSource).toContain('broadcastUiEvent(["workflows", "tui"], "workflow:status"'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { resolve } from "node:path"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| describe("tui workflows screen architecture", () => { | ||
| const appSource = readFileSync(resolve(process.cwd(), "ui/tui/App.js"), "utf8"); | ||
|
|
||
| it("mounts a dedicated workflows screen instead of a simple table", () => { | ||
| expect(appSource).toContain('./WorkflowsScreen.js'); | ||
| expect(appSource).toContain('<${WorkflowsScreen}'); | ||
| expect(appSource).not.toContain('title="Workflows"\n subtitle=${workflowState.loading ? "Loading configured workflows…"'); | ||
| }); | ||
|
|
||
| it("keeps workflows in the tab order", async () => { | ||
| const constants = await import("../ui/tui/constants.js"); | ||
| expect(constants.TAB_ORDER.some((tab) => tab.id === "workflows")).toBe(true); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { | ||
| WORKFLOW_FLASH_DURATION_MS, | ||
| WORKFLOW_HISTORY_LIMIT, | ||
| buildWorkflowHistoryRows, | ||
| buildWorkflowTemplateRows, | ||
| createWorkflowTriggerFormState, | ||
| reduceWorkflowStatusEvent, | ||
| toggleWorkflowTreeNode, | ||
| } from "../ui/tui/workflows-screen-helpers.js"; | ||
|
|
||
| describe("tui workflows screen helpers", () => { | ||
| it("builds template rows with required input summaries and live status glyphs", () => { | ||
| const rows = buildWorkflowTemplateRows([ | ||
| { | ||
| id: "continuation-loop", | ||
| name: "Continuation Loop", | ||
| type: "pipeline", | ||
| enabled: true, | ||
| schedule: "manual", | ||
| requiredInputs: { | ||
| taskId: { type: "string", required: true }, | ||
| }, | ||
| lastRunAt: "2026-03-25T12:00:00.000Z", | ||
| lastResult: "success", | ||
| }, | ||
| ], { | ||
| activeRuns: new Map([["continuation-loop", { runId: "run-1", spinnerFrame: 2 }]]), | ||
| flashByWorkflowId: new Map(), | ||
| now: Date.parse("2026-03-25T12:00:01.000Z"), | ||
| }); | ||
|
|
||
| expect(rows).toHaveLength(1); | ||
| expect(rows[0].name).toContain("Continuation Loop"); | ||
| expect(rows[0].name).toContain("⠹"); | ||
| expect(rows[0].scheduleOrTrigger).toBe("manual · taskId*"); | ||
| expect(rows[0].lastResult).toBe("success"); | ||
| }); | ||
|
|
||
| it("keeps only the most recent 50 history rows and surfaces run detail metadata", () => { | ||
| const history = Array.from({ length: 55 }, (_, index) => ({ | ||
| runId: `run-${index + 1}`, | ||
| workflowId: "wf-demo", | ||
| workflowName: "Demo", | ||
| status: index % 2 === 0 ? "completed" : "failed", | ||
| startedAt: 1_000 + index, | ||
| endedAt: 2_000 + index, | ||
| durationMs: 1_000, | ||
| triggerSource: "manual", | ||
| error: index % 2 === 0 ? null : "boom", | ||
| })); | ||
|
|
||
| const rows = buildWorkflowHistoryRows(history); | ||
| expect(rows).toHaveLength(WORKFLOW_HISTORY_LIMIT); | ||
| expect(rows[0].runId).toBe("run-55"); | ||
| expect(rows.at(-1).runId).toBe("run-6"); | ||
| expect(rows[1].result).toBe("failed"); | ||
| }); | ||
|
|
||
| it("creates inline trigger form state from required input schema", () => { | ||
| expect(createWorkflowTriggerFormState({ | ||
| taskId: { type: "string", required: true, description: "Task id" }, | ||
| branch: { type: "string", required: false, default: "main" }, | ||
| })).toEqual({ | ||
| fields: [ | ||
| { id: "taskId", label: "taskId", required: true, value: "", description: "Task id" }, | ||
| { id: "branch", label: "branch", required: false, value: "main", description: "" }, | ||
| ], | ||
| values: { taskId: "", branch: "main" }, | ||
| }); | ||
| }); | ||
|
|
||
| it("reduces workflow:status events into active runs, flashes, and history entries", () => { | ||
| const now = Date.parse("2026-03-25T12:00:00.000Z"); | ||
| let state = reduceWorkflowStatusEvent(undefined, { | ||
| runId: "run-1", | ||
| workflowId: "wf-1", | ||
| workflowName: "Demo", | ||
| eventType: "run:start", | ||
| status: "running", | ||
| timestamp: now, | ||
| }, now); | ||
|
|
||
| expect(state.activeRuns.get("wf-1")?.runId).toBe("run-1"); | ||
|
|
||
| state = reduceWorkflowStatusEvent(state, { | ||
| runId: "run-1", | ||
| workflowId: "wf-1", | ||
| workflowName: "Demo", | ||
| eventType: "run:end", | ||
| status: "completed", | ||
| durationMs: 800, | ||
| timestamp: now + 800, | ||
| }, now + 800); | ||
|
|
||
| expect(state.activeRuns.has("wf-1")).toBe(false); | ||
| expect(state.flashByWorkflowId.get("wf-1")?.status).toBe("completed"); | ||
| expect(state.history[0]).toMatchObject({ runId: "run-1", workflowId: "wf-1", status: "completed" }); | ||
|
|
||
| const afterFlash = reduceWorkflowStatusEvent(state, { | ||
| runId: "run-2", | ||
| workflowId: "wf-2", | ||
| workflowName: "Other", | ||
| eventType: "run:start", | ||
| status: "running", | ||
| timestamp: now + WORKFLOW_FLASH_DURATION_MS + 1, | ||
| }, now + WORKFLOW_FLASH_DURATION_MS + 1); | ||
| expect(afterFlash.flashByWorkflowId.has("wf-1")).toBe(false); | ||
| }); | ||
|
|
||
| it("toggles workflow detail tree expansion paths", () => { | ||
| const expanded = toggleWorkflowTreeNode(new Set(), "nodes.root.child"); | ||
| expect(expanded.has("nodes.root.child")).toBe(true); | ||
|
|
||
| const collapsed = toggleWorkflowTreeNode(expanded, "nodes.root.child"); | ||
| expect(collapsed.has("nodes.root.child")).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { | ||
| WORKFLOW_FLASH_DURATION_MS, | ||
| buildWorkflowHistoryRows, | ||
| buildWorkflowTemplateRows, | ||
| createWorkflowTriggerFormState, | ||
| reduceWorkflowStatusEvent, | ||
| tickWorkflowStatusState, | ||
| } from "../ui/tui/workflows-screen-helpers.js"; | ||
|
|
||
| describe("workflows-screen-helpers", () => { | ||
| it("builds trigger form fields from schema properties", () => { | ||
| const form = createWorkflowTriggerFormState({ | ||
| required: ["taskId"], | ||
| properties: { | ||
| taskId: { description: "Task id", default: "123" }, | ||
| note: { required: false, defaultValue: "hello" }, | ||
| }, | ||
| }); | ||
|
|
||
| expect(form.fields).toEqual([ | ||
| expect.objectContaining({ id: "taskId", required: true, value: "123", description: "Task id" }), | ||
| expect.objectContaining({ id: "note", required: false, value: "hello" }), | ||
| ]); | ||
| expect(form.values).toEqual({ taskId: "123", note: "hello" }); | ||
| }); | ||
|
|
||
| it("shows running spinner and completion flash in template rows", () => { | ||
| const active = reduceWorkflowStatusEvent(undefined, { | ||
| eventType: "run:start", | ||
| workflowId: "wf-1", | ||
| workflowName: "Continuation Loop", | ||
| runId: "run-1", | ||
| timestamp: 1000, | ||
| status: "running", | ||
| }, 1000); | ||
|
|
||
| const runningRow = buildWorkflowTemplateRows([ | ||
| { id: "wf-1", name: "Continuation Loop", requiredInputs: { taskId: { required: true } } }, | ||
| ], { | ||
| activeRuns: active.activeRuns, | ||
| flashByWorkflowId: active.flashByWorkflowId, | ||
| now: 1000, | ||
| })[0]; | ||
|
|
||
| expect(runningRow.name).toMatch(/^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] /); | ||
| expect(runningRow.scheduleOrTrigger).toContain("taskId*"); | ||
|
|
||
| const done = reduceWorkflowStatusEvent(active, { | ||
| eventType: "run:end", | ||
| workflowId: "wf-1", | ||
| workflowName: "Continuation Loop", | ||
| runId: "run-1", | ||
| timestamp: 1500, | ||
| status: "completed", | ||
| durationMs: 500, | ||
| }, 1500); | ||
|
|
||
| const flashedRow = buildWorkflowTemplateRows([ | ||
| { id: "wf-1", name: "Continuation Loop" }, | ||
| ], { | ||
| activeRuns: done.activeRuns, | ||
| flashByWorkflowId: done.flashByWorkflowId, | ||
| now: 1500 + WORKFLOW_FLASH_DURATION_MS - 1, | ||
| })[0]; | ||
|
|
||
| expect(flashedRow.name.startsWith("✔ ")).toBe(true); | ||
| }); | ||
|
|
||
| it("ticks spinner frames for active runs", () => { | ||
| const state = reduceWorkflowStatusEvent(undefined, { | ||
| eventType: "run:start", | ||
| workflowId: "wf-1", | ||
| runId: "run-1", | ||
| timestamp: 1000, | ||
| status: "running", | ||
| }, 1000); | ||
|
|
||
| const next = tickWorkflowStatusState(state); | ||
| expect(next.activeRuns.get("wf-1")?.spinnerFrame).toBe((state.activeRuns.get("wf-1")?.spinnerFrame + 1) % 10); | ||
| }); | ||
|
|
||
| it("caps and sorts recent history rows", () => { | ||
| const rows = buildWorkflowHistoryRows([ | ||
| { runId: "r1", workflowId: "wf", workflowName: "One", startedAt: 10, endedAt: 1010, status: "completed" }, | ||
| { runId: "r2", workflowId: "wf", workflowName: "Two", startedAt: 20, endedAt: 2020, status: "failed", error: "boom" }, | ||
| ]); | ||
|
|
||
| expect(rows.map((row) => row.runId)).toEqual(["r2", "r1"]); | ||
| expect(rows[0]).toEqual(expect.objectContaining({ result: "failed", error: "boom" })); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,9 +10,9 @@ import { | |||||||
| MIN_TERMINAL_SIZE, | ||||||||
| TAB_ORDER, | ||||||||
| } from "./constants.js"; | ||||||||
| import { useWebSocket } from "./useWebSocket.js"; | ||||||||
| import { useTasks } from "./useTasks.js"; | ||||||||
| import { useWorkflows } from "./useWorkflows.js"; | ||||||||
| import WorkflowsScreen from "./WorkflowsScreen.js"; | ||||||||
| import { useTasks } from "./useTasks.js"; | ||||||||
|
||||||||
| import { useTasks } from "./useTasks.js"; | |
| import { useTasks } from "./useTasks.js"; | |
| import { useWebSocket } from "./useWebSocket.js"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is brittle and currently mismatches
ui/tui/App.js: App imports WorkflowsScreen using double quotes ("./WorkflowsScreen.js"), but the test searches for the single-quoted substring./WorkflowsScreen.js. Update the check to match the actual source (e.g., look for"./WorkflowsScreen.js"or use a regex that ignores quote style).