Skip to content

feat(briefing): read the daily briefing in the browser (/report/work_briefing); Qt window keeps only the notes/Slack tabs (ADR 0018) - #85

Merged
LiminCode merged 1 commit into
mainfrom
m4b-briefing-page
Nov 20, 2026
Merged

LiminCode merged 1 commit into
mainfrom
m4b-briefing-page

Conversation

@LiminCode

Copy link
Copy Markdown
Owner

Summary

The daily work briefing is now read in the browser instead of a Qt window. The island's document button, the morning alert's "View" and the right-click "View the latest" all open /report/work_briefing on the config-panorama local service: summary, usage chips (model / effort / time / tokens / cost), the full text (★ priority colours, 🐞 rows tinted, status chips, links in new tabs) and a "Regenerate" button. While a briefing is generating the page redraws itself (busy → new content) over the same long-poll the panorama uses. The Qt WorkBriefingWindow stays only as a shell for the notes / Slack tabs (it no longer carries a briefing tab); the personal assistant keeps its own window until its turn. The right-click menu loses the "Generation time" sub-menu (the value is edited on the panorama) and gains "Briefing settings…". ADR 0018 records the direction and the order of the remaining moves; roadmap section M4b added.

What changed and why

  • pet/panorama/markdown.py (new): zero-dependency Markdown → HTML for the subset briefings use (headings, nested -/1. lists, paragraphs, bold, inline code → <code class="chip">, [text](http(s)://…) and bare URLs → target=_blank rel=noopener links; other schemes stay text). Leading ★ on a list item → <span class="star s1|s2|s3">, items starting with work_briefing.BUG_MARK → <li class="bug"> (their indented scene lines are the nested list inside). This replaces the Qt window's _decorate fragment walk; everything else is escaped.
  • pet/panorama/reports.py (new): report providers. work_briefing(service_of, config) turns WorkBriefingService.latest() / busy / last_error() into the page's fixed-field dict (title, theme, summary, generated, usage[], html, busy, busy_text, empty_text, error, action, available); generate_work_briefing → started / busy / failed / unavailable; theme() follows context_menu_appearance.theme (no toggle on the page: one place to edit a preference).
  • pet/panorama/service.py: reports= ctor kwarg, one Feed per report; has_report, report(name, after, wait) (first ask builds the payload on the GUI thread via on_gui), publish_report(name, force=False) (does nothing until someone has looked, so the started/finished signals never run the provider for nobody), report_watched (a page is long-polling = the user is reading), open_report(name) (starts the server without a panorama collection round, opens /report/<name>#token). _page_target split into _server_url(path) + the focus suffix; stop() closes report feeds.
  • pet/panorama/routes.py: GET /report/{name} (public shell, 404 for unregistered names) and GET /api/report/{name} (token, ?after= long-poll like /api/graph); module docstring lists them.
  • pet/panorama/actions.py: generate_report(generators) (400 bad_report for unknown names).
  • pet/panorama/render.py: REPORT_SHELL / REPORT_STYLES / REPORT_MODULES / REPORT_KEYS, report_shell(), report_payload(); ASSETS serves the new files; client.js joins MODULES (before boot.js), report.js deliberately does not (it is an entry that runs itself and must not be bundled into the offline snapshot).
  • pet/panorama/page/client.js (new): takeToken(storageKey) + makeApi(token) extracted from boot.js so both pages share the token handling and the api / api.patch / api.post helpers; boot.js now imports them (no behaviour change, its tests still pass). report.html / report.css / report.js (new): the report page; CSS uses the shared --m-* tokens plus the same extra colours as the Qt shell's _EXTRA_TOKENS, no border radius.
  • pet/work_briefing_ui.py: WorkBriefingWindow(briefing_page=False) builds the shell without the briefing tab; WorkBriefingController(open_report=, report_watched=) — "view" opens the browser (and counts as read), a failed open shows a bubble, a page being watched suppresses the new-briefing alert, open_window(tab=…) still opens the Qt shell for notes / Slack. Without the two callbacks the old Qt path is unchanged (tests, other callers).
  • pet/app.py: _panorama() builds the service lazily and registers reports={"work_briefing": …} plus the generate_report action; _open_report / _report_watched / _publish_report; the briefing service's started / finished publish the report.
  • pet/context_menus/shared.py, pet/sprite_menu_facade.py: "Generation time" sub-menu removed (set_work_briefing_time gone), "Briefing settings…" → open_config_panorama(focus="work_briefing").
  • pet/locale/zh.json, en.json: menu.shared.briefing_settings, briefing.bubble.page_failed, panorama.ui.report_*; menu.shared.generation_time dropped.
  • Docs: docs/adr/0018-content-pages-move-to-the-browser.md (new, registered in the ADR index), docs/roadmap.md (M4b), docs/config-panorama.md (module table, "报告页" section), docs/work-assistant.md (module table, "窗口" section rewritten), CHANGELOG.md.
  • Tests: tests/test_panorama_markdown.py (9), tests/test_panorama_reports.py (8), tests/test_panorama_report_page.py (17: service, real local server routes incl. long-poll and action, render, report.js under QJSEngine), tests/test_work_briefing_page.py (7: controller browser path, Qt shell without the tab, menu, facade); updated test_work_briefing (menu), test_panorama_entry (registrations), test_panorama_page / test_panorama_settings_panel (bundle client.js with boot.js), test_panorama_service (fake server page_url(path)).
  • Deliberately untouched: notes / Slack pages and the personal assistant window (next steps in M4b); the Qt briefing window class itself (still used by the personal assistant and its tests).

Performance

Measured with PYTHONPATH=. python perf_c.py on this machine (Windows 11, venv Python, real latest briefing: 8592 chars / 64 lines):

Path Result
markdown.render of the real briefing, 200 runs median 0.28 ms, max 0.58 ms → 13131 chars HTML
provider + report_payload (full page data), 100 runs median 0.38 ms, max 223.74 ms (first run: lazy imports) → 16943 bytes
New static files report.js 4132 B · client.js 2528 B · report.css 3132 B · shell 760 B; boot.js 3675 B after the extraction
Panorama offline bundle 51494 B (was 50927 B: client.js is now included)
  • Steady state: zero. The provider runs only when a page asks or when a briefing starts/finishes and a page has asked before (publish_report without force is a no-op otherwise).
  • New paths: opening the briefing starts the same local server the panorama uses (no collection round, so no probes, no WSL call); one GET per page open, then one held long-poll per visible tab (same mechanism as the panorama page); one POST per "Regenerate" click.
  • Threads / syscalls: no new threads (the server's request threads already exist); no new disk writes (reports are not snapshotted); no network beyond 127.0.0.1.
  • Memory: one Feed per registered report holding the latest payload (~17 KB).

Real-machine run

  1. Standalone preview (read-only, separate from the running pet): serve_c.py built the real provider over the real data directory and served it with a real PanoramaServer; opened http://127.0.0.1:9546/report/work_briefing#<token> in the built-in browser. Checked from the page: hash cleared, data-theme=light (follows the user's appearance preference), title "工作简报 · 大肥鱼", six h3 sections (Jira / PR / Slack / 日程 / 邮件 / 建议先做), 37 star spans (5 × ★★★), 1 status chip, 54 target=_blank links, usage chips claude-opus-5-5 · high · 118 秒 · 407k · 12k · 1.25, "重新生成" enabled, no console errors. Content is company material and is not attached.
  2. Pet restarted from this branch (pid 44664, 19:49:05; log: both link channels report their hooks present, no ERROR). The user clicked the island's briefing button at 20:24: log shows 配置全景服务已启动:http://127.0.0.1:8271(空闲 900 秒后自停) with no panorama collection lines (no "Windows 一侧已发布" / WSL probe: open_report starts the server without a collection round), and the user confirmed the briefing page opened in the browser ("开出来了"). No ERROR / Traceback afterwards.

Tests

Red first: the new test files failed before the product change (ImportError: pet.panorama.markdown / reports, missing routes, WorkBriefingController rejecting open_report=). Then the affected families (panorama, work briefing, briefing window, notes / Slack UI, personal UI, context menus, i18n, architecture, PR discipline, retired features, settings table, desktop pet features, agent link, island): 1372 passed, after which the four remaining failures were fixed (two tests still bundling boot.js alone, the menu test expecting "Generation time", two known baselines compact_semantic_groups / three_column_masonry). ruff check and git diff --check clean. Full suite not run: no config schema or migration change, no packaging / platform dispatch change; the lifecycle change is one lazily built service plus two signal connections, covered by test_work_briefing_page.py and test_panorama_report_page.py.

Docs

  • CHANGELOG.md: one line (user-visible change)
  • Topic doc under docs/ updated (config-panorama.md, work-assistant.md, roadmap M4b)
  • ADR added under docs/adr/ (0018: content pages move to the browser; the Qt window is kept until the other pages move)

🤖 Generated with Claude Code

…「简报」页(ADR 0018)

- pet/panorama/reports.py:报告页的数据(work_briefing provider:最近一份 → 标题 / 概要 / 用量 / 全文 HTML / 忙 / 错 /
  按钮 / 有没有这项功能)、generate_work_briefing;markdown.py:零依赖的 Markdown → HTML(★ / bug 记号变类名、链接只认 http(s))
- service:reports 登记表、每份报告一个 Feed、report / publish_report(没人看过不白做)/ report_watched / open_report(起服务
  不采集);_page_target 拆出 _server_url
- routes:GET /report/<名字>(公开外壳)、GET /api/report/<名字>(要令牌,认 ?after=);actions.generate_report
- 页面:report.html / report.css / report.js;client.js 抽出取令牌与带令牌的 fetch,boot.js 改用它
- WorkBriefingController:open_report / report_watched 两条路——「查看」开浏览器、打开即读过、页面开着不冒提醒;
  WorkBriefingWindow(briefing_page=False) 只给笔记 / Slack 当壳
- app:_panorama() 懒建服务并登记 reports 与 generate_report;简报 started / finished → publish_report
- 菜单:「生成时间」子菜单拿掉,加「简报设置…」翻到配置全景(facade.open_work_briefing_settings)
- ADR 0018;路线图新增 M4b;docs/config-panorama「报告页」一节;docs/work-assistant「窗口」改写;CHANGELOG;字表

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant