-
Notifications
You must be signed in to change notification settings - Fork 695
[已撤回] 修复看板日志不可见(请看 #117) #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |||||||||||||||||||
| DIST = BASE / 'dist' # React 构建产物 (npm run build) | ||||||||||||||||||||
| DATA = BASE.parent / "data" | ||||||||||||||||||||
| SCRIPTS = BASE.parent / 'scripts' | ||||||||||||||||||||
| _ACTIVE_TASK_DATA_DIR = None | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # 静态资源 MIME 类型 | ||||||||||||||||||||
| _MIME_TYPES = { | ||||||||||||||||||||
|
|
@@ -82,21 +83,84 @@ def now_iso(): | |||||||||||||||||||
| return datetime.datetime.now(datetime.timezone.utc).isoformat().replace('+00:00', 'Z') | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| def load_tasks(): | ||||||||||||||||||||
| return atomic_json_read(DATA / 'tasks_source.json', []) | ||||||||||||||||||||
| def _iter_task_data_dirs(): | ||||||||||||||||||||
| """返回可用的任务数据目录候选(优先 workspace,其次本地 data)。""" | ||||||||||||||||||||
| dirs = [DATA] | ||||||||||||||||||||
| oclaw_home = pathlib.Path.home() / '.openclaw' | ||||||||||||||||||||
| for p in sorted(oclaw_home.glob('workspace-*/data')): | ||||||||||||||||||||
| if p.is_dir(): | ||||||||||||||||||||
| dirs.append(p) | ||||||||||||||||||||
| return dirs | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+89
to
95
|
||||||||||||||||||||
| oclaw_home = pathlib.Path.home() / '.openclaw' | |
| for p in sorted(oclaw_home.glob('workspace-*/data')): | |
| if p.is_dir(): | |
| dirs.append(p) | |
| return dirs | |
| for p in sorted(OCLAW_HOME.glob('workspace-*/data')): | |
| if p.is_dir(): | |
| dirs.append(p) | |
| return dirs |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_task_source_score() 遍历 tasks 时假设每个元素都是 dict:(t or {}).get(...) 在 t 为 str/int 等非 dict 时会抛 AttributeError,进而导致 get_task_data_dir()/healthz/live-status 等接口异常。建议在循环内先判断 t 是否为 dict(或使用 try/except / getattr 兜底),保证异常/脏数据不会把服务打挂。
| tid = str((t or {}).get('id', '')) | |
| if not isinstance(t, dict): | |
| continue | |
| tid = str(t.get('id', '')) |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_task_data_dir() 会在“当前没有任何候选目录包含 tasks_source.json”时依然把 _ACTIVE_TASK_DATA_DIR 缓存为 DATA(best_dir 初始值),之后即使 workspace/data 下生成了 tasks_source.json 也不会重新探测(因为缓存目录 is_dir() 仍为 True)。建议只在找到有效 tasks_source.json 时才缓存,或增加重探测条件/TTL(例如当选中的 tasks_source.json 不存在时重新选择)。
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_refresh_live_data_async() 在 workspace 数据目录未包含 scripts/refresh_live_data.py 时会 fallback 到项目级 SCRIPTS/refresh_live_data.py;但该脚本内部把 DATA 固定为“脚本所在仓库的 data/”,会把 live_status.json 写到项目 data 而不是已选中的 task_data_dir,导致看板读取的 live_status.json 仍不可见/不同步。建议:不要对 workspace 场景 fallback 到项目脚本;或给脚本增加 data_dir 参数/环境变量并在此处传入,确保生成文件落在 task_data_dir。
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR 描述中提到“统一 /healthz /api/live-status /api/agent-config 使用同一数据源”,但当前 diff 只把 /healthz 与 /api/live-status 切到 get_task_data_dir();/api/agent-config(以及后续 model-change-log/last-result 等)仍固定读取 DATA。若这些文件也可能落在 workspace data 下,会继续出现数据源不一致。建议确认需求后要么同步改为使用 task_data_dir,要么在 PR 描述中澄清哪些文件仍然固定在 DATA。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_iter_task_data_dirs() 的注释写的是“优先 workspace,其次本地 data”,但当前实现是先把 DATA 放进列表再 append workspace。由于 get_task_data_dir() 在评分相同的情况下不会覆盖 best_dir(使用的是 > 而不是 >=),这会导致同分时始终偏向本地 DATA,与注释/预期不一致。建议调整候选目录顺序(workspace 在前)或在评分相同时显式优先 workspace。