Skip to content

fix: repair session detail history and source links - #33

Closed
ZeroPointSix wants to merge 2 commits into
mainfrom
fix/zer-669-session-detail
Closed

fix: repair session detail history and source links#33
ZeroPointSix wants to merge 2 commits into
mainfrom
fix/zer-669-session-detail

Conversation

@ZeroPointSix

@ZeroPointSix ZeroPointSix commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replay session events from zero on a fresh admin-page SSE connection while preserving in-page reconnection cursors.
  • Persist and backfill real Slack and Discord source permalinks, distinguish copying the Plus session link from returning to the platform source, and ensure a parent-channel Discord message records the created thread URL.
  • Centralize user-facing session status labels, filters, colors, and metric semantics so exited is displayed as 已完成 and is not counted as a failure.

Closes ZER-669.

Discord Discussion URL: Not available; the implementation scope is tracked in Linear ticket ZER-669 and this PR's review thread.

Review Contract

Goal

Ensure an administrator who opens a session detail page can recover the available history, accurately return to the originating Slack or Discord conversation, and see one consistent status vocabulary across details, filters, lists, and overview metrics.

Non-goals

This PR does not introduce durable, cross-restart event archival; redesign Discord thread creation; alter session lifecycle semantics; or reconcile the unrelated overlapping changes in PR #32.

Accepted Residual Risks

The in-memory SessionEventBus retains a bounded history (default 1,000 events). A fresh page can therefore replay only the retained suffix after an overflow, while the UI renders its latest 60 timeline entries. Operators can reload and inspect the latest session snapshot, but full historical recovery requires a future durable event store. This trade-off requires maintainer approval before merge.

Acceptance Criteria

  • A fresh admin-page SSE connection requests replay from sequence zero and merges replayed events into the relevant detail timeline.
  • Slack and Discord sessions retain a real platform permalink; when Discord creates a thread from a parent-channel message, the stored link opens the created thread rather than the parent message.
  • idle and exited are displayed as 等待中 and 已完成 everywhere users can select or view a status; only error increments the failure metric.
  • Frontend type checking, frontend unit tests, frontend production build, and targeted Discord permalink tests pass.

Follow-ups

Add durable event retention with explicit overflow visibility, and rebase or regenerate the overlapping web assets in PR #32 after this PR merges.

Validation

  • pnpm --dir web lint
  • pnpm --dir web test
  • pnpm --dir web build
  • cargo test -p openab-core --no-default-features --features discord,slack 'discord::tests::session_permalink'
  • git diff --check

@linear-code

linear-code Bot commented Aug 12, 2026

Copy link
Copy Markdown

ZER-669

ZeroPointSix commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

Context fact card(三审)

Target

  • 仓库:ZeroPointSix/openab-plus
  • PR:fix: repair session detail history and source links #33 fix: repair session detail history and source links
  • 关联:ZER-669
  • Base:main
  • Head:42293292e1d1446870cca9341f8f4042ed899831
  • 本轮相对二审 head 807c5a7… 新增 1 个修复 commit:fix: address session status and thread review feedback

Verified facts

  • PR 仍 open / non-draft / mergeable,当前相对 main ahead 2 / behind 0。
  • 二审的两个代码 blocker 已修复:
    1. 状态展示、筛选与 metrics 统一从 sessionStatusDisplay / sessionStatusOptions 派生;exited → 已完成failed: false,不会再计入失败数。
    2. Discord 父频道消息创建新 thread 后,不再保存原父消息 msg.link()discord_session_permalink() 会生成实际 thread channel URL。已在线程内或 DM 的消息仍保留原 message permalink。
  • Review Contract 已补齐,并明确记录 fresh replay 在全局 1000-event history overflow 后只能恢复 retained suffix 的 residual risk。
  • 仍维持一条 Admin SSE;fresh page 从 sequence 0 replay、页内重连保留 cursor 的实现没有被本轮修复改动破坏。

Relevant code and tests

  • web/src/lib/format.ts:集中维护 label / color / active / running / failed 语义,并导出 sessionStatusOptions
  • web/src/lib/session.tssessionMetrics() 从同一 mapping 计算 active/running/failed。
  • OverviewPage.tsx / SessionTable.tsx:筛选与 valueEnum 均使用 sessionStatusOptionsStatusTag / SessionDetailPage 继续使用 sessionStatusDisplay
  • discord.rs:新增 discord_session_permalink(),覆盖“父频道消息 → 新 thread”与“已在 thread 内”两条分支。
  • session.test.ts 新增 exited 状态一致性测试;Discord 新增两个 permalink 单测。
  • 主 CI 日志确认 discord::tests::session_permalink_targets_new_thread_instead_of_parent_messagesession_permalink_preserves_message_link_inside_existing_thread 均实际执行并通过。

CI/CD and validation entrypoints

  • Admin Web:success。
  • CI:success;cargo check、workspace clippy、unified clippy、workspace tests、ACP gateway tests、unified build 全部通过。
  • cargo test --workspace:core 779 tests 全过;gateway 281 tests 全过;相关 Discord permalink 测试实际执行成功。
  • Docker Smoke Test:success。
  • Docker Smoke Test (Unified):success。
  • exact-head Review Contract:success。

Assumptions not allowed

Risks / blockers

Proposed change scope

  • 本轮无额外代码修改建议;从代码审查角度已具备合并条件。
  • 合并前由 maintainer 明确接受 Review Contract 中的 bounded-history residual risk。

Execution summary

Problem

  • 二审阻塞为状态语义不一致、Discord 新建 thread permalink 指向父消息,以及 Review Contract/CI 未完成。

Root cause / verified facts

  • 新 commit 已把状态展示与 metrics 收口到一个 mapping,并针对 exited 补回归测试。
  • Discord 新建 thread 路径现基于实际 thread_channel.channel_id 生成 source URL;原 thread/DM 路径仍保留 canonical message URL。
  • 相关 Rust 单测在 exact-head 主 CI 中实际执行并通过。

Solution

  • 二审提出的代码与流程问题均已处理。

Files changed

  • 本次仅三审,无代码修改。

Validation

  • Admin Web:success。
  • CI:success。
  • Docker Smoke:success。
  • Unified Docker Smoke:success。
  • Review Contract:success。

CI/CD

  • exact-head 42293292e1d1446870cca9341f8f4042ed899831 当前所有已发现检查均为 green。

Remaining risks / follow-ups

三审结论:代码层面建议合并 / 无新增 blocker;合并前请 maintainer 明确接受 Review Contract 中的 bounded-history residual risk。

@ZeroPointSix

Copy link
Copy Markdown
Owner Author

已由 #46 的干净 ZER-404 W1–W5 只读工作台整合替代。#46 从最新 main 按依赖顺序重建,保留本 PR 的有效能力并补齐跨包冲突、活动流接线、恢复链与最新回归修复;原分支保留供历史追溯。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant