Skip to content

WSI research assistant in the viewer package - #20

Open
raylim wants to merge 34 commits into
codex/wsi-rd-annotationsfrom
codex/wsi-rd-agent
Open

raylim wants to merge 34 commits into
codex/wsi-rd-annotationsfrom
codex/wsi-rd-agent

Conversation

@raylim

@raylim raylim commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Fork follow-up stacked on codex/wsi-rd-annotations (#19). It adds a research assistant panel to the viewer that proposes annotations and viewer actions for the user to approve.

Behavior

  • A Research assistant sidebar section sends chat messages to the annotation service's /agent/chat and streams the reply (server-sent events).
  • The request carries the current slide, its viewport and an embedding context.
  • The assistant returns proposals:
    • create, batch-create, update or delete annotations;
    • viewer actions: select a slide, go to coordinates, zoom.
  • Pending annotation proposals are drawn as an overlay on the slide.
  • Each proposal can be approved or rejected.
    • Approved annotations are saved through commit-annotations and appear in the annotation list.
    • Approved viewer actions run in the viewer. Selecting a slide reports back whether its first tile became ready, it failed, or it was cancelled.
  • Proposals are tied to the slide key and tile-pyramid shape, so they are not applied to a different slide.
  • The assistant only ever sees the opaque slide key, never an image id or path.

Service calls and auth

The assistant uses the same service, proxy and request rules as the annotations in #19 (wsiServiceRequest.ts): the portal session cookie (credentials: 'include'), no token, studyId exactly once in the query string, and X-Requested-With: XMLHttpRequest plus Content-Type: application/json on writes.

Request Use
POST {url}/agent/chat?studyId=… A chat turn, streamed back; proposals arrive in the stream
POST {url}/agent/actions/{id}/commit-annotations?studyId=… Save an annotation proposal
POST {url}/agent/actions/{id}/apply?studyId=…, then …/complete?studyId=… Approve a viewer proposal, then report its result
POST {url}/agent/actions/{id}/reject?studyId=… Reject a proposal

A 401 ("Sign in to use the research assistant.") or 403 (no access to this study) is shown in the panel, which then disables its input, Apply/Reject and auto-approve and sends nothing more until the study changes. Neither is retried.

Config

  • Enabled by wsi_agent_enabled (default false): the panel stays hidden unless it is true.
  • Shown only when the annotation service (wsi_annotation_api_url) is also configured.

Backend dependencies

Tests

  • WsiAgentPanel.spec.tsx: chat, commit, apply, complete and reject each send studyId once, the cookie, the CSRF header and no Authorization; after a 401 or 403 the panel sends nothing more for the study and disables pending proposals.
  • Mocked Playwright spec wsi-annotation-agent.spec.ts: checks the same request contract in the browser.

🤖 Generated with Claude Code

raylim added a commit that referenced this pull request Oct 8, 2026
Rebuilt on codex/wsi-viewer-package (slide timing out, clinical section,
patient tab URL scoping) with the updated children: study #17, molecular
#18, agent #20 (with annotations #19) and study slides #23. #21 is closed:
its patient-tab URL scoping is now in the base and its slide timeline moved
to #28, so the timeline files, timing fields and mock routes it brought in
are left out. The previous head is kept as a parent so the update is a
fast-forward; this commit keeps the rebuilt tree.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 12, 2026
raylim added a commit that referenced this pull request Oct 13, 2026
Molecular (#18) and annotations/agent (#19/#20) both add to the viewer,
controller host, sidebar, runtime config and light entry; keep both, as
the previous integration did.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 13, 2026
Merges the updated children: #17 b56bec1, #18 ff6ea53, #20 64712b9
(with #19 0b5a959) and #23 35c00aa (with #27 46d3dcb), all on
cBioPortal#5732 e90d380. The tree is the children merged onto each other (second
parent); the previous integration head stays the first parent so the
push fast-forwards.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim
raylim added this pull request to stack #31 October 14, 2026 17:09
Squash of #20 onto the rebased #19 after resource table v2 merged upstream.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim
raylim force-pushed the codex/wsi-rd-agent branch from 4030a75 to d81dab9 Compare October 15, 2026 21:12
raylim added a commit that referenced this pull request Oct 15, 2026
…rge target)

Rebuilt from the rebased cBioPortal#5732 (44b68b8) by merging #17 (30456c9),
#18 (643d044), #20 (d81dab9, includes #19) and #23 (008ce69).

Squash of #22 onto the rebased cBioPortal#5732 after resource table v2 merged upstream.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…er_url rename)

# Conflicts:
#	end-to-end-test-playwright/tests/wsi-foundation-mocks.ts
raylim added a commit that referenced this pull request Oct 15, 2026
…ration

#17 5304083, #18 704a81c, #20 be9a529 (with #19), #23 8f4a2bb.
The integration tree already matched them; this records the parents.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 7 commits October 16, 2026 20:07
…keys)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	packages/cbioportal-wsi-viewer/src/WSIViewer.tsx
# Conflicts:
#	packages/cbioportal-wsi-viewer/src/WSIViewer.tsx
#	packages/cbioportal-wsi-viewer/src/wsiViewerController.ts
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 22, 2026
…wer base 3857131)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…shed Slide ID) into codex/wsi-rd-agent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 22, 2026
…wer base 72bd40f)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…to codex/wsi-rd-agent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 22, 2026
…wer base f26f4e8)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…I- Slide ID) into codex/wsi-rd-agent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 22, 2026
…wer base 9f86f50)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 14 commits October 27, 2026 14:12
# Conflicts:
#	end-to-end-test-playwright/tests/wsi-foundation-mocks.ts
#	packages/cbioportal-wsi-viewer/src/wsiAuth.spec.ts
…abled

The backend properties are now wsi.annotation_api.url and wsi.agent.enabled
(raylim/cbioportal#9).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
402cdc5: Show all slides only when it changes the list)

# Conflicts:
#	packages/cbioportal-wsi-viewer/src/WSIViewer.foundation.spec.tsx
…: tile requests by key and sealed source, no token)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…: thumbnails without tw/th, ingress-only 401/403, registry generation)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim raylim added the enhancement New feature or request label Nov 3, 2026
raylim and others added 2 commits November 5, 2026 11:47
…after cBioPortal#5732 squash-merged as 8052359)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…end master) into codex/wsi-rd-agent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim
raylim removed this pull request from stack #31 November 12, 2026 18:21
@raylim
raylim added this pull request to stack #37 November 12, 2026 18:22
raylim and others added 3 commits November 12, 2026 17:03
…service) into codex/wsi-rd-agent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… a token

The assistant routes sit behind the same cookie-authenticating proxy as
the annotation service, so the panel uses wsiServiceRequest like the
annotations do.

- WsiAgentPanel: chat, commit-annotations, apply, complete and reject send
  credentials: 'include', studyId once in the query and
  X-Requested-With: XMLHttpRequest, with no Authorization header. The
  getToken prop becomes studyId; agentEndpoint is removed.
- A 401 or 403 shows why in the panel, disables the input, the proposal
  buttons and auto-approve, and stops requests until the study changes.
- WSIViewer: no agent token callback.
- Playwright: no access-token mock; asserts studyId, the CSRF header and
  no Authorization on every annotation and assistant request.
- README: documents the assistant routes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Nov 12, 2026
)

This merge takes its tree entirely from deploy/wsi-rd-children-20261112
(dd19c06), the second parent:
- codex/wsi-study-slide-facets-ui (#29, 7e493f7; stacked on #23 and #27)
- codex/wsi-rd-study (#17, 0c999a1)
- codex/wsi-rd-molecular (#18, ce690cf)
- codex/wsi-summary-timeline (#28, 406f52b)

The annotation (#19) and research assistant (#20) branches merged earlier
are not part of the result. The first parent keeps the branch's earlier
history, so the push is a fast-forward.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant