[codex] Fix agent background progress surfaces#269
Conversation
PR AI Review / PR AI 语义预检中文
本次 PR 新增 agent_runs 持久化状态表,统一 Android 通知、iOS background bridge 和前台 Agent activity widget 的进度语义。改动覆盖数据库 schema 迁移(14→15)、新增 AgentRunService、扩展 AgentBackgroundStatus 状态模型、修改 submitInput 链路、以及在 LocalTaskExecutor 中接入 run 生命周期钩子。diff 超过 220KB 被截断,部分 test 和 generated 代码无法完整验证。PR 提供了较充分的测试证据(540 passed, 7 skipped),但 Android 通知文案存在硬编码英文、_isDatabaseLocked 检测模式不一致等问题需关注。 影响范围
黄金链路
风险项
测试缺口
English
This PR introduces a durable agent_runs state table and unifies progress semantics across Android notifications, iOS background bridge, and the in-app Agent activity widget. Changes span DB schema migration (14→15), new AgentRunService, expanded AgentBackgroundStatus model, modified submitInput path, and run lifecycle hooks in LocalTaskExecutor. The diff exceeded 220KB and was truncated, so some test and generated code could not be fully verified. The PR provides substantial test evidence (540 passed, 7 skipped), but hardcoded English in Android notifications and inconsistent _isDatabaseLocked detection patterns warrant attention. Affected Areas
Golden Path
Findings
Test Gaps
|
…und-progress-status # Conflicts: # android/app/src/main/kotlin/com/memexlab/memex/AgentBackgroundService.kt # android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt # lib/data/services/agent_background_coordinator.dart # lib/data/services/agent_background_status.dart # lib/data/services/agent_queue_background_worker.dart # test/data/services/agent_background_status_test.dart
PR Preflight Summary / PR 预检汇总中文
English
PR Policy Preflight / PR 规则预检PR Policy Preflight / PR 规则预检中文
规则命中
English
Findings
PR Flutter Quality / Flutter 质量预检PR Flutter Quality / Flutter 质量预检中文
English
Flutter Analyzer Baseline
No new analyzer issues introduced by this PR. Flutter Test Baseline
No new Flutter test failures introduced by this PR. |
背景
Fixes #267。
这次 PR 聚焦修复后台 Agent 进度展示链路:Android 通知、iOS background bridge、以及 App 内浮动的 Agent activity widget 之前会各自读取不同的 transient activity / task snapshot,导致通知文本滞后、部分文案未本地化,以及从通知返回 App 时在缺少 live activity 历史的情况下无法稳定恢复进度。
本 PR 有意只收敛通知与进度语义,不重做 Agent Core,也不拆分 agent handler。更系统性的 SQLite executor ownership / foreground-background lease 问题继续由 #268 跟踪。
主要改动
agent_runs状态表,并把队列任务关联到同一个run_id,让一次用户提交对应一个可恢复的进度面。AgentBackgroundStatus语义,供 Android 通知、iOS background status payload、以及前台 Agent activity widget 复用。database is locked,避免非关键进度路径冒出未处理 Flutter 异常。本轮更新
upstream/main(base4b20327),并解决 merge conflicts;当前 PR 为MERGEABLE。submitInput风险:durableAgentRunService创建/刷新失败时只记录 warning,不再阻塞用户提交链路。submitInput回归测试,覆盖 durable run 写入失败但 fact/card 仍落盘的路径。tasks.run_idnullable 列会被添加;idx_tasks_run_id会被创建;agent_runs表可写;NULL run_id保持安全,不会污染新 durable run 的remainingTasks统计。已知后续
#268 继续跟踪系统性的 SQLite contention / 单 executor owner 设计。本 PR 已经让非关键进度/marker 路径更稳,但前后台 executor lease、WAL/busy timeout 验证、集中式 DB retry policy 仍建议单独设计,不放进本 PR 扩大范围。
验证
本轮补充验证:
git diff --checkflutter analyze --no-pub --no-fatal-infosflutter test --no-pub test/db/app_database_migration_test.dartflutter test --no-pub test/db/app_database_migration_test.dart test/data/services/agent_run_service_test.dart test/data/services/local_task_executor_test.dart test/data/repositories/submit_input_test.dartflutter test --no-pub --concurrency=1PR 原有验证记录:
flutter test test/data/services/agent_run_service_test.dart test/data/services/agent_background_status_test.dart test/data/services/agent_background_coordinator_test.dart test/data/services/agent_queue_background_worker_test.dart test/data/services/local_task_executor_test.dart test/ui/agent_activity/agent_activity_widget_test.dartflutter build apk --debug --flavor globalDevcom.memexlab.memex.dev:E/flutter ... Unhandled Exception;当前状态
9f9abe7。