acp pane: terminal handling: replay on resize, no wrapping live rows, hidden cursor, no echo, no login banner (items 2-4 of the user's brief) #86
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/rexcity!86
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/rexcity-49ot9"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Items 2, 3 and 4 of the brief on the acp pane (
rexcity acp follow): terminal handling. Items 1, 5, 6, 7 and 8, the log lines and their colours, are the other bead's and are not touched. Work is on main atfd06139.What changed
ESC[?7l) and on (ESC[?7h). A row still too long for the terminal is cut at its edge and never becomes two. The cursor is hidden while the pane follows and shown again when it ends.SIGINT,SIGTERMandSIGHUPnow cancel the follow, so the restore also runs on a signal.ISIGstays on, so^Cstill ends it. The termios ioctl numbers for darwin and linux are instdin_darwin.goandstdin_linux.go.login(1).rex.WithoutLoginmakesSplitsend"login": falsein the terminal block's options, andopenPaneasks for it for a view's pane only. Tui agents' panes and the city's declared panes are started as before, so the PATH the login shell gives them is unchanged. A tab's first pane is created byrex session neworrex window new, which start the program directly, so it never had a banner.Decision left to the executor. The replay covers the tail of the log, not only what follows the last
━━header. A screen after a resize then looks as it did before it. Splitting into several PRs was not needed: the three items are one change in one package, plus the one-option change ininternal/rex.Before and after
Each run is a real pty running
rexcity acp follow(main's build, then this branch's) on a copy of~/.rexcity/39545500/roles__worker-gcg-session-81c764ce….log. I copied the log elsewhere and appended a call that has been running for 12 s; nothing under~/.rexcitywas changed. The screens come from a small terminal emulator that honours autowrap andESC[A,ESC[J,ESC[HandESC[2J; the last rows are shown.Item 2, resize 100 to 60 columns with a call running. Before, the live rows are duplicated and the rows above them keep the 100-column layout. After, the screen is cleared and drawn once at 60 columns.
The
▷ Bash running 1h09mrow is aSkillcall that has no end in this log. That is item 1 and is untouched.Item 2, the pty says 100 columns and the terminal draws 41 (the winsize mismatch from the brief, not worked around beyond the cut). Before, the live rows wrap and ghost rows are left. After, each live row is one row, cut at the edge.
Item 3, typing
hello, the down arrow andESC 4into the pane.At rest the terminal's
ECHOandICANONare off while the follower runs and back on afterSIGINT:(False, False)then(True, True).Item 4, a split of the follower's pane in a scratch Rex session.
Checks
go vet ./...,GOOS=linux go vet ./...andgo test ./...pass.REXCITY_LIVE_TESTS=1 go test ./internal/rexpasses. It asserts that a default split shows the banner and alogin=falseone does not.[Unreleased]inCHANGELOG.md. The README describes the replay, autowrap, cursor, input and login behaviour.terminalBlockwith and without login;testdata/pane/demo_bytes.goldenis regenerated: it now holds the cursor hide and show and the?7l/?7hpairs.Not done here
TIOCSWINSZon split and resize, which is what item 2 says to file there. The terminal blocks I created by API report 80×24 with no client laid out. I have no tracker for Rex, so the Operator needs to forward this to Rex's authors.in_progresswhen execution starts (outside this repository).Bead: rexcity-49ot9
Review of
981d321397for rexcity-49ot9. Checks of the head: success.Verdict
fail
Findings
CHANGELOG.mdunder[Unreleased]. Since this branch was cut, main has #83 (83bb714), and main'sREVIEW.md("Changelog and releases") now says a pull request's note "goes in a fragment of its own, a new file in.changelog/, and never inCHANGELOG.md, which only a release writes". The work bead asks for a fragment once that change has merged, and it has. The head merges into main with no conflict, but the result breaks that rule. Fix: rebase onto main (83bb714), drop theCHANGELOG.mdhunk, and put the three### Fixedbullets in a new fragment, say.changelog/acp-pane-terminal.md, with nothing but the level-3 heading and its bullets.remember) and :282 (entryAtOrBefore): this regresses the linear-time property that 0.33.0's note promises ("a long word in the agent's text ... is wrapped in linear time and no longer freezes the pane") on exactly the pane that matters, a live terminal one. When one entry is longer than2*replayTail, each 32 KiB write over that size runsentryAtOrBefore. It finds no entry start afterfromand scans back to the entry's start (O(n)), thenappend([]byte(nil), p.hist[0:]...)copies the whole buffer (O(n)). For an entry of n bytes that is O(n²/32 KiB). I measured it with a throwaway test (not committed) on aLive: truepane, writing one sentence holding a single word in 32 KiB pieces, asfollowreads them. 2 MiB took 0.27 s on this head and 0.40 s on main. 8 MiB took 6.5 s here and 0.77 s on main. 16 MiB took 19.9 s here and 1.6 s on main. The pane freezes for that long, andhistkeeps the whole entry. The existingTestAWordOfMegabytesIsCutAtTheWidthInLinearTimeusesplainRig(not Live), so it cannot catch this. Possible fixes: track the offset of the last entry start as bytes arrive, so a trim never rescans. Or, when no entry begins at or afterfrom, stop keeping more than a bound and mark the replay as starting mid-entry, or drop the oversized entry fromhist. Either way, add the Live case to that test.replay): the replay resetsp.callsand re-reads only the last 32 KiB. A call whose▷start entry is older than that, such as a longgo testwhile parallel calls or a long turn fill the log, loses its running row at a resize, though it is still running. Its end then has no registered call. It may be worth saying so in the README paragraph on the replay, or carrying the still-running calls across the replay.TestRunningLinesAreWrittenWithAutowrapOffAndItIsOnAgainAfterThemsetssc.nowrap = trueby hand and feeds the emulator 45x. That tests the test's screen emulator, not the pane. The first half (the?7l…?7hpair around the live rows) is the real assertion.Verified
REVIEW.mdandREADME.md, and the whole diff (18 files, +580/-73): follow.go, pane.go, status.go, stdin*.go, rex.go, rpp tabs/view/runtime and their tests.WriteandIdlereplay the kept tail onto a cleared screen (ESC[H ESC[2J). Call start times come from the log's stamps, so running times survive the replay.trackis muted while replaying, so no second OSC 7501 is sent. Live rows sit between?7land?7h. The cursor is hidden at the first redraw and shown inFlush. All correct apart from the findings above.hushInputclears ECHO/ICANON/IEXTEN and keeps ISIG, drains stdin in a goroutine, and its deferred restore also runs on SIGINT/SIGTERM/SIGHUP throughsignal.NotifyContext.followreturnsctx.Err()at its poll andFollowmapscontext.Canceledto exit 0. The termios ioctls are right for darwin (TIOCGETA/TIOCSETA) and linux (TCGETS/TCSETS).rex.WithoutLoginputs"login": falseonly on the view's ownSplit, not on declared panes or a tui agent's pane. The fake Rex andTestAViewsPaneIsNoLoginShellAndNoOtherPaneIscover this.origin/main(83bb714): clean, no conflict. Forge saysmergeable.go vet ./...,GOOS=darwin GOARCH=arm64 go vet ./...andGOOS=linux go vet ./...pass, andgo test ./...passes (all packages).go test -racepasses forinternal/rexandinternal/rppand reports no data race ininternal/acpbox. Its only failure there, the 1 s wall-clock bound ofTestAWordOfMegabytesIsCutAtTheWidthInLinearTimeunder the race detector, fails the same way on main, so it is not this PR's.-base main -warn missing-fragment) on the merged tree, givesvalid=trueand exit 0. The tool accepts a note inCHANGELOG.md; the first finding isREVIEW.md's rule, not the tool's.981d321397a31b291a62Review of
a31b291a62for rexcity-49ot9 (round 2, after review 221 on981d321). Checks of the head: success.Verdict
pass
Findings
fd06139", "The changelog check (v1.6.0, offline) is valid" and "The note is under[Unreleased]inCHANGELOG.md". The note is now.changelog/acp-pane-terminal.md, the branch is on51dffc8, and the description does not mention the new rule that an entry too long to fit twice the tail is dropped. Main's squash commits carry the title only, so history is unaffected. Fix: edit the description. That needs no new head.trim): when an entry outgrows twice the tail,keepis almost always 0 in practice. While that entry was between 32 and 64 KiB, an earlier trim already cuthistdown to the entry alone, so there is nothing before it left to keep. A resize in the middle of such an entry then clears the screen and draws only the rest of it, unstyled and cut with…. Earlier sentences are gone, and so is the line of a call still running. I checked this with a throwaway test:Before.and a running▷ Bash #1, then a 150 KB sentence in 32 KiB pieces, then a resize. The README paragraph states the limitation for calls, and the case needs an entry over 64 KiB, so it is not blocking. The commit message's "A replay in the middle of such an entry lays out what was kept before it" overstates it. If it ever matters, keep the entries before a long entry when the trim first cuts at it.Verified
Round 1's findings are all addressed:
.changelog/acp-pane-terminal.md: only### Fixedand three bullets.CHANGELOG.mdis untouched against main, and the branch is rebased onto main's tip,51dffc8.rememberis linear now. Entry starts are recorded as bytes arrive (scan), sotrimusessort.SearchIntsand never rescans. An entry over 2×32 KiB is dropped as it arrives (discard), and the capacity is bounded.TestAWordOfMegabytesOnATerminalIsKeptForAReplayInLinearTime(16 MiB, 0.12 s here), plusTestKeepingTheTailOfAnEntryLongerThanItIsInLinearTimefor the bookkeeping alone.A throwaway randomized test (not committed) drove
rememberwith 300 random logs. Entries were stamps,▶ gcand━━heads, continuation lines and some entries up to 200 KB, written in chunks of 1 B to 40 KiB, 3,753 of the writes while dropping. After every write it checked four things:replayed()begins at a recorded start, is no longer than the tail when an entry begins in it, and holds only whole entries while dropping.No violation.
I read the work bead (items 2-4 and the first decision), its round-1 note, the PR description, main's
REVIEW.mdandREADME.md, and the whole diff (18 files, +733/-73).Item 2 is as reviewed in round 1. A resize replays the kept tail onto a cleared screen, and
trackis muted while replaying, so no second OSC 7501 is sent. Live rows sit between?7land?7h. The cursor is hidden while following and shown inFlush.Item 3:
hushInputand the signal-cancelled context are unchanged. Item 4:rex.WithoutLoginapplies to a view's own split only, as before.Merged the head into
origin/main(51dffc8): a fast-forward, clean. The forge saysmergeable.On the merged tree, with the city's variables removed (proved: 0), these pass:
go vet ./...,GOOS=darwin GOARCH=arm64 go vet ./...andGOOS=linux go vet ./...;go test ./..., all packages;go test -race -count=1forinternal/acpbox,internal/rexandinternal/rpp;-count=3.The changelog check, built from changelog v2.1.0's source with
-base main -warn missing-fragmenton the merged tree, givesvalid=true, no warning, exit 0.The head's checks: success.