Skip to content

refactor(app): move the layout notice state into a hook - #1757

Merged
devswha merged 1 commit into
mainfrom
refactor/app-layout-notice-hook
Oct 23, 2026
Merged

devswha merged 1 commit into
mainfrom
refactor/app-layout-notice-hook

Conversation

@devswha

@devswha devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Wave 2 of the App.tsx split. The plan is .omo/plans/app-stores-split.md in the maintainer's workspace. It follows #1754.

This wave moves the layout notice out of src/App.tsx into src/lib/useLayoutNotice.ts. That is the line shown over the pane when a PC's bridge refuses a palette layout call. Both hooks run inside App's render, so updates and effect order are unchanged.

What changes

  • Moved verbatim into two hooks:
    • useLayoutNotice() holds the layoutNotice state and its 6-second timer effect, with their comment. It returns { layoutNotice, setLayoutNotice }.
    • useLayoutRefused(setLayoutNotice, t) holds the layoutRefused callback with its comment and its [t] dependency list.
  • Stays in App.tsx: each block becomes one call at its own former position, so effect order is unchanged.
    • The first sits between the error state and the authentication state.
    • The second sits just before the notification-target block.
  • Imports: routeMissing leaves App's ./lib/api.ts import, because only the moved callback used it.
  • Hook ceiling: APP_HOOK_CEILING in src/app-hooks.test.ts drops from 179 to 176. That is App's new count, after moving one useState, one useEffect and one useCallback.

Checks

  • --color-moved: git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD shows 28 lines as moved. The other lines are:
    • the ./lib/api.ts import line, without routeMissing;
    • the new import;
    • the two call lines;
    • the ceiling value;
    • the new file's imports, doc comments, signatures and returns.
  • Typecheck: bun run typecheck passes.
  • Ceiling test: HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts passes. Adding const zz = useState(false); to App.tsx makes it fail.
  • Browser regressions: each run with bun run check run --build bun scripts/<name>.ts, and each exited 0.
    • ui-contexts-regression.ts (it runs the update-notice check)
    • revision-bound-update-demo
    • telemetry
    • lan-exposure-notice
    • machine-conflict
  • bun run check fast: passes (unit 6245 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.7s)

Outside PRs that touch the same files

No other maintainer PR touches these files. One outside contributor's PR touches src/App.tsx: #1427. It already conflicts with main in App.tsx, and conflicts the same way with this branch, so it needs a rebase either way.

Move-only: moved lines plus imports, two hook signatures, two calls and the lowered ceiling. No changelog fragment: users see no change.

The layout notice state with its 6s timer, and the layout refusal callback,
move verbatim into src/lib/useLayoutNotice.ts as two hooks, called in App
where each block stood. APP_HOOK_CEILING is lowered from 179 to 176.
Plan .omo/plans/app-stores-split.md wave 2.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 595a333 and 34cdba1.

📒 Files selected for processing: 3
  • src/App.tsx
  • src/app-hooks.test.ts
  • src/lib/useLayoutNotice.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Refactor
    • Layout notices for unavailable routes continue to display and clear automatically after six seconds. Notice handling is now managed consistently across the app.

App now uses dedicated hooks for layout notice state, its six-second timeout, and refusal handling. The hook-call ceiling test threshold decreases from 179 to 176.

Changes: Layout notice handling

Layer / File(s) Summary
Implement layout notice hooks
src/lib/useLayoutNotice.ts
useLayoutNotice manages nullable notice state and clears truthy notices after six seconds. useLayoutRefused sets a translated notice for routeMissing errors and warns for other errors.
Wire hooks into App
src/App.tsx, src/app-hooks.test.ts
App replaces its inline notice state, timeout effect, and refusal callback with the new hooks. The hook-call ceiling test threshold decreases from 179 to 176.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related PRs

  • devswha/ovis#1754: Moves Settings dialog navigation state and effects from App.tsx into a hook, continuing the App state extraction work.
Merge Risk: ⚪ Minimal · up to 34cdb

No actionable issue is identified with the layout-notice extraction; it appears ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: moving layout notice state into a hook.
Description check Passed The description explains the problem and resulting behavior, lists the implementation changes, and provides detailed validation results. It does not use the exact template headings, but it includes th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem and resulting behavior, lists the implementation changes, and provides detailed validation results. It does not use the exact template headings, but it includes the required Change and Validation information.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: move-only PR (wave 2 of the App.tsx split). It is merged on its checks without waiting for a CodeRabbit review, as AGENTS.md allows.

A gate reviewer on a different model than the author's approved it:

  • On main, the layoutNotice state and its timer effect were already next to each other, so effect cleanup and commit order are unchanged.
  • The hook calls are moved verbatim, dependencies included.
  • The setter stays stable, and layoutRefused keeps [t].
  • Counting App's hooks on the TypeScript AST confirms 179 → 176.
  • The hook-ceiling test, the typecheck and the lan-exposure-notice browser regression all pass.

All required checks are green and no review thread is open.

@devswha
devswha merged commit e590552 into main Oct 23, 2026
9 checks passed
@devswha
devswha deleted the refactor/app-layout-notice-hook branch October 23, 2026 12:27
devswha added a commit that referenced this pull request Oct 23, 2026
Wave 3 of the App.tsx split. The plan is
`.omo/plans/app-stores-split.md` in the maintainer's workspace. It
follows PR #1757.

This wave moves the connection chip's state out of `src/App.tsx` into
`src/lib/useConnectionChip.ts`, along with the callback that reads
output stalls from server messages. Both hooks run inside App's render,
so updates and effect order are unchanged.

## What changes

- **Moved verbatim into two hooks:**
- `useConnectionChip()` holds the `connected`, `connectedBefore` and
`outputStopped` states and the `paneLost` callback, with their comments.
It returns all seven names App uses.
- `useServerMessageHandler(setOutputStopped)` holds the
`handleServerMessage` callback with its `[]` dependency list.
- **Stays in `App.tsx`:** each block becomes one call at its own former
position:
- The first sits between the `sessionHistory` state and the
notifications state.
- The second sits right after the event-stream effect, before
`enableNotifications`.

`connWord` and the inline `onConnectionChange` lambda also stay in App.
- **Imports:** `ServerMessage` leaves App's `../shared/protocol.ts` type
import, because only the moved callback used it.
- **Hook ceiling:** `APP_HOOK_CEILING` in `src/app-hooks.test.ts` drops
from 176 to 171. That is App's new count, after moving three `useState`
and two `useCallback` calls.

## Checks

- **`--color-moved`:** `git diff --color-moved=plain
--color-moved-ws=allow-indentation-change origin/main...HEAD` shows 20
lines as moved. The other 19 lines are:
  - the narrowed type import;
  - the new import;
  - the two call lines;
  - the ceiling value;
  - the new file's imports, doc comments, signatures and returns.
- **Typecheck:** `bun run typecheck` passes.
- **Ceiling test:** `HERDR_TEST_MODE=unit bun test
src/app-hooks.test.ts` passes. Adding `const zz = useState(false);` to
App.tsx makes it fail.
- **Browser lane:** `bun run check integration browser`: browser lane
exit 0 (every browser script passed, 1990 s). The integration lane's
only failure is `server/api.contract.test.ts` "creates, edits, searches,
inspects, and closes an owned workspace" (line 1540, `/api/pane/files`
returns `[]`), which fails the same way on unchanged `origin/main` on
this PC; this PR changes no server code, and CI runs that lane in its
own environment.
- `bun run check fast`: passes (unit 6253 pass, 0 fail, 13 skip in 443
files, 8 at a time, 78.6s)

## Outside PRs that touch the same files

No other maintainer PR touches these files. One outside contributor's PR
touches `src/App.tsx`: #1427. It already conflicts with main in
`App.tsx`, and conflicts the same way with this branch, so it needs a
rebase either way.

Move-only: moved lines plus imports, two hook signatures, two calls and
the lowered ceiling. No changelog fragment: users see no change.
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