Closing a TUI tab leaks its runtime, session and context in --listen mode
Mantenedores costumam responder em até 1 dia
@pcbeingused333 já está trabalhando nisso.
Desde 14/11/2026.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Read AttachRuntime (pkg/server/session_manager.go around lines 451-463) next to finishSessionDeletion (lines 958-992), since the detach path should mirror the cleanup there. Then check the tab-close flow in Supervisor.CloseSession (pkg/tui/service/supervisor/supervisor.go:308) and the injector registration in cmd/root/run_listen.go:49. Done means a closed tab disappears from GET /api/sessions, its context is cancelled, and the persisted session still exists.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
In --listen mode every TUI tab attaches its runtime to the serving session
manager, and there is no detach path. The only code that removes an entry
from runtimeSessions is session deletion
(DeleteSession/BatchDeleteSessions → finishSessionDeletion,
pkg/server/session_manager.go:958-992), while closing a tab goes through
Supervisor.CloseSession (pkg/tui/service/supervisor/supervisor.go:308),
which cancels the TUI-local context and removes the tab from the supervisor
— but is not a session deletion, so none of that cleanup ever runs for a
closed tab.
Per closed tab, the following stay reachable for the life of the process:
- the
runtime.Runtimeandsession.Sessionheld by theactiveRuntimes
entry (session_manager.go:451-463); - the context created by
context.WithCancel(context.WithoutCancel(ctx))
insideAttachRuntime— itscancelis only invoked on session deletion,
so the whole context tree is retained; - the follow-up injector registered at
cmd/root/run_listen.go:49
(sm.RegisterFollowUpInjector(sess.ID, a.InjectUserMessage)), a closure
that keeps the tab's*app.Appreachable; - the recall handler
AttachRuntimeinstalls on the runtime
(session_manager.go:460).
A long-running --listen process that cycles through tabs therefore
accumulates one runtime+session+context set per closed tab, none of it
collectable. A single CLI run is bounded by process exit; the same
unbounded accumulation applies to embedders that attach runtimes to a
serve api session manager.
Expected Behavior
Closing a tab releases what the tab attached to the session manager: the
runtimeSessions entry is removed, its context cancelled, and the follow-up
injector / recall handler dropped — while the persisted session itself stays
(tab close ≠ session delete).
Actual Behavior
Closed tabs keep their runtime, session and context attached until the
process exits. GET /api/sessions keeps listing tabs that were closed,
because GetActiveSessions ranges over runtimeSessions
(session_manager.go:505-510).
Steps to Reproduce
docker-agent run config.yaml --listen 127.0.0.1:8080- In the TUI, open several new tabs (each spawned tab attaches to the
serving manager — see the wiring comment atcmd/root/run_listen.go:31-43) - Close the tabs
curl http://127.0.0.1:8080/api/sessions— every closed tab still shows
up as an active session, and the underlying runtime/session/context are
never released
Docker Agent version
docker-agent version dev Commit: 3c9f6d4
OS & terminal
No response
Model used
No response
Error output
Screenshots
No response
Additional context
Verified on current main (3c9f6d45b): no DetachRuntime exists anywhere
in the tree, and runtimeSessions.Delete has exactly one call site (session
deletion).
Suggested direction: a DetachRuntime(sessionID) symmetric with
AttachRuntime, called from the tab-close path — remove the entry, call
cancel(), and unregister the follow-up injector, recall handler and
event-log references (mirroring finishSessionDeletion's cleanup at
session_manager.go:989-992), leaving the persisted session intact. The
locker AttachRuntime returns carries the #3590 stream-guard contract
(callers hold it across direct RunStream calls), so a detach path must
keep that contract working for still-attached runtimes.
- Linguagem predominante
- Go
- Estrelas
- 4.7k
- Forks
- 565
- Merge médio
- 18h 52min
- PRs com merge (30d)
- 221
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de docker/docker-agent
-
edit_file diff rendering panics on invalid UTF-8 textTalvez já em andamento @TDnorthgarden assumiu hoje. Abertaarea/tui
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
docker/docker-agent#4955 ·
Mantenedores costumam responder em até 1 dia
-
A setting to turn off the models.dev catalog download (offline and strict-network use)Talvez já em andamento @3431481073 assumiu há 19 dias. Abertaarea/config area/models
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
docker/docker-agent#4714 ·
Mantenedores costumam responder em até 1 dia
-
Error when trying to run sandbox example?Talvez livre de novo @dgageot assumiu há 28 dias e não há nenhum pull request aberto. Abertaarea/cli
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
docker/docker-agent#4672 · 1 comentário · 1 reação · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
`edit_file` silently edits the first match when `oldText` occurs more than onceTalvez já em andamento @dwin-gharibi assumiu há 103 dias. Abertaarea/tools
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
docker/docker-agent#3929 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
area/api area/runtime
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
docker/docker-agent#4951 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de docker/docker-agent
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
IBM-Cloud/terraform-provider-ibm#7115 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
fluxcd/notification-controller#1441 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
volcengine/volcengine-go-sdk#163 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
OneBusAway/maglev#2145 ·
Mantenedores costumam responder em até 2 dias
-
priority/medium status/ready type/chore
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
discobox-ai/discobox#1357 ·
Mantenedores costumam responder em até 1 dia