Skip to content

fix(webapp): unwrap the {items} envelope for kb.list_* results#555

Closed
plind-junior wants to merge 1 commit into
testfrom
fix/webapp-list-envelope
Closed

fix(webapp): unwrap the {items} envelope for kb.list_* results#555
plind-junior wants to merge 1 commit into
testfrom
fix/webapp-list-envelope

Conversation

@plind-junior

@plind-junior plind-junior commented Jul 24, 2026

Copy link
Copy Markdown
Member

the pending page (and every list view) was crashing the whole tree through the error boundary with TypeError: r.data.map is not a function.

root cause: kb.list_* results moved from a bare array to a {items, _meta} dict envelope (server deprecation, remove_in 1.4.0), but the webapp still typed and consumed them as flat arrays. Shell.tsx and PendingView.tsx call r.data.map(...) on the fan-out rows, so a {items, _meta} payload has no .map and throws — and since Shell renders on every route, the error boundary swallows the entire app, not just the pending queue. the kb.list_sessions sibling right above was already defensive (r.data?.sessions ?? []), which is why it never surfaced there.

fix: unwrap items once in rpc(), scoped to kb.list_* methods, tolerating the old bare-array shape and leaving kb.list_sessions ({sessions}) and non-list object results untouched. one central change repairs the pending page and any list view; the fan-out, optimistic caches, and views are unaffected.

verified live against a running vouch serve (kb.list_pending returns {items, _meta}): the pending page renders, the sidebar counts populate, zero console errors. tests add four rpc() cases (unwrap list envelope, pass bare array through, leave {sessions} alone, don't unwrap non-list methods). full webapp suite green (153), tsc clean.

Summary by CodeRabbit

  • Bug Fixes

    • Improved compatibility with older server responses for knowledge-base list requests.
    • List results are now handled consistently while preserving session-list response details.
    • Non-list operations continue to return their responses unchanged.
  • Tests

    • Added coverage for legacy list responses, current response formats, session lists, and non-list methods.

kb.list_* moved from a bare array to a `{items, _meta}` dict envelope
(server deprecation, remove_in 1.4.0), but the webapp still typed and
consumed these as flat arrays — so `r.data.map` in Shell and PendingView
threw "map is not a function", crashing the whole tree through the error
boundary on every page, the pending queue included.

unwrap `items` once in rpc(), scoped to kb.list_* methods, tolerating the
old bare-array shape and leaving kb.list_sessions ({sessions}) and non-list
object results untouched. one central change fixes the pending page and
every list view; the fan-out, optimistic caches, and views are unaffected.
@github-actions

Copy link
Copy Markdown

this PR changes UI (web/, src/vouch/web/, or webapp/) but has no before/after screenshots in the description. UI changes are reviewed by screenshot, not by running the app. add before and after screenshots, then reopen.

@github-actions github-actions Bot closed this Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2983c5b2-e87a-4eb0-9695-2788e119910c

📥 Commits

Reviewing files that changed from the base of the PR and between 40c9df0 and 89a5de9.

📒 Files selected for processing (2)
  • webapp/src/lib/rpc.test.ts
  • webapp/src/lib/rpc.ts

Walkthrough

rpc() now unwraps legacy { items } results for kb.list_* methods while preserving bare arrays and other response envelopes. Tests cover supported list responses, kb.list_sessions, and non-list methods.

Changes

RPC list response compatibility

Layer / File(s) Summary
List envelope handling and coverage
webapp/src/lib/rpc.ts, webapp/src/lib/rpc.test.ts
rpc() unwraps legacy { items } envelopes for kb.list_* methods and preserves other result shapes, with tests covering arrays, sessions, and non-list methods.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ 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 fix/webapp-list-envelope

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.

@github-actions github-actions Bot added the size: XS less than 50 changed non-doc lines label Jul 24, 2026
@github-actions

Copy link
Copy Markdown

this PR changes UI (web/, src/vouch/web/, or webapp/) but has no before/after screenshots in the description. UI changes are reviewed by screenshot, not by running the app. add before and after screenshots, then reopen.

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

Labels

size: XS less than 50 changed non-doc lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant