Repository navigation
fix(cockpit): mid-round log seeding — ops stderr tail rides the snapshot - #219
Merged
Merged
Conversation
task_log was fire-and-forget: a page opened mid-round saw only
post-subscribe lines, so 展開全量日誌 clicked with no visible change.
- backend: _OPS_LOG_KEEP=200 tail per ops task in UpdateManager
(created at start_ops_round, swept next round, survives terminal
state); snapshot() gains a logs face {task_id: [lines]}; unknown
task_id still emits without a tail
- frontend: TaskProvider.seedLogs on snapshot event + resync fetch,
replace-only-if-longer (stale snapshot never shrinks received lines)
- cockpit: expand button carries the line count; new round's rising
edge resets the expanded state
Gates: backend 90/0 (ops_rounds+tasks+pruning, 3 new), frontend
vitest 437/437 (3 new) + tsc + build
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.
问题
驾驶舱(运营 tab)轮次进行中打开页面时,点「展开全量日志」没有任何可见变化。
根因:
task_logSSE 事件是 fire-and-forget——后端UpdateManager.ops_log只_emit不留存,快照(SSE 初始事件与/api/tasks)只带 tasks+batch。轮中开页的用户丢掉订阅前的全部 stage 行,日志面只剩 1 行,展开与收起视觉相同。修复(三层)
backend/ipdb/_tasks.py):每 ops task 一条_OPS_LOG_KEEP=200deque 尾(与前端LOG_KEEP_LINES同窗)。start_ops_round建、下一轮 start 清扫、终态后仍随快照出(轮后开页也能播上一轮尾)。snapshot()增logs面{task_id: [lines]},经TasksSnapshotOutextra="allow" 透传。未知 task_id 照发事件不建尾(恢复轮替身不破)。frontend/src/tasks/TaskProvider.tsx):seedLogs接 SSE snapshot 事件与 resync fetch 两口;合并律=尾更长才替换——同 task 的 append-only 流上,更短的旧快照(fetch/SSE 竞态)不得缩水已收行。frontend/src/pages/OpsCockpit.tsx):展开钮带行数计数(单行时也有可见差);新一轮起跑上升沿复位展开态(全新日志面不跨轮携带)。验证
test_ops_rounds+test_tasks+test_tasks_pruning90 passed(新 3 例:尾随快照出+终态留+下轮清扫 / 205 行窗 200 / 未知 tid 只发不建)单写者直修(伞收口判例),非 SDD 派发。