Skip to content

feat(renderer): sub-plan C.1 — SwiftTerm fork + capture/replay harness#1

Merged
kiki830621 merged 6 commits into
mainfrom
renderer-c1-v2
May 26, 2026
Merged

feat(renderer): sub-plan C.1 — SwiftTerm fork + capture/replay harness#1
kiki830621 merged 6 commits into
mainfrom
renderer-c1-v2

Conversation

@kiki830621
Copy link
Copy Markdown
Contributor

Summary

Sub-plan C.1 partial completion via background agent (rate-limited mid-Task-6).

What's done

  • Package.swift switched to PsychQuant/SwiftTerm fork (logos-renderer-base branch)
  • Tools/SwiftTermReplay/ — standalone Swift Package with record + replay subcommands
  • 2 of 5 baseline captures recorded (01-simple-streaming, 02-edit-tool)
  • docs/renderer-c1-retrospective.md with C.2 starting points

What's deferred

  • 3 remaining captures (plan/rate-limit/permission) — collect organically
  • Visual baseline screenshots — collect during C.2 prep
  • docs/renderer-baselines/ directory contents

Review notes

  • Branch is rebased on D-Task 1 (merge-base 971e3d6). Main has D-Tasks 2-7 (auto-handle complete). Merging this PR will combine fork-swap + auto-handle on main.
  • No renderer modifications yet — pure infrastructure for C.2+.
  • swift build + swift test both green on this branch (31 tests).
  • cd Tools/SwiftTermReplay && swift build builds standalone tool.

Test plan

# Verify dep switch works
swift package resolve
swift build
# Verify replay tool works
cd Tools/SwiftTermReplay && swift run swiftterm-replay --help
swift run swiftterm-replay replay --input Sources/SwiftTermReplay/Captures/01-simple-streaming.ttyrec --speed 1.0

Tracks logos-renderer-base branch (pinned to v1.13.0 — upstream main
currently broken with undefined SyncDebug references). Behavior
identical to upstream v1.13.0 until C.2 begins renderer modifications.

Fork URL: https://github.com/PsychQuant/SwiftTerm
Standalone Swift Package executable for recording + replaying PTY
streams into SwiftTerm. Lives in Tools/ — not bundled into Logos app.

CLI skeleton with ArgumentParser; Record + Replay subcommands stubbed
out, implementations in next tasks.

Adapted from plan: renamed main.swift to SwiftTermReplay.swift to
satisfy Swift's @main + executable-target rule.
Uses openpty + posix_spawn to launch child in a PTY (fork() is
unavailable in modern Swift on Darwin). Tees stdout to:
(a) ttyrec file with little-endian Int32 (sec, usec, len) headers,
(b) parent's stdout for user visibility.

POSIX_SPAWN_SETSID (0x0400 on Darwin) makes the child a new session
leader, which acquires the slave PTY as its controlling terminal.
Tested with 'ls -la /tmp' — produces valid ttyrec format.

Note: arguments after the subcommand name must use -- separator if
they look like flags (e.g. 'record --output file.ttyrec -- ls -la').
NSApp host with TerminalView. Parses ttyrec format (3 little-endian
Int32 headers + payload chunks). Feeds bytes via view.feed(byteArray:)
at recorded timing scaled by --speed multiplier (1.0=real, 0=instant).

Now we can: (a) record any claude scenario once, (b) replay it
deterministically through renderer changes in C.2+. Provides
regression visibility we lack from one-shot live runs.

Smoke-tested: /tmp/test-ls.ttyrec parses to 1 chunk and feeds without
error. (Window display verified manually — running headless replay
exits cleanly via timeout.)
…ements

Captures recorded (2 of 5 planned):
- 01-simple-streaming.ttyrec
- 02-edit-tool.ttyrec

Tool refinements:
- Package.swift excludes Captures/ from compilation (test fixtures only)
- Recorder.swift improvements (+13 lines)
- Replayer.swift improvements (+16/-11 lines)

Missing (deferred to follow-up):
- 03-plan-mode.ttyrec
- 04-rate-limit.ttyrec (best effort)
- 05-permission.ttyrec
- docs/renderer-c1-retrospective.md (C.2 starting points)
- baseline screenshots in docs/renderer-baselines/

Background agent rate-limited mid-Task-6.
SwiftTerm 1.13 internals map (entry points, color/font props, caret).
Hypothesized tearing pattern for 02-edit-tool.ttyrec (pending visual
verification). 5 concrete C.2 starting points: drawRect vs CALayer,
buffer-at-parser vs buffer-at-cell, CVDisplayLink timing, first
acceptance test, prototype risk.

Background-agent-execution lessons: pre-create forks, isolate branches,
prefer inline over background for long-running plans.
kiki830621 added a commit that referenced this pull request May 26, 2026
…40 tests pass

Cumulative milestone: Logos shell + claude host + 5-rule auto-handle.
The #1 killer feature is live: claude no longer blocks on known
prompts (rate-limit / trust / Bash permission / press-Enter) while
you stepped away.

8 test suites total. PR #1 (sub-plan C.1 partial) awaiting review +
merge. Sub-plan C.2 (frame-rate renderer) and sub-plan E (multi-account)
are independent next steps.
@kiki830621 kiki830621 merged commit 4b997f7 into main May 26, 2026
@kiki830621 kiki830621 deleted the renderer-c1-v2 branch May 26, 2026 03:22
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.

1 participant