Skip to content

feat(webui): memory panel with recall hits and accepted memories - #679

Merged
delete-cloud merged 1 commit into
mainfrom
feat/webui-memory-panel
Jul 24, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
feat/webui-memory-panel

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

改动

服务端:turn 的 context pack 经 ctx.config 上的 contributor-keyed stash(semantic_memory + kb 两个插件各自写入,顺序无关)在 turn 完成时由 RuntimeTurnFinalizer 沿现有 finish 链写入 run.metadata["context_pack"]。shape 与 developer console 的 _context_summary_from_run 已有解析逻辑完全一致,所以 /console/context 页面也同时点亮。recall 命中由此可通过 GET /sessions/{id}/runs 读取。

前端:新增 MemoryPanel 组件 —— recall 命中表(score + similarity/overlap 徽标)+ accepted memories 列表(复用已在线的 GET /sessions/{id}/memory/reviews?status=accepted),session 选中时和 turn 完成后拉取。

文档:web-client-api-contract.md 补上 4 个已存在的 /memory/* 端点和 run metadata 的 context_pack shape。

测试

  • tests/coding_agent/ + test_developer_console.py:1654 passed
  • webui vitest:20 passed(含 6 个新 MemoryPanel 测试)
  • ruff check/format 干净;PM-0017 release checks 32 passed

Summary by CodeRabbit

  • New Features

    • Added a Memory Review panel showing recall hits, accepted memories, scores, confidence, and tags.
    • Memory information now refreshes automatically after session activity and history updates.
    • Agent run metadata now preserves context-pack details for later inspection.
    • Added client support for retrieving memory review records.
  • Documentation

    • Documented memory review APIs, semantic-memory maintenance operations, and context-pack run metadata.

Server: persist each turn's context pack into run.metadata["context_pack"]
via a contributor-keyed stash on ctx.config (semantic_memory + kb),
copied into run metadata by RuntimeTurnFinalizer through the existing
finish chain. The shape matches what the developer console's
_context_summary_from_run already parses, so /console/context lights up
too. Recall hits become readable over GET /sessions/{id}/runs.

Frontend: new MemoryPanel component (recall-hits table with score +
similarity/overlap badge, accepted-memories list from the existing
GET /sessions/{id}/memory/reviews?status=accepted endpoint), fetched on
session select and after turn completion.

Docs: web-client-api-contract.md gains the four /memory/* endpoints and
the run metadata context_pack shape.

Tests: 80 focused python tests + 20 vitest (6 new MemoryPanel tests)
pass; full tests/coding_agent + developer_console suite 1654 passed.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Memory context flow

Layer / File(s) Summary
Context pack production and stash
coding-agent/src/coding_agent/topics/context_pack.py, coding-agent/src/coding_agent/plugins/{kb,semantic_memory}.py, coding-agent/tests/coding_agent/plugins/*
Retrieval plugins stash structured context packs, preserve cached KB packs, clear stale contributions, and validate these behaviors in tests.
Run metadata persistence
coding-agent/src/coding_agent/runs/{lifecycle,persistence}.py, coding-agent/tests/coding_agent/test_run_lifecycle.py
Turn finalization merges stashed context packs into run metadata and forwards optional metadata through persistence and lifecycle calls.
Web memory review and context display
coding-agent/webui/app/src/{lib/*,components/*,App.tsx}, coding-agent/docs/web-client-api-contract.md
The web client loads runs and memory reviews, extracts context-pack hits, renders memory data, and documents the related REST and metadata contracts.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant AgentClient
  participant MemoryPanel
  App->>AgentClient: load runs and accepted memory reviews
  AgentClient-->>App: return runtime runs and memory review records
  App->>MemoryPanel: render recall hits and accepted memories
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main web UI change: a memory panel showing recall hits and accepted memories.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/webui-memory-panel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
coding-agent/webui/app/src/lib/types.ts (1)

181-191: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

ContextPackItem type/rendering drops KB citation location fields (repo_path, line_start, line_end). The backend ContextPackItem dataclass includes these optional fields and the KB plugin populates them for repo/test-failure references, but the frontend type doesn't model them and the panel never renders them — so recall hits for KB citations lose their file/line context in the UI.

  • coding-agent/webui/app/src/lib/types.ts#L181-L191: add repo_path?: string | null, line_start?: number | null, line_end?: number | null to ContextPackItem to match the backend to_dict() shape.
  • coding-agent/webui/app/src/components/MemoryPanel.tsx#L52-L69: once typed, render repo_path/line_start-line_end (e.g. alongside source_kind) for KB-sourced hits.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/webui/app/src/lib/types.ts` around lines 181 - 191, Add optional
repo_path, line_start, and line_end fields to the ContextPackItem interface in
coding-agent/webui/app/src/lib/types.ts:181-191, matching the backend nullable
types. Update the KB-hit rendering in
coding-agent/webui/app/src/components/MemoryPanel.tsx:52-69 to display the
repository path and line range alongside source_kind when citation fields are
present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@coding-agent/webui/app/src/App.tsx`:
- Around line 140-156: Update refreshMemory to use a sequence counter, following
the existing loadSeqRef pattern used by newSession/loadSession. Increment and
capture the counter for each refresh, then require both the captured sequence
and activeSessionRef.current to match before applying success or error state,
preventing stale same-session responses from overwriting newer results.

---

Nitpick comments:
In `@coding-agent/webui/app/src/lib/types.ts`:
- Around line 181-191: Add optional repo_path, line_start, and line_end fields
to the ContextPackItem interface in
coding-agent/webui/app/src/lib/types.ts:181-191, matching the backend nullable
types. Update the KB-hit rendering in
coding-agent/webui/app/src/components/MemoryPanel.tsx:52-69 to display the
repository path and line range alongside source_kind when citation fields are
present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 42d8fdb3-12bd-43b9-b692-0aa226fd79b9

📥 Commits

Reviewing files that changed from the base of the PR and between f3a5396 and 263d331.

📒 Files selected for processing (14)
  • coding-agent/docs/web-client-api-contract.md
  • coding-agent/src/coding_agent/plugins/kb.py
  • coding-agent/src/coding_agent/plugins/semantic_memory.py
  • coding-agent/src/coding_agent/runs/lifecycle.py
  • coding-agent/src/coding_agent/runs/persistence.py
  • coding-agent/src/coding_agent/topics/context_pack.py
  • coding-agent/tests/coding_agent/plugins/test_kb_plugin.py
  • coding-agent/tests/coding_agent/plugins/test_semantic_memory.py
  • coding-agent/tests/coding_agent/test_run_lifecycle.py
  • coding-agent/webui/app/src/App.tsx
  • coding-agent/webui/app/src/components/MemoryPanel.test.tsx
  • coding-agent/webui/app/src/components/MemoryPanel.tsx
  • coding-agent/webui/app/src/lib/api.ts
  • coding-agent/webui/app/src/lib/types.ts

Comment thread coding-agent/webui/app/src/App.tsx Resolved
@delete-cloud
delete-cloud merged commit 013e880 into main Jul 24, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/webui-memory-panel branch July 24, 2026 14:08
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