refactor(runtime): extract resume-repaint tick into useResumeTick (#1237)#1280
Merged
Conversation
) Item 5 of the app.ts decomposition. Lifts the SIGCONT resume-repaint cluster — the throwaway `setResumeTick` `useState` and the effect that wires `resumeRef.current` to a tick-bump (forcing the Ink tree to repaint after `fg` so the user doesn't land on an empty alt-screen) — into a new `useResumeTick` hook. The `useState` and effect are adjacent in app.ts with no intervening hooks, so they move together into one hook called at the original slot; hook order is preserved. The effect is reproduced verbatim — same `!resumeRef` guard, `resumeRef.current = () => setResumeTick((tick) => tick + 1)` assignment, cleanup, and `[resumeRef]` dependency array. `resumeRef` stays owned by the runtime (also read by the editor / compose / changelog action hooks) and is passed in. Adds tests for install/cleanup, the tick-bump updater, and the no-resumeRef no-op.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 5 —
app.tsdecomposition (#1237)Follows #1279. Lifts the SIGCONT resume-repaint cluster into a new
useResumeTickhook.What & why
When the workstation is suspended (Ctrl-Z) and resumed (
fg→ SIGCONT), Ink comes back on the alternate screen buffer without repainting — the user lands on an empty screen. The runtime installs a resume callback intoresumeRef; the SIGCONT handler invokes it, and this cluster's callback bumps a throwaway counter to force a re-render (repaint).Single combined hook (order-safe)
The throwaway
setResumeTickuseStateand its effect are adjacent inapp.tswith no intervening hooks, so they move together into one hook called at the original slot — hook order is preserved. The effect is reproduced verbatim: same!resumeRefguard,resumeRef.current = () => setResumeTick((tick) => tick + 1)assignment, cleanup, and[resumeRef]deps.resumeRefstays runtime-owned (it's also read by the editor / compose / changelog action hooks to re-arm the screen after shelling out) and is passed in.Changes
hooks/useResumeTick.ts.app.ts: theuseState+ effect →useResumeTick(React, {resumeRef}).hooks/useResumeTick.test.ts— install/cleanup, the tick-bump updater, and the no-resumeRefno-op.Validation
jest(workstation): 112 suites / 1877 tests pass, 68 snapshots no diffstsc --noEmit: clean ·eslint: 0 errors ·rollup -c: buildsdist/