Skip to content

feat(daemon): manage a session's background jobs from /tasks - #1729

Merged
edenreich merged 6 commits into
mainfrom
feat/daemon-tasks
Nov 6, 2026
Merged

edenreich merged 6 commits into
mainfrom
feat/daemon-tasks

Conversation

@edenreich

@edenreich edenreich commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

/tasks now works in a daemon chat. It used to refuse with a daemon chat starts no A2A tasks of its own, but the view also lists shells and subagents, and in a daemon chat all of them run in the thread's worker. The chat had no way to see or stop them.

The worker now answers two new panel frames from its job supervisor, and the view loads from them in a daemon chat. An in-process chat behaves as before.

Closes #1731, since /tasks now works during a daemon chat's run and closing it would otherwise cost the run its status.

Changes

  • internal/presentation/headless/panel_tasks.go (new): list_tasks answers with the worker's jobs and cancel_task stops one. An A2A task is also cancelled on its agent, the way the in-process view does it.
  • internal/sessions/registry.go: both frames route like the other panel requests. The thread's own worker answers, which matters here because the jobs live in that process.
  • internal/presentation/tui/daemonthread/tasks.go (new): the client, following Artifacts.
  • tui.WorkerJobs is the contract the view takes. GetWorkerJobs returns nil for an in-process chat.
  • TaskView: it loads from the worker in a daemon chat. Its running counts come from the loaded rows there, since rendering cannot ask the worker. A finished A2A row no longer offers cancel, which matters now that such a row can have no retained record.
  • FeatureTasks and the refusal are gone.
  • docs/browser-extension-protocol.md documents both frames, and the daemon, shortcuts and task docs are updated.

A run keeps its status across a panel

Opening /tasks during a run and closing it wiped the run's status, so the chat looked stopped while the agent kept working. Three things overwrote it, which is more than #1731 named:

  • A shortcut announced Executing <name>... over the status and restarted its timer. While a run is busy it no longer does.
  • A panel set its own text under the panel, where nobody can see it, and left it behind. StatusView now ignores a status without a spinner that arrives under a panel during a run, and the task view's own message is gone.
  • Closing the panel cleared the line. StatusView now ignores that blank status during a run. A direct tool with no chat session still clears it.

The /tasks menu also stayed on screen after closing the panel. A keystroke's update could land after Enter sent the text, so an update for text the input no longer holds is now dropped.

Limits

  • The view polls once a second while a job runs. A job started while nothing runs shows after reopening /tasks, because a daemon chat gets no local job change event. This is marked with a ponytail: comment.
  • A cancelled shell shows as Failed, the same as in an in-process chat.

Verification

  • TestChatDaemonListsAndStopsTheWorkersJobs and TestChatDaemonShowsAFinishedJobsOutput fail on main and pass here. TestChatDaemonShowsASubagentsTranscript covers a subagent's stats and transcript, and I did not run it against main.
  • Unit tests cover the panel frames (including the A2A route and a reported failure), the client, the view and the registry's routing.
  • go test -race ./... and task precommit:run passed on the first commit, and the full e2e suite on that commit too.
  • For the status fix: TestChatTUIKeepsARunsStatusAfterClosingAPanel (/tasks and /theme) and TestChatDaemonKeepsARunsStatusAfterClosingTasks fail without it and pass with it, along with a unit table covering what the guard keeps and what it still lets through.
  • By hand with tmux and tokenless, opened during a run: /tasks, /tools, /agents, /conversations, /artifacts, /explorer and /theme closed with Esc, and /model closed by picking a model. Each showed the run's status afterwards.
  • A full local go test -race ./... and e2e run of the status fix was interrupted, so CI is the full check for that commit. The changed packages and the daemon and status e2e tests pass locally.

Not exercised end to end: an A2A task in a daemon chat, which only has unit tests, and a session teleported to a remote workspace. The frames take the same route as list_artifacts there, but no test drives it.

Downstream

A daemon chat refused /tasks, saying it starts no A2A tasks of its own. The
view also lists shells and subagents, and in a daemon chat all of them run in
the thread's worker, so the chat had no way to see or stop them.

The worker now answers list_tasks and cancel_task from its job supervisor, and
the view loads from it in a daemon chat. Details work the same way, and a
subagent's transcript already came from the worker's storage.
@edenreich
edenreich requested a review from a team as a code owner November 6, 2026 22:41
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 6, 2026
Opening /tasks during a run and closing it wiped the run's status, so the chat
looked stopped while the agent kept working. A shortcut announced itself over the
status and restarted its timer, a panel set its own text under the panel where
nobody can see it, and closing the panel cleared the line. Later chunks did not
bring the status back, since they only update it when the chat status changes.

While a run is busy, a shortcut no longer announces itself. A status without a
spinner no longer replaces the run's when it is blank or arrives under a panel.
The task view's own message is gone, since it could never be seen.

The /tasks menu also stayed on screen after closing the panel. A keystroke's
update is delivered asynchronously and could land after Enter sent the text, so
an update for text the input no longer holds is now dropped.
Comment thread internal/presentation/headless/panel.go Resolved
Comment thread internal/presentation/headless/panel.go Resolved
Comment thread internal/presentation/headless/panel.go Resolved
@edenreich

Copy link
Copy Markdown
Contributor Author

@infer can you run task fmt? nothing more.

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Model: ollama_cloud/glm-5.3-flash · Action: v0.59.4 · CLI: v0.244.0 · View Job

Todos

(agent has not posted a plan yet)

Pull Request

#1729

✅ Infer Result: Success

Done. task fmt reformatted one file - internal/presentation/headless/panel.go (struct field alignment in PanelDeps, a leftover from the review suggestion batch) - and I committed it as style(headless): run task fmt and pushed it to feat/daemon-tasks. The pre-commit hook (mod tidy, imports check, golangci-lint, markdownlint) passed, and the working tree is clean and in sync with origin.

Model: ollama_cloud/glm-5.3-flash · Action: v0.59.4 · CLI: v0.244.0 · Exit Code: 0 · Duration: 3m 34s

Tokens: 211,350 in · 1,643 out · 212,993 total (8 requests)

Tool calls: 7 total · 100% success rate

Traces
Session: 1794007841-7e978de7

session (headless, success)                                                                        3m26s
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
│           ╰── POST [inference-gateway, server]                                                    2.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
├── execute_tool Bash call_3b0wi1b4                                                                 2.9s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.3s
│           ╰── POST [inference-gateway, server]                                                    1.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.3s
├── execute_tool Bash call_dt5lq15t                                                                 10ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.2s
│           ╰── POST [inference-gateway, server]                                                    1.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.2s
├── execute_tool Bash call_aiyfon2t                                                                  5ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.3s
│           ╰── POST [inference-gateway, server]                                                    3.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.3s
├── execute_tool Bash call_v926ynvd                                                                 11ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.3s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        1.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.3s
├── execute_tool Bash call_re27a2lj                                                                 3m7s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.2s
│           ╰── POST [inference-gateway, server]                                                    1.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.2s
├── execute_tool Bash call_9t4951ut                                                                 1.4s
├── chat ollama_cloud/glm-5.3-flash                                                                981ms
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      972ms
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    968ms
│           ╰── POST [inference-gateway, server]                                                   968ms
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                968ms
├── execute_tool Bash call_pcatdi2w                                                                  9ms
╰── chat ollama_cloud/glm-5.3-flash                                                                 1.4s
    ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.4s
        ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.4s
            ╰── POST [inference-gateway, server]                                                    1.4s
                ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.4s
Stats
Tool Calls

╭──────┬───────┬───────┬─────────╮
│ Tool │ Calls │ Fail% │ Avg     │
├──────┼───────┼───────┼─────────┤
│ Bash │ 7     │ 0%    │ 27371ms │
╰──────┴───────┴───────┴─────────╯

Token Usage

╭────────────────────────────┬────────┬────────┬────────────┬────────┬──────╮
│ Model                      │ Prompt │ Cached │ Completion │ Total  │ Cost │
├────────────────────────────┼────────┼────────┼────────────┼────────┼──────┤
│ ollama_cloud/glm-5.3-flash │ 211350 │ 89600  │ 1643       │ 212993 │ -    │
╰────────────────────────────┴────────┴────────┴────────────┴────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ headless │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

@edenreich
edenreich merged commit f7a371c into main Nov 6, 2026
1 check passed
@edenreich
edenreich deleted the feat/daemon-tasks branch November 6, 2026 23:51
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.246.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 7, 2026
@edenreich edenreich moved this from Todo to Done in 2026 Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Closing /tasks during a run clears the run's status

1 participant