Skip to content

Commit 13b03dd

Browse files
cliffhallclaude
andcommitted
Auto-read resource on sidebar click
Clicking a resource in the URIs accordion now triggers onReadResource in addition to setting the selection, so the preview panel jumps straight to the pending → ok render path. Removes the unreachable "Click to read this resource" placeholder, since the loader / preview / error states always cover the rendered output for a selected resource. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0110a06 commit 13b03dd

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

clients/web/src/components/screens/ResourcesScreen/ResourcesScreen.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ describe("ResourcesScreen", () => {
114114
).toBeInTheDocument();
115115
});
116116

117-
it("renders empty state when a resource is selected but no readState", async () => {
117+
it("auto-reads when a resource is clicked in the sidebar", async () => {
118118
const user = userEvent.setup();
119-
renderWithMantine(<ResourcesScreen {...baseProps} />);
119+
const onReadResource = vi.fn();
120+
renderWithMantine(
121+
<ResourcesScreen {...baseProps} onReadResource={onReadResource} />,
122+
);
120123
await user.click(screen.getByText("x.txt"));
121-
expect(screen.getByText("Click to read this resource")).toBeInTheDocument();
124+
expect(onReadResource).toHaveBeenCalledWith("file:///x");
122125
});
123126

124127
it("forwards refresh and subscribe events from the preview panel", async () => {

clients/web/src/components/screens/ResourcesScreen/ResourcesScreen.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function ResourcesScreen({
107107
function handleSelectResource(uri: string) {
108108
setSelectedTemplateUri(undefined);
109109
setSelectedResourceUri(uri);
110+
onReadResource(uri);
110111
}
111112

112113
function handleSelectTemplate(uriTemplate: string) {
@@ -201,11 +202,7 @@ export function ResourcesScreen({
201202
</Group>
202203
) : selectedResource ? (
203204
<ScrollArea.Autosize flex={1} mah={SCROLL_MAX_HEIGHT}>
204-
{renderReadState() ?? (
205-
<DetailCard>
206-
<EmptyState>Click to read this resource</EmptyState>
207-
</DetailCard>
208-
)}
205+
{renderReadState()}
209206
</ScrollArea.Autosize>
210207
) : (
211208
<DetailCard flex={1}>

0 commit comments

Comments
 (0)