feat(ink-compat): extend Ink compatibility layer parity#30
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d3a30b175
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!canUseAlternateBuffer || !alternateBufferActive) return; | ||
| writeBestEffort(stdout, ANSI_ALTERNATE_BUFFER_EXIT); | ||
| alternateBufferActive = false; |
There was a problem hiding this comment.
Preserve caller-owned alternate buffer state on cleanup
When alternateBufferAlreadyActive is set, this render call starts with alternateBufferActive = true even though it did not enter the alternate buffer itself, but cleanupAlternateBuffer() still unconditionally writes the exit sequence whenever alternateBuffer is enabled. In nested/embedded use (where a parent already owns the alternate buffer), unmounting this instance will send \u001B[?1049l and tear down the parent’s buffer unexpectedly, causing terminal screen/state corruption outside this app.
Useful? React with 👍 / 👎.
| const measuredId = node.internal_id; | ||
| const stackPropsWithId = mapped.wrapper | ||
| ? mapped.stackProps | ||
| : { ...mapped.stackProps, id: measuredId }; |
There was a problem hiding this comment.
Avoid reusing IDs across accumulated Static snapshots
This assigns node.internal_id into rendered vnode props, including the <Static> path where vnodes are appended to root.staticVNodes over time, so the same host node ID is duplicated across historical static entries. Core layout indexing keeps the first rect for a given id (buildLayoutRectIndexes only sets when the id is absent), so later snapshots can no longer update that node’s measured rect; measureElement/ResizeObserver for static boxes can become stale after additional static emissions.
Useful? React with 👍 / 👎.
This PR extends
@rezi-ui/ink-compattoward Ink parity (G1–G7 scope).Parity features
measureElement()committed-layout reads +getBoundingBox(),getScrollHeight()/getScrollWidth()ResizeObserverimplementation wired to committed layout snapshotsonRender,isScreenReaderEnabled,alternateBuffer,incrementalRendering(best-effort surface)useStdin()raw-mode behavior: meaningfulisRawModeSupported, ref-countedsetRawMode()toggles, clearer unsupported errorsCore plumbing
createApp()internal callbacks for render/layout (internal_onRender,internal_onLayout)WidgetRenderer.getRectByIdIndex()+ committed id->rect indexing used by ink-compat measurementValidation
npm run build(pass)npm run typecheck(pass)npm run test(pass; 920 tests)Known deviations / constraints
incrementalRendering: accepted for Ink surface parity; currently best-effort/no-op in this implementation