Skip to content

Fix: keep generation retryable and don't disable local actions when offline#78

Open
deepfates wants to merge 1 commit into
mainfrom
codex/investigate-generate-button-issue
Open

Fix: keep generation retryable and don't disable local actions when offline#78
deepfates wants to merge 1 commit into
mainfrom
codex/investigate-generate-button-issue

Conversation

@deepfates

Copy link
Copy Markdown
Owner

Motivation

  • Users could not trigger generation or perform local actions (e.g., New Story) when the browser reported offline, and no network request or server logs were produced.
  • A stale navigator.onLine check and a generation error short-circuit created a silent dead-end that prevented retries after transient failures.

Description

  • Remove the navigator.onLine preflight from useTextGeneration so the client attempts the real /api/generate fetch and surfaces network failures via the existing error path (client/interface/hooks/useTextGeneration.ts).
  • Stop globally disabling the A/Enter control when isOffline is true and instead disable only while a generation is actively in-flight (client/interface/Interface.tsx).
  • Remove the permanent short-circuit that blocked Enter after an earlier generation error so users can retry after reconnecting (client/interface/hooks/useStoryTree.ts).
  • Add an end-to-end regression that exercises offline New Story, a visible generation network failure, and a successful retry after reconnect (tests/e2e/offline-controls.e2e.ts).

Testing

  • Ran lint: bun run lint, which completed successfully.
  • Ran unit tests: bun test ./server ./client — full suite passed (155 tests).
  • Built production bundles: bun run build — build succeeded.
  • Added Playwright e2e: attempted bunx playwright test tests/e2e/offline-controls.e2e.ts but execution was blocked in this environment because Playwright’s Chromium binary could not be downloaded (CDN download returned HTTP 403), so the new e2e regression could not be executed here.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46fed5feed

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +14 to +19
await page.route("**/api/generate", async (route) => {
await route.fulfill({
status: 200,
contentType: "text/event-stream",
body: 'data: {"content":" The connection returned."}\n\ndata: [DONE]\n\n',
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Delay the success mock until after reconnect

When this e2e runs, the /api/generate route is registered before context.setOffline(true), so the offline A-button click still matches this handler and is fulfilled with the 200 SSE body from the test process instead of producing the expected fetch failure. That makes the Network error assertion time out (or at least skips the intended offline error path); register the success mock only after setOffline(false), or have the route abort while the context is offline.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant