session: a suspended session never gets time_idle and stays 'running' in the sidebar forever
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #62791 của @hakarrr — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- sqlite, typescript
Hướng nghiên cứu
Start by tracing the code that writes time_suspended and the sidebar logic that counts child sessions with time_idle unset; the issue does not name files or tests. Check how startup or suspension handles sessions without a live process or turn, then add coverage for a suspended child. Done means interrupted children are finalized and no longer counted as running.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A session that is suspended by a server restart (or otherwise interrupted) never gets time_idle / idle_outcome written. The sidebar therefore counts it as an active subagent indefinitely — in my case the app showed "6 subagents" while only 2 were actually running; the other four had last activity 4 and 10 days earlier. Only a manual UPDATE session_v2 SET time_idle = ... clears them.
Environment
- opencode version: v2.1.4
- OS: Linux 6.17.0-41-generic (Ubuntu) x86_64
- Terminal: TERM_PROGRAM=WezTerm, TERM=xterm-256color, COLORTERM=truecolor
- Shell: /usr/bin/zsh
- Install/channel: latest (
~/.opencode/bin/opencode) - Active plugins: none found in
~/.config/opencode/opencode.json(permissions only) and no.opencode/plugin*directories
Reproduction
- Run opencode with a main session that spawns subagent sessions (the child rows have
session_v2.parent_idset). - Restart the app/server, or let the server suspend a child while it is running (in my DB these rows have
time_suspendedset). - Open the session sidebar / subagent counter.
- Observe the suspended child still counted as running, days after its last message.
- Confirm in the database: the row has
time_suspendedset, buttime_idle IS NULLandidle_outcome IS NULL.
Query used:
select id, title, time_updated, time_idle, time_suspended, idle_outcome
from session_v2
where parent_id = '<main session id>' and time_idle is null
order by time_updated desc;
Result at the time of the report (only the first two were actually alive):
| last activity | title | time_idle | time_suspended |
|---|---|---|---|
| today 21:51 | Multi-instance processor and drain | NULL | set |
| today 21:45 | Fix macOS desktop compile stage | NULL | set |
| 2026-11-04 13:21 | Scrub client infrastructure | NULL | set |
| 2026-11-04 13:07 | Fix code-diver index freshness | NULL | set |
| 2026-11-04 01:45 | Infisical env gap and config guard | NULL | set |
| 2026-10-27 19:40 | Ask-for-credentials UX with reuse | NULL | NULL |
Expected Behavior
A child session that the server suspends or abandons should be finalized — time_idle written with idle_outcome of interrupted/failed — so the UI stops counting it as an active subagent. At minimum, a session with no activity for hours/days must not be reported as running.
Actual Behavior
The sessions keep time_idle IS NULL forever. The subagent counter and any "running" indicator treat them as live work: the UI said "6 subagents" when 2 were running and 4 had been dead for 4-10 days. Restarting the app does not reconcile them, because the state lives in the database, not in memory.
Scale in this one profile: 1896 rows in session_v2, of which 761 had time_idle IS NULL (most inherited from the v2 migration), so this is systematic rather than a one-off.
Additional Context
Workaround that fixed the display (data-preserving, only marks sessions idle):
update session_v2
set time_idle = time_updated, idle_outcome = 'interrupted'
where time_idle is null
and time_updated < (strftime('%s','now') - 24*3600) * 1000;
After that the sidebar showed only the two genuinely running subagents.
Expected repair path inside opencode: on startup (or on the suspension path that sets time_suspended), finalize any child that has no live process/turn — e.g. mark time_idle = time_updated, idle_outcome = 'interrupted', and expose that state in the sidebar instead of "running".
- Ngôn ngữ chính
- TypeScript
- Star
- 225k
- Fork
- 30.4k
- Merge trung bình
- 4 giờ 16 phút
- Pull request đã merge (30 ngày)
- 528
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
anomalyco/opencode#62873 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#62822 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anomalyco/opencode#62601 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#62516 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
anomalyco/opencode#62374 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
code-quality good-first-issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenRailAssociation/netzgrafik-editor-frontend#1481 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🙌 icon request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
lucide-icons/lucide#5183 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Unhandled rejection when a call fails before delivery and an argument is an imported promiseĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 81/100
cloudflare/capnweb#293 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug implicit-state
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
area:models enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày