Skip to content

fix(workbench): show long tool output on macOS - #6868

Merged
M4n5ter merged 2 commits into
rust-previewfrom
fix/long-code-text-pieces
Nov 14, 2026
Merged

M4n5ter merged 2 commits into
rust-previewfrom
fix/long-code-text-pieces

Conversation

@UncertaintyDeterminesYou4ndMe

@UncertaintyDeterminesYou4ndMe UncertaintyDeterminesYou4ndMe commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Cause

macOS draws each NSH text into one Core Animation layer, and a layer taller or wider than the GPU's largest texture (16384 pixels) shows nothing. Tool details put a whole Shell output or file in one text, so on a 2x display an output of about 1200 lines showed as an empty box. A single very long line, such as minified JSON, has the same problem across.

Change

CodeText lays its text out in pieces of 200 lines (4000 pt tall at 20 pt lines). Line numbers are padded to one width, so the pieces line up as one column.

A line wider than one layer is cut and ends with "… N more characters". The budget is 720 columns with that note included, which holds at the largest text size (130%) on a 2x display: one monospace column there measures about 20.9 px, so 720 columns are about 15,050 px. East Asian characters (up to 1.6 columns measured) count as two, and emoji and symbols such as ✅ (2.2 measured) as three. A test ties the budget to the largest size in appearance.ts. The copy buttons still copy the whole recorded text.

One trade-off: a text selection cannot cross from one piece into the next. The copy buttons cover copying everything.

AI use

Diagnosis and the patch were done with Claude Code (Claude Opus 5.5). It found the empty box on a local build, matched it to the layer size limit, and wrote the change and its unit test. I checked the fix on a local build with a long Shell output.

macOS draws each NSH text into one Core Animation layer, and a layer
taller or wider than 16384 pixels shows nothing. A Shell output of about
1200 lines rendered as an empty box at 2x.

Code text is now laid out in pieces of 200 lines, each well under the
limit. A line wider than 800 columns, with wide characters counted as
two, is cut and ends with how many characters are left. The copy buttons
still copy the whole recorded text.
@M4n5ter

M4n5ter commented Nov 13, 2026

Copy link
Copy Markdown
Member
English

Please fix the width budget before we merge this. The fixed lineColumns = 800 in codePieces.ts does not cover the supported 130% text size. appearance.ts offers a scale of 1.3, and the AppKit shell applies it to code text too. The truncation suffix also adds width beyond those 800 columns.

Using CoreText with the same NSFont.monospacedSystemFont that NSH uses, at 13 × 1.3 pt on a 2x display:

  • 800 ASCII a characters measure approximately 16,715 px wide.
  • An input of 830 a characters, cut to 800 plus … 30 more characters, measures approximately 17,154 px wide.

Both exceed the 16,384 px limit this change is intended to avoid, so a supported text-size setting can still reach the dimensions responsible for the empty output. These are native font measurements; I have not reproduced the blank result in a window built from this PR.

Please account for the maximum supported text scale and the suffix in the final width budget, and verify both an exactly-at-limit line and a truncated line at 130% on a 2x display. The 200-line splitting approach otherwise looks reasonable, and the copy path preserves the original text.

简体中文

合并前请先修一下宽度预算。codePieces.ts 固定使用 lineColumns = 800,没有覆盖应用支持的 130% 字号。appearance.ts 提供了 1.3 倍缩放,AppKit shell 也会将它应用到代码文本上。另外,截断后的省略提示还会在这 800 列之外继续增加宽度。

使用 NSH 相同的 NSFont.monospacedSystemFont,通过 CoreText 测量,在 13 × 1.3 pt、2x 屏幕下:

  • 800 个 ASCII 字符 a 的实际宽度约为 16,715 px。
  • 输入 830 个 a,截成 800 个并追加 … 30 more characters 后,实际宽度约为 17,154 px。

两种都超过了这次改动要避开的 16,384 px 上限,因此使用受支持的字号设置,仍会落入导致输出空白的尺寸范围。这些数据来自原生字体测量;我还没有在基于本 PR 构建的窗口里复现空白结果。

请让最终宽度预算覆盖最大支持字号和省略提示,并在 130% 字号、2x 屏幕下验证“恰好达到列数上限”和“超过上限后被截断”两种输入。其余部分,按 200 行分块的方向可以,复制链路也保留了完整原文。

…note

At the 130% text size on a 2x display, 800 columns of monospace code
text measured about 16,715 px, over the 16,384 px layer limit, and the
"more characters" note added more. The budget is now 720 columns with
the note included, and emoji and symbols such as ✅, which measure 2.2
columns, count as three. A test ties the budget to the largest size in
appearance.ts.
@UncertaintyDeterminesYou4ndMe

Copy link
Copy Markdown
Contributor Author
English

Thanks, you're right on both counts. Fixed in d4985af:

  • The budget is now 720 columns including the "… N more characters" note. The cut reserves room for the note before cutting, sized for the longest count the line could produce, in whatever language the note is in.
  • Emoji and pictographic symbols count as three columns. While checking your numbers I found they measure 2.2 columns, so 360 emoji were about 16,560 px even under the old two-column count. East Asian characters measure up to 1.6 and still count as two.
  • A test reads textSizes from appearance.ts and fails if the largest size outgrows the budget.

I measured the lines codePieces actually produces with CoreText, using NSFont.monospacedSystemFont at 13 × 1.3 pt, ×2 (800 a gives 16,715 px, matching your figure):

Line Width
exactly at the limit: 720 a 15,044 px
exactly at the limit: 360 字 / 240 ✅ 12,061 / 11,040 px
cut, English note (721 a, or 10 million) 15,002 px
cut, Simplified / Traditional Chinese note 14,960 px
cut, CJK / ✅ / family emoji / mixed aé字😀 12,140 / 11,132 / 2,965 / 12,949 px

The widest is 15,044 px, about 8% under 16,384. 200 lines at 130% are 10,400 px tall.

Like you, I haven't reproduced the blank or its absence in a window at 130%. These are native measurements of the exact strings. One known gap: a few rare glyphs are wider than the estimate (U+FDFD is about 5 columns, cuneiform about 7.5). A full line would need around 20 of them to reach the limit.

简体中文

谢谢,两点都对,已在 d4985af 修复:

  • 预算改为 720 列,包含“…还有 N 个字符”提示。截断前先按这一行可能出现的最长数字给提示留出位置,提示是哪种语言都按实际宽度算。
  • emoji 和图形符号按 3 列计。核对你的数据时我发现它们实测约 2.2 列,旧的按 2 列计算时,360 个 emoji 约 16,560 px,同样会超限。中日韩文字实测最多 1.6 列,仍按 2 列计。
  • 新增测试读取 appearance.ts 里的 textSizes,最大字号超出预算时会失败。

我用 CoreText(NSFont.monospacedSystemFont,13 × 1.3 pt,×2)测量了 codePieces 实际生成的行(800 个 a 为 16,715 px,与你的数据一致)。最宽的是恰好达到上限的 720 个 a,15,044 px,比 16,384 低约 8%;各种截断行(英文、简体、繁体提示,中文、✅、emoji、混排)都在 15,002 px 以内。200 行在 130% 下高 10,400 px。

和你一样,我没有在 130% 的窗口里复现空白或确认不空白,这些是对实际字符串的原生测量。已知缺口:少数罕见字形比估算更宽(U+FDFD 约 5 列,楔形文字约 7.5 列),一整行要有约 20 个才会达到上限。

@M4n5ter
M4n5ter merged commit d7370b1 into rust-preview Nov 14, 2026
59 of 69 checks passed
@M4n5ter
M4n5ter deleted the fix/long-code-text-pieces branch November 14, 2026 02:44
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.

2 participants