Repository navigation
feat(site): add a Workflows panel to agent chats - #256
Conversation
A nil json.RawMessage parameter is not a driver NULL: database/sql converts it to a zero-length []byte, which lib/pq sends as an empty string and Postgres rejects on a jsonb column (invalid input syntax for type json). Route the three nullable jsonb params through pqtype.NullRawMessage via sqlc column overrides and a jsonbValue helper.
The run list, run detail and stop_workflow of a chat, as the API side
of the fork-workflows experiment:
- GET /api/v2/chats/fork/{chat}/workflow-runs (keyset page, step counts)
- GET /api/v2/chats/fork/{chat}/workflow-runs/{run} (script, steps,
result and logs of the terminal snapshot)
- POST /api/v2/chats/fork/{chat}/workflow-runs/{run}/stop (409 terminal)
Every route is gated like the workflow tools: the fork-workflows
experiment and the chat owner's deployment owner role. The stop runs
through chatd.ForkStopWorkflowRun: a live run unwinds on a canceled
script context and journals stopped with a snapshot that carries the
failed open steps; a run this replica does not hold is stopped through
its journal rows.
A chatdmig node adds workflow_runs.updated_at/finished_at and
workflow_steps.started_at/finished_at, which the run status updates
stamp. The generated forkdb output, the apidoc swagger entries and
typesGenerated.ts are not in this commit yet.
…olumns The sqlc.arg(...)::jsonb casts cut the params off from the column overrides, so InsertWorkflowStepParams.Value and the Update* result and value params generated as json.RawMessage and did not compile against jsonbValue's pqtype.NullRawMessage. An uncast param keeps the override: the generated param is NullRawMessage, which sends a real SQL NULL for an empty document instead of the zero-length string Postgres rejects on jsonb. The models already scanned NullRawMessage, so this completes the same fix as the column overrides.
…s-2b-run-api # Conflicts: # coderd/database/forkdb/queries/workflow_runs.sql
The merge of the jsonb param fix duplicated the method after FailOpenWorkflowStepsOfRun; vet caught the redeclaration.
A resumed run returned journaled steps without setting reused, so the await result showed reused false for steps the restart did not run again. The journal read path already hardcodes reused for the same reason.
…b-run-api # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/queries/workflow_runs.sql # coderd/database/forkdb/sqlc.yaml # coderd/x/chatd/fork_workflow.go # coderd/x/chatd/fork_workflow_journal.go # coderd/x/chatd/fork_workflow_journal_internal_test.go
…into mike/workflows-ui-2-panel
…anel # Conflicts: # coderd/x/chatd/fork_workflow.go # coderd/x/chatd/fork_workflow_journal_internal_test.go
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c913639fc9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged head
Follow-ups: the Stop button comes in the next PR. The duration of an interrupted run keeps growing because the run has no |
Chats in the
fork-workflowsexperiment get a Workflows tab in the right panel. This is the second of three UI PRs for the experiment; the first rendered the workflow tool cards (#246), and the next adds a Stop control.The tab appears only when the experiment is on, the viewer is an owner, the chat is a root chat, and the chat has at least one workflow run, so ordinary chats are unchanged. A failed run list request hides the tab.
The run list shows each run newest first: a status badge, the title (or the script preview, cut off with an ellipsis, when the run has none), when it started, how long it ran, step progress and failed step count. Clicking a run opens its detail: status, title, timing, step progress, run ID, a hint to ask the agent to resume an interrupted run, the run error, the step list linking each step to its child chat, the result, logs and script. A back button returns to the list.
Runs have no watch socket, so the list polls every 5 seconds while a run is running and every 30 seconds otherwise. The detail polls every 3 seconds while its run is running and the tab is visible. A failed refetch keeps the cached data and shows a warning.
The panel reads the run list and detail endpoints from #258 with their generated
WorkflowRunandWorkflowRunDetailtypes, and reuses the status badge, step list and long text fromcomponents/ForkWorkflows/(#246). The only upstream file touched isAgentChatPageView.tsx: two imports, one hook call and one conditionalSidebarTab.