Skip to content

fix(native): show the read verdict in the FileViewerHost body with a Retry button - #2

Merged
edgar-durand merged 1 commit into
mainfrom
fix/native-fileviewer-error-retry
Sep 8, 2026
Merged

edgar-durand merged 1 commit into
mainfrom
fix/native-fileviewer-error-retry

Conversation

@edgar-durand

Copy link
Copy Markdown
Collaborator

Problem

packages/native/src/components/FileViewerHost.tsx rendered the body as

{loading || html === null ? ( <ActivityIndicator … /> "Fetching {path}…" )

After fetcher.read returned { error } the host set error (top bar) but content stayed null, so the spinner kept spinning under the message and there was no Retry — only close/reopen. The consumer (codeagent-mobile #2822) now returns liveness-aware verdicts as that error string ("This session isn't responding — is it online?"), which made the dead-end visible.

Fix

  • On a read failure the body renders the verdict (alert icon + centered text) with a Retry button that re-runs fetcher.read for the same request (readAttempt counter in the read effect's deps). While the retry is in flight the normal "Fetching …" state shows again.
  • The top error bar is now reserved for failures on top of a displayed file (save, editor bridge) — error && html !== null — so the same message is never shown twice.
  • The !fetcher "No active session" branch was unreachable behind the spinner condition; it is checked first now.

Styling reuses the file's existing chrome constants (#a78bfa button, #fecaca error text, placeholder layout).

Tests

First component spec in @codeam/ide-native: real render through react-dom into jsdom, RN primitives replaced by thin DOM stubs (src/test/setup.tsx, vitest.config.ts); the WebView stub exposes its bridge so the save path is exercised like Cmd+S.

npm run test --workspace @codeam/ide-native -- src/components/FileViewerHost.test.tsx → 4 passed (RED on main: 3 failed / 1 passed). npm run typecheck and npm run lint clean.

New dev deps: jsdom (root), react-dom (native devDependencies, matches web).

Refs bead codeagent-rtbh.

🤖 Generated with Claude Code

…Retry button

After `fetcher.read` returned `{ error }` the host set the top error bar but
`content` stayed `null`, so `loading || html === null` kept the "Fetching …"
spinner drawing under the message and the only way out was close/reopen.

- On a read failure the body now renders the fetcher's verdict (e.g. the
  liveness-aware "This session isn't responding — is it online?") with a
  Retry button that re-runs `fetcher.read` for the same request; while the
  retry is in flight the normal loading state shows again.
- The top error bar is reserved for failures on top of a displayed file
  (save, editor bridge), so the same message is never shown twice.
- The `!fetcher` "No active session" branch was unreachable behind the
  spinner condition; it is checked first now.

Adds the first component spec in @codeam/ide-native: react-dom into jsdom
with thin DOM stubs for the RN primitives (`src/test/setup.tsx`), driven
through the real `FileViewerProvider`.

Refs: codeagent-rtbh
@edgar-durand
edgar-durand merged commit 673d3b8 into main Sep 8, 2026
3 checks passed
@edgar-durand
edgar-durand deleted the fix/native-fileviewer-error-retry branch September 8, 2026 12:29
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.

2 participants