Skip to content

fix(tui): update tool spacing before layout#30762

Open
kitlangton wants to merge 3 commits into
devfrom
fix/tui-prelayout-tool-spacing
Open

fix(tui): update tool spacing before layout#30762
kitlangton wants to merge 3 commits into
devfrom
fix/tui-prelayout-tool-spacing

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

@kitlangton kitlangton commented Jun 4, 2026

Summary

  • move inline tool spacing updates from OpenTUI renderBefore into a shared pre-layout lifecycle helper
  • preserve text, block-tool, user-message, and subagent-group separators without drawing against stale Yoga geometry
  • cache sibling relationships once per parent per frame so pre-layout spacing remains linear for long transcripts
  • make v2 session text renderable IDs unique and reset v2 inline spacing through the same helper
  • assert inline spacing on the first rendered frame and cover sticky-bottom geometry while text separators mount and unmount

Root cause

renderBefore runs after Yoga layout and immediately before drawing. Updating marginTop from that hook dirtied layout after scroll geometry had already been calculated, which could leave sticky-bottom transcript rendering out of sync and expose blank space until a later frame or resize.

Review passes

  • extracted the shared renderer-boundary behavior into setPreLayoutSiblingMargin
  • memoized user-message IDs so the lifecycle hot path no longer rescans the transcript for each inline row
  • cached previous-sibling maps in weak references once per parent per frame after a follow-up review identified quadratic sibling scans
  • added a constrained sticky-bottom scrollbox regression that asserts geometry growth and shrinkage after exactly one render per transition

Red-before-green

With only the regression-test changes applied to pre-fix origin/dev, the sticky-bottom transition test fails immediately after mounting the separator:

Expected: 5
Received: 4

With this branch, the same one-render transition test passes.

Verification

  • bunx prettier --check src/cli/cmd/tui/util/layout.ts src/cli/cmd/tui/routes/session/index.tsx src/cli/cmd/tui/feature-plugins/system/session-v2.tsx test/cli/tui/inline-tool-wrap-snapshot.test.tsx
  • bun run test -- test/cli/tui/inline-tool-wrap-snapshot.test.tsx (10 pass, 6 snapshots)
  • bun typecheck from packages/opencode
  • git diff --check origin/dev...HEAD
  • pre-push hook: bun turbo typecheck (22 successful)

Known lint blocker

  • scoped bunx oxlint ... is blocked before source analysis by the existing .oxlintrc.json error: options.typeAware is only supported in the root config

@kitlangton kitlangton added the beta label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant