Bound automatic terminal titles before session persistence

Merged
AU
2mo ago
+334-31

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:

RepresentationSnapshot bytesMedian JSON encode
Unbounded synthetic title635,3971.438896 ms
256-Unicode-scalar title12,4290.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 behavior
  • TitleUpdateAmplificationRegressionTests: real Ghostty ingress → coalescer → workspace/panel state → many-workspace snapshot encoding, persisted oversized-title restore, custom-title preservation, authored workspace-name preservation
  • python3 scripts/swift_file_length_budget.py
  • ./scripts/lint-pbxproj-test-wiring.sh
  • python3 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