Skip to content

fix(desktop): board auto-retry on server startup#30

Merged
siracusa5 merged 4 commits intomainfrom
fix/board-server-ready-retry
Mar 16, 2026
Merged

fix(desktop): board auto-retry on server startup#30
siracusa5 merged 4 commits intomainfrom
fix/board-server-ready-retry

Conversation

@siracusa5
Copy link
Copy Markdown
Collaborator

Summary

When running dev:desktop, the board-server starts in the background and there's a race condition: the React frontend loads before the server is ready on :4800. Previously, a single failed HTTP request would show a static error forever ("Could not connect to board server" / "Is the board server running on :4800?"). This PR makes the board pages resilient by polling for server readiness before attempting data fetches.

Changes

  • useBoardServerReady.ts (new hook) — polls GET /health every 2s until the server responds, then stops. Cleans up the interval on unmount.
  • useBoardData.ts — accepts a ready boolean param (default true for backwards compat); skips the initial fetch until ready.
  • BoardProjectsPage.tsx — uses useBoardServerReady, gates api.projects.list() on ready, shows "Connecting to board server..." during startup instead of a static error.
  • BoardKanbanPage.tsx — same pattern; passes ready to useBoardData; removes the ":4800" hint from post-connection errors since the server is confirmed running by that point.

Test Plan

  • Local tests pass (177/177)
  • CI checks pass
  • pnpm dev:desktop — board page shows "Connecting..." briefly then loads (or "No projects yet" if empty)
  • Kill board-server manually, navigate to board — shows "Connecting..." and auto-recovers when server restarts
  • pnpm exec tsc --noEmit in apps/desktop — no errors

Notes

tauri.conf.json is unchanged — the beforeDevCommand & background launch is correct; the frontend just needs to be resilient to slow startup. The WebSocket hook already had retry logic; this aligns HTTP fetching with the same pattern.

siracusa5 and others added 4 commits March 16, 2026 15:25
…ate instead of static error

Add useBoardServerReady hook that polls /health every 2s until the board
server responds, then stops. BoardProjectsPage and BoardKanbanPage now gate
their API calls on ready===true and show "Connecting to board server..."
during the wait. Eliminates the race condition where the React frontend
loads before the board-server is ready on :4800.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, hook tests

- Replace AbortSignal.timeout() with AbortController+setTimeout for
  compatibility with older WKWebView versions (macOS 12/13)
- Initialize useBoardData loading to false (no fetch in-flight until
  ready=true; callers gate on !ready||loading so behavior is unchanged)
- Add useBoardServerReady tests: initial state, ok/non-ok response,
  retry timing, stops-after-ready, unmount cleanup (183 tests total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Un-ignore .devlaunch.yml so project launch config is shared.
Fixes broken pnpm install:desktop and watch:desktop references
that don't exist in package.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… guard setReady after unmount

- Test now imports BOARD_SERVER_BASE from board-api instead of hardcoding
  the URL string, so it stays in sync if the constant changes
- useBoardServerReady: track mounted flag in effect closure; skip setReady
  if component unmounts before in-flight fetch resolves

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@siracusa5 siracusa5 merged commit 59a443a into main Mar 16, 2026
5 checks passed
@siracusa5 siracusa5 deleted the fix/board-server-ready-retry branch March 16, 2026 20:47
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