Skip to content

Terminal renderer fix + configurable padding and smaller font sizes#48

Closed
mai1015 wants to merge 2 commits into
duxweb:mainfrom
mai1015:terminal
Closed

Terminal renderer fix + configurable padding and smaller font sizes#48
mai1015 wants to merge 2 commits into
duxweb:mainfrom
mai1015:terminal

Conversation

@mai1015

@mai1015 mai1015 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Two terminal-focused changes, atomically committed.

1. fix: shape non-ASCII terminal cells per-segment to preserve combining marks

The row combiner previously gave up on the entire row as soon as one span was non-combinable (wide CJK, multi-codepoint, or anything non-ASCII), forcing the whole row through the slower per-span path.

  • combine_terminal_row_runs now collects maximal contiguous groups of 1:1 char-to-cell ASCII spans and merges each group into its own TerminalRowLine, returning only genuinely non-combinable spans as leftover. One wide cell no longer blocks the rest of the row from combining.
  • TerminalTextRun now carries one TerminalTextSegment per originating cell (byte range + column + hash). Non-ASCII text is painted per cell instead of per Rust char, so a cell's base character and any combining marks (e.g. "á" as a + U+0301) shape as a single unit at the correct column. The previous char-based split displaced combining marks into the next column.
  • ASCII text keeps the fast single-shape path; only non-ASCII segments iterate.
  • TerminalPreparedRow.line: Option<_>lines: Vec<_> to carry multiple combined lines per row.
  • New unit tests cover combining-mark cells, per-cell segment bookkeeping under append_text, and combining around a non-combinable span.

2. feat: configurable terminal padding and smaller font sizes

  • New terminalPadding setting (0-40 px), plumbed end-to-end: AppSettings, sanitize, defaults, SettingsSummary, the settings service (set_terminal_padding), desktop settings UI (new select row), and terminal_config_for_settings (Edges::all(px(padding))).
  • Static terminal_config() padding default drops from 10 px → 0 px so the user setting is the sole source of truth (the desktop pane insets were already adding their own padding, this avoids double-counting).
  • Minimum terminal font size drops 10 → 8 across the cycle list, numeric_string bounds, and the desktop picker (8..=28). Mobile gains 10.0 and 11.0 steps and its remote-pane insets shrink 12 → 4 to match the tighter desktop layout.
  • Default terminal line-height multiplier 1.45 → 1.2 — the old value left oversized row gaps at the new smaller sizes.
  • Refactor: runtime terminal settings service routes numeric-string clamping through a shared set_numeric_string helper.

Files

  • apps/desktop/src/terminal/{renderer,grid_version,element}.rs — renderer fix
  • apps/desktop/runtime/src/settings/**, apps/desktop/src/app/{settings,settings_actions,terminal_state}.rs, apps/desktop/src/terminal/config.rs — padding feature
  • apps/mobile/lib/{models/remote_models.dart, widgets/components/remote_terminal_pane.dart}, apps/mobile/pubspec.lock — mobile alignment

Test plan

  • Desktop: terminal renders ASCII rows correctly (no regression in the combine path).
  • Desktop: CJK / wide cells keep grid alignment; combining diacritics stack on the base glyph.
  • Desktop: change Terminal Padding in settings → applies live, persists across restart.
  • Desktop: cycle font size reaches 8 and wraps back from 28 → 8.
  • Mobile: font picker shows 10.0/11.0 steps; terminal pane insets look correct.

Notes

  • Skipped two untracked items that do not belong in this PR: .omo/ (local agent session state) and docs/spec/changes/add-tailscale-transport-2026-07-05/ (a proposed but unrelated tailscale transport spec).

Ultraworked with Sisyphus

mai1015 and others added 2 commits July 5, 2026 16:20
… marks

The row combiner used to give up on the entire row as soon as one span was
non-combinable (wide CJK, multi-codepoint, or anything non-ASCII), forcing the
whole row through the per-span path. combine_terminal_row_runs now collects
maximal contiguous groups of 1:1 char-to-cell ASCII spans and merges each
group into its own TerminalRowLine, returning only the genuinely non-
combinable spans as leftover — so one wide cell no longer blocks the rest of
the row from being shaped once.

TerminalTextRun now carries one TerminalTextSegment per originating cell
(byte range + column + hash). Painting non-ASCII text per cell, rather than
per Rust char, keeps a cell's base character and any combining marks (e.g.
"á" as a + U+0301) shaped as a single unit at the cell's column — splitting
by char had been displacing the mark into the next column. ASCII text keeps
the fast single-shape path; everything else iterates segments.

TerminalPreparedRow.line: Option<TerminalRowLine> becomes lines: Vec<...>
to carry the multiple combined lines per row.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Adds a new terminalPadding setting (0-40 px) plumbed end-to-end through
AppSettings, sanitize, defaults, SettingsSummary, the settings service
(set_terminal_padding), the desktop settings UI (a new select row), and
terminal_config_for_settings (Edges::all(px(padding))). The static
terminal_config() default drops from 10px to 0px so the user-configured
value is the sole source of padding, and the desktop pane insets stop
double-counting padding.

Lowers the minimum terminal font size from 10 to 8 across the cycle step
list, the sanitize/summary numeric_string bounds, and the desktop picker
(8..=28). The mobile font step list gains 10.0 and 11.0 and the mobile
remote terminal pane insets shrink from 12 to 4 so the small-screen
terminal matches the tighter desktop layout.

Also tightens the default terminal line-height multiplier from 1.45 to
1.2 — the prior value left oversized gaps between rows at the new smaller
font sizes.

Refactors the runtime terminal settings service to route numeric-string
clamping through a shared set_numeric_string helper.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
dux-web added a commit that referenced this pull request Jul 6, 2026
…down to 8

Adopted from PR #48 as opt-in settings instead of changed defaults:
terminalLineHeight (1.0-2.0, default 1.45) and terminalPadding (0-40px,
default 10) apply live to open terminals; font size range widens 10-28
to 8-28.

Co-authored-by: mai1015 <i@mai1015.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dux-web

dux-web commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

感谢贡献!这个 PR 已经部分合入 main:

  • 渲染修复(6a2edd6)已原样 cherry-pick 为 ebce9d4,保留你的作者署名。main 上的分支菜单/终端这段时间重构较多,唯一的冲突是我们后来给合并门槛加的 symbol 字体检查(Nerd Font/powerline 需要逐格绘制)——已把该条件迁移进你新的 combine_terminal_row_runs 分组判断,语义与两边都一致,208 个测试全绿。
  • 第二个 commit 以「可选设置」形式采纳(0a14a20,已给你挂 Co-authored-by):terminalPadding(0-40,默认保持 10)、新增 terminalLineHeight(1.0-2.0,默认保持 1.45)、字号下限放宽到 8。默认外观不变,想要你提议的紧凑效果的用户在 设置 → 通用 → 终端 里调 1.2 / 0 / 8 即可,对已打开的终端实时生效。移动端的 inset/字号档位改动暂未带入(移动端独立发版,后续单独评估)。

由于是 cherry-pick + 重实现而不是分支合并,GitHub 不会自动标记 merged,这里手动关闭。再次感谢!

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