Bound automatic terminal titles before session persistence
Problem
Automatic terminal titles can carry multiline transcript-sized OSC values into workspace and panel metadata, inflating session snapshots and autosave encoding.
Change
- bound and sanitize automatic terminal titles at the shared terminal-title admission boundary
- normalize already-persisted oversized automatic titles during workspace, Dock, and panel restore
- preserve explicit custom titles, authored workspace names, transferred panel names, and ordinary short OSC titles
- add deterministic ingress-to-snapshot regression coverage and generated-fixture measurements
Evidence and trade-off
The identical generated fixture uses 128 workspaces and two 3,000-line automatic titles duplicated into workspace/panel metadata:
| Representation | Snapshot bytes | Median JSON encode |
|---|---|---|
| Unbounded synthetic title | 635,397 | 1.438896 ms |
| 256-Unicode-scalar title | 12,429 | 0.098438 ms |
The chosen bound is 256 Unicode scalars, including an ellipsis when truncated. Newline-like controls become spaces; other C0/C1 and bidi embedding/override/isolate controls reject the automatic update. The bound keeps normal title metadata generous while capping each admitted title at 1,023 UTF-8 bytes. Measurements use generated text only.
Validation
TerminalTitleChurnFilterTests: multiline bound, control rejection, scalar-safe multibyte truncation, spinner and ordinary-title behaviorTitleUpdateAmplificationRegressionTests: real Ghostty ingress → coalescer → workspace/panel state → many-workspace snapshot encoding, persisted oversized-title restore, custom-title preservation, authored workspace-name preservationpython3 scripts/swift_file_length_budget.py./scripts/lint-pbxproj-test-wiring.shpython3 scripts/localization_catalog.py check- canonical HQ autoreview: clean, no accepted/actionable findings; merge-conflict gate clean
The focused hosted macOS test run is queued without a runner assignment, as are the PR's macOS compile admission, Swift package tests, CLI pipe regressions, and agent-notification tests. No local Xcode build or app launch was performed.
Closes #12980