Skip to content

fix(web): conclusion knowledge search with target discovery and correct size pagination - #107

Open
Poxel2 wants to merge 1 commit into
offendingcommit:mainfrom
Poxel2:upstream/viewer-fixes
Open

Poxel2 wants to merge 1 commit into
offendingcommit:mainfrom
Poxel2:upstream/viewer-fixes

Conversation

@Poxel2

@Poxel2 Poxel2 commented Sep 17, 2026

Copy link
Copy Markdown

Description

Fixes peer-level knowledge search in the web viewer and corrects list pagination across the UI.

Peer knowledge search always returned nothing

The peer page's conclusion search self-scoped the query to observed = <the peer itself>. The conclusions/query endpoint requires both filters.observer and filters.observed, but a peer that holds knowledge about other peers holds nothing about itself — so the self-scoped query was a guaranteed zero rows for exactly the peers where knowledge search matters most.

This PR:

  • Adds useConclusionTargetPeers, which walks conclusions/list with an observer_id filter and collects the distinct observed_id values (with row counts) from real stored conclusions. Returns { targets, complete }; complete is false when the walk hit the page cap, so a truncated result is never presented as the full target list.
  • Adds a target <select> to the peer page knowledge panel, populated from those discovered targets (masked ids, with counts). A single target from a complete walk is auto-selected; a truncated walk never auto-selects — the user picks explicitly. An explicit user choice always wins over auto-select.
  • Removes the implicit self-scope fallback in useQueryPeerConclusions; the query is never fired without a concrete observed target (the server requires both filters).
  • Per-peer target state resets when the viewed workspace or peer changes, so a stale target can't silently scope the search wrong.
  • Discovery errors are surfaced in the panel and in the picker option state instead of rendering an endless "loading targets…".
  • Result rows keep observer→observed, session and timestamp provenance. Identical contents are deduplicated for display only (with a hidden-duplicate count); no data operations.

Pagination used the wrong query parameter

The list endpoints take page and size, but the UI sent page_size everywhere. The server silently ignores page_size and falls back to 50 items per page, so pages beyond the first were never reachable from the UI. All call sites now send size (workspaces, peers, peer sessions, sessions, session messages, conclusions list, dreams, compare views, seed kits, instance discovery).

Testing

  • pnpm --filter @openconcho/web test — 122 tests pass, including a new conclusion-targets.test.tsx suite covering: target collection with counts, multi-page walks, complete=false on a cap-truncated walk (40 requests, no walk past the cap), the exact page-count boundary (complete=true when the last walked page is the reported page count), error propagation, the empty-store case, and count/id sort order.
  • pnpm --filter @openconcho/web typecheck — clean.
  • pnpm --filter @openconcho/web lint — clean (biome, 125 files).
  • pnpm --filter @openconcho/web build — succeeds.

Reproduction

  1. Open a peer that holds conclusions about other peers and use the knowledge search on the peer page → previously zero results regardless of query; now the observed target is discovered from the peer's actual conclusions and results appear.
  2. List any collection with more than 50 items → previously only the first 50 were reachable; now paging works.

…ct size pagination

Peer page: add a clearly separated 'Search peer knowledge (conclusions)'
panel querying /conclusions/query scoped to observer=peer, with an
observed-peer target discovered from the conclusions the peer actually
holds, plus observer→observed, session and timestamp provenance on each
result. Message search is unchanged.

- useConclusionTargetPeers: walk conclusions/list (paginated) with an
  observer_id filter and collect distinct observed_id values with row
  counts. Returns { targets, complete }; complete is false when the walk
  hit the page cap, so a truncated result is never reported as complete
  and a single target from a truncated walk is not auto-selected.
- PeerDetail: target <select> over discovered targets (masked, with
  counts); auto-select only when exactly one target exists AND discovery
  is complete; scope badge shows the selected target; per-peer target
  state resets when the viewed workspace or peer changes; discovery
  errors are surfaced in the panel and picker instead of hanging in a
  loading state.
- useQueryPeerConclusions: no implicit self-scope fallback — the server
  requires both observer and observed filters and self-scoping yielded
  guaranteed-zero rows; the target must be resolved by the caller.
- Display-only dedup of identical result contents with a hidden-
  duplicate count; provenance preserved; purely presentational.
- Pagination: send the server's actual 'size' query param everywhere the
  UI previously sent 'page_size' (workspaces, peers, peer sessions,
  sessions, session messages, conclusions list, dreams, compare views,
  seed kits, instance discovery). The server silently ignored
  'page_size', falling back to 50 items per page.
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