feat(web): expandable resource_link with read-on-demand (#1449)#1456
Open
cliffhall wants to merge 2 commits into
Open
feat(web): expandable resource_link with read-on-demand (#1449)#1456cliffhall wants to merge 2 commits into
cliffhall wants to merge 2 commits into
Conversation
Replace the placeholder `resource_link` rendering in ContentViewer with a dedicated, Mantine-native `ResourceLink` element that mirrors V1's behavior: - Shows uri (monospace, link-styled), optional name/description, and a mimeType badge. - Expand/collapse affordance (chevron + loading spinner) that is keyboard accessible (native button: role, aria-expanded, aria-label, Enter/Space). - On first expand, reads the linked resource on demand via an injected callback and renders the full read result inline as formatted JSON under a green "Resource:" label, capped to a max height with scroll for large results. The fetched result is cached across collapse/expand. The read handler is threaded as a "dumb component + callback as prop" through ToolResultPanel → ToolsScreen → InspectorView, with App supplying a handler that returns the `ReadResourceResult` from `inspectorClient.readResource`. Also extract the shared `resourceContentsToBlock` helper into `utils/resourceContents.ts` (previously private to ResourcePreviewPanel). Tests: unit coverage for ResourceLink (collapsed/expanded/error/cache) and the ContentViewer wiring, plus Storybook stories with play functions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A plain ScrollArea with only `mah` does not scroll when its parent (the content-sized card) has no definite height, so a large read result overflowed the card instead of scrolling. Switch to ScrollArea.Autosize, which grows with content up to the max height and then scrolls. Adds a LargeResult story covering the bounded-scroll behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1449
Summary
Replaces V2's placeholder
resource_linkrendering with a dedicated, Mantine-nativeResourceLinkelement that brings V1's interactive, expandable, click-to-read experience to V2.Behavior
role,aria-expanded,aria-label, and Enter/Space handling.The matching V1 layout (uri / name / description / mime badge / green "Resource:" label / scrollable JSON):
Wiring
Follows the V2 "dumb component + callbacks as props" pattern. The read handler is threaded
App → InspectorView → ToolsScreen → ToolResultPanel → ContentViewer → ResourceLink.Appsupplies a handler returning theReadResourceResultfrominspectorClient.readResource(uri).Refactor
Extracts the shared
resourceContentsToBlockhelper intoutils/resourceContents.ts(previously private toResourcePreviewPanel).Testing
ResourceLink(collapsed/expanded/error/cache/non-interactive),resourceContents, and theContentViewerresource_link wiring.playfunctions forResourceLinkandContentViewer.npm run validate,npm run test:integration(522), andnpm run test:storybook(345) all pass.🤖 Generated with Claude Code