Skip to content

estimatedMsgHeight overcounts structured-diff rows by ~4 #835

Description

@ericleepi314

estimatedMsgHeight is ~4 rows high for a kind: 'diff' message with
structured diffData. Measured at cols=80 and cols=100: estimate 10, paint 6.
On origin/main before #834 it was 9 against 6, so most of this predates that
PR; #834 added one row via a call-row counting fix that is correct everywhere
else, and explicitly scoped this branch out.

Two causes, both in the kind: 'diff' path:

  • The estimator counts wrappedLines(msg.text) for a markdown fallback that
    the structured branch never renders (messageLine.tsx returns its own
    wrapper with DiffView instead).
  • It adds 2 for a Response separator that branch never paints —
    shouldShowResponseSeparator returns false for msg.kind === 'diff'.

It also does not model DiffView's own rows at all, so the sign of the error
depends on the patch size.

Why it matters: the virtualized transcript positions rows from this estimate
before Yoga measures anything, so a wrong number shows up as scrollbar drift
and blank gaps. Edit/Write segments are common.

kind: 'diff' is now the only message kind with no estimate-vs-paint coverage
in toolBrief.test.ts's parity suite (which renders real ToolTrail and
MessageLine output and asserts the estimate equals the painted row count).
Adding a structured-diff case there — which needs structuredDiffSupported()
and real diffData — would both pin the fix and stop it regressing.

Found during the review of #834.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions