[Fix] fix dashboard restored session rows#277
Merged
deepcoldy merged 3 commits intoJun 23, 2026
Conversation
8790dc7 to
42c75fd
Compare
…响应报有效动作 + no-wake 负向测试 Review 修复(PR deepcoldy#277): - 阻塞: session-resume.test.ts 也 mock 了 session-activity.js 但漏导出新增的 announceSessionRow,restoreActiveSessions 跑到 announceSessionRow(ds) 即抛 "No announceSessionRow export" → 补 vi.fn()(与 restore-zombie-close.test.ts 一致) - /resume 响应的 wake 改为报「实际是否 fork」(woke) 而非原始 query 参数;加注释 说明 wake=1 是 opt-in 运维 curl 钩子,默认关、不改任何现有调用方行为 - 补默认 resume(无 wake) 不 fork 的负向测试,守住 wake && 短路守卫
Codex 二审发现的残留竞态:daemon 在 restoreActiveSessions() 之前就发布发现 descriptor(daemon.ts:3643 vs :3765),dashboard 的 attachDaemon 是先 hydrate (GET /api/sessions)再订阅 SSE。若 hydrate 落在 restore 前 → 拿到空快照;而 DashboardEventBus 无 buffer/replay,restore 期的 announceSessionRow() 若发生在 本条 SSE 订阅建立之前就被丢弃 → 聚合器既无快照行也无 spawned 行,后续 session.update/close 仍按 unknown row 丢弃。原 PR 只修了「已订阅时 restore 才 announce」的路径,没修掉竞态本身。 修法:/api/events 处理器先 subscribe 再回放当前 listActiveSessions() 为 session.spawned。这样订阅前已注册的行经快照送达、订阅后注册的行经实时事件送达, 两路覆盖确定性消除竞态;不改启动顺序/descriptor 时机。幂等(聚合器/前端 store 均按 sessionId upsert)。补 SSE 快照回放回归测试。
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景 / Problem Found
这次修改是排查线上问题时发现的:botmux 重启前有 3 个会话在 dashboard 上表现为
starting,重启后这些会话在 dashboard 里看不到了。排查后确认,
starting不是持久化的Session.status,而是 dashboard 根据 active session 缺少 screen/status 派生出来的展示状态。daemon 重启时restoreActiveSessions()会把 active session 注册回内存,但此前不会向 dashboard SSE 广播完整 session row。如果 dashboard 在 hydrate/SSE 时序上先收到后续session.update/ close 事件,却本地还没有对应 row,这些 patch 就会被当成 unknown row 忽略,最终表现为恢复/关闭状态在 dashboard 消失。What Changed
announceSessionRow(ds)to publish a fullsession.spawneddashboard row fromcomposeRowFromActive(ds).announcePendingRepoSession()so session row announcements share one path.restoreActiveSessions()to announce restored normal sessions and restored adopt sessions immediately after they are registered intoactiveSessions.wake=1support toPOST /api/sessions/:sessionId/resume.wake=1, the route immediately callsforkWorker(ds, '', true)after a successful resume, which is useful for operational recovery when a session must be usable right away.Impact
wake=1.Validation
corepack pnpm vitest run --project unit test/dashboard-ipc.test.ts test/dashboard-attention-signals.test.ts test/restore-zombie-close.test.tscorepack pnpm exec tsc --noEmitgit diff --check