Skip to content
Merged
Show file tree
Hide file tree
Changes from 124 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
2472251
test(cmux-tui-core): the person's key waits for no shared lock (R-DAE…
lawrencecchen Nov 3, 2026
7dc4598
test(cmux-tui-core): a key waits for no client registry lock (R-DAEMO…
lawrencecchen Nov 3, 2026
f1ea1b6
fix(cmux-tui-core): the person's key reads the client registry's publ…
lawrencecchen Nov 3, 2026
590cb11
fix(cmux-tui-core): the key reads the session's published routes; one…
lawrencecchen Nov 3, 2026
5d0e4a0
test(cmux-tui-core): a key waits for no surface admission lock, with …
lawrencecchen Nov 3, 2026
8e5c8a2
fix(cmux-tui-core): the surface admission budget reserves with atomic…
lawrencecchen Nov 3, 2026
154730a
test(cmux-tui-core): a key waits for neither the link peers nor the p…
lawrencecchen Nov 3, 2026
48c4d9e
test(cmux-tui-core): a change cut short by a panic is never published…
lawrencecchen Nov 3, 2026
4462389
test(cmux-tui-core): a reservation unshares a published route map; a …
lawrencecchen Nov 3, 2026
8f7d405
fix(cmux-tui-core): link peers and host proxy authors are published; …
lawrencecchen Nov 3, 2026
eecb0d8
test(cmux-tui-core): a key waits for no creating-input lock, and for …
lawrencecchen Nov 3, 2026
8a50288
fix(cmux-tui-core): a key skips the creating-input lock while nothing…
lawrencecchen Nov 3, 2026
831686b
test(cmux-tui-core): the surface budget's limits on both arms; a lock…
lawrencecchen Nov 3, 2026
10f1669
fix(cmux-tui-core): drop an unnecessary path qualification in a test …
lawrencecchen Nov 3, 2026
690b82f
test(cmux-tui-core): a poisoned session state never routes by the pub…
lawrencecchen Nov 3, 2026
bb0265f
fix(cmux-tui-core): the lane's surface read takes the old path on a p…
lawrencecchen Nov 3, 2026
3e0f7b2
Merge branch 'fix/p0-typing-s1-relay-peers' into fix/p0-typing-s1-cre…
lawrencecchen Nov 3, 2026
3b2e29f
fix(cmux-tui-core): the creating-input live check reads the routes on…
lawrencecchen Nov 3, 2026
123e363
Merge branch 'fix/p0-typing-s1-creating-input' into fix/p0-typing-s1-…
lawrencecchen Nov 3, 2026
dfe81bf
test(cmux-tui-core): a key waits for neither the sizing nor the activ…
lawrencecchen Nov 3, 2026
0fb7c43
fix(cmux-tui-util): a test dereferences the published u64 once (E0614…
lawrencecchen Nov 3, 2026
8ee8220
Merge branch 'fix/p0-typing-s1-relay-peers' into fix/p0-typing-s1-cre…
lawrencecchen Nov 3, 2026
4fd7672
Merge branch 'fix/p0-typing-s1-creating-input' into fix/p0-typing-s1-…
lawrencecchen Nov 3, 2026
7fad48f
fix(cmux-tui-core): a key skips its sizing note when its view is the …
lawrencecchen Nov 3, 2026
cd9a6dc
fix(cmux-tui-core): the sizing test hook went in above another test h…
lawrencecchen Nov 3, 2026
19dd118
fix(cmux-tui-core): the lane's surface read loads the routes before i…
lawrencecchen Nov 3, 2026
24dd4c6
Merge branch 'fix/p0-typing-s1-relay-peers' into fix/p0-typing-s1-cre…
lawrencecchen Nov 3, 2026
846d412
Merge branch 'fix/p0-typing-s1-creating-input' into fix/p0-typing-s1-…
lawrencecchen Nov 3, 2026
4672321
Merge commit 'ff04cf67b63' into fix/p0-typing-s1-admission
lawrencecchen Nov 3, 2026
c4b9ddb
Merge #34014's squash (4bb12b86ecd) into fix/p0-typing-s1-admission: …
lawrencecchen Nov 3, 2026
e2a052e
Merge feat-cmux-next (8880dae3652e) into fix/p0-typing-s1-admission
lawrencecchen Nov 3, 2026
eaef70c
test(cmux-tui-core): a key does not wait for another writer's blocked…
lawrencecchen Nov 4, 2026
331fe49
fix(cmux-tui-core): a person's key to a hosted terminal goes to the t…
lawrencecchen Nov 4, 2026
4bf5af5
test(cmux-tui-core): after a respawn, keys skip the sizing lock again…
lawrencecchen Nov 4, 2026
5fe770d
fix(cmux-tui-core): a sizing entry follows its terminal across a resp…
lawrencecchen Nov 4, 2026
89414e0
fix(cmux-tui-core): name the input port module without super:: where …
lawrencecchen Nov 4, 2026
8c109c2
Merge branch 'fix/p0-typing-s1-sizing' into fix/p0-typing-s1-input-port
lawrencecchen Nov 4, 2026
ae5c3cf
Merge branch 'feat-cmux-next' into fix/p0-typing-s1-admission
cmux-bot[bot] Nov 4, 2026
8ccc6f0
test(cmux-tui-core): a settled size-state read takes the session lock…
lawrencecchen Nov 4, 2026
8701dbd
fix(cmux-tui-core): a sizing entry looks its surface up only when it …
lawrencecchen Nov 4, 2026
417fab7
fix(cmux-tui-core): the input port's order test can fail; the port co…
lawrencecchen Nov 4, 2026
6d8a5b4
Merge branch 'fix/p0-typing-s1-sizing' into fix/p0-typing-s1-input-port
lawrencecchen Nov 4, 2026
8d40cfa
Merge the squashed S1.3 head (ae5c3cf1bfd, #34146) into fix/p0-typing…
lawrencecchen Nov 4, 2026
e87f276
Merge feat-cmux-next just before #34146's squash (530dd321d1b) into f…
lawrencecchen Nov 4, 2026
1a457f2
Merge #34146's squash (dfcfac60c35) into fix/p0-typing-s1-relay-peers…
lawrencecchen Nov 4, 2026
7e8aa9e
Merge feat-cmux-next (0ae1413031d4) into fix/p0-typing-s1-relay-peers
lawrencecchen Nov 4, 2026
7b90f43
Merge branch 'fix/p0-typing-s1-relay-peers' into fix/p0-typing-s1-cre…
lawrencecchen Nov 4, 2026
b86e5e8
Merge branch 'fix/p0-typing-s1-creating-input' into fix/p0-typing-s1-…
lawrencecchen Nov 4, 2026
4c8d169
Merge remote-tracking branch 'origin/fix/p0-typing-s1-sizing' into fi…
lawrencecchen Nov 4, 2026
7c90c29
fix(cmux-tui-core): the input port refuses only when the host reader …
lawrencecchen Nov 4, 2026
2dd59d8
fix(cmux-tui-core): a key to a failed host link is refused at once on…
lawrencecchen Nov 4, 2026
a3d307a
Merge feat-cmux-next just before #34171's squash into fix/p0-typing-s…
lawrencecchen Nov 4, 2026
6234806
Merge #34171's squash (e039c73b64a) into fix/p0-typing-s1-creating-in…
lawrencecchen Nov 4, 2026
5aa3ec4
Merge feat-cmux-next (2e0b6acc3593) into fix/p0-typing-s1-creating-input
lawrencecchen Nov 4, 2026
f738b2e
Merge remote-tracking branch 'origin/fix/p0-typing-s1-creating-input'…
lawrencecchen Nov 4, 2026
5586fb8
fix(cmux-tui-core): a failed reconnect completion on a failed link al…
lawrencecchen Nov 4, 2026
8b9f34a
test(cmux-tui-core): a frame sent after a key the input port holds mu…
lawrencecchen Nov 4, 2026
91af73e
fix(cmux-tui-core): every other frame to a hosted terminal's host goe…
lawrencecchen Nov 4, 2026
1f3d590
Merge remote-tracking branch 'origin/fix/p0-typing-s1-sizing' into fi…
lawrencecchen Nov 4, 2026
5efb06b
Merge remote-tracking branch 'origin/fix/p0-typing-s1-input-port' int…
lawrencecchen Nov 4, 2026
189ba58
test(cmux-tui-core): an automation write answers after the input port…
lawrencecchen Nov 4, 2026
9afa300
fix(cmux-tui-core): on the input lane only the person's keys answer b…
lawrencecchen Nov 4, 2026
fbafa36
test(cmux-tui-core): an activity subscriber hears the person's keys o…
lawrencecchen Nov 4, 2026
d11ff86
Merge feat-cmux-next before the S1.4 squash (e4a43f9def2) into fix/p0…
lawrencecchen Nov 4, 2026
d34f488
Merge the S1.4 squash (eaa00d9434d, #34174) into fix/p0-typing-s1-siz…
lawrencecchen Nov 4, 2026
f36b4be
Merge feat-cmux-next (2fa7c631ef7c) into fix/p0-typing-s1-sizing
lawrencecchen Nov 4, 2026
9674a79
test(cmux-tui-core): the input lane is on unless CMUX_TUI_RDS_INPUT=0…
lawrencecchen Nov 4, 2026
ba4800d
fix(cmux-tui-core): the input lane is the default; CMUX_TUI_RDS_INPUT…
lawrencecchen Nov 4, 2026
0df96cf
Merge the S1.5 landed head (f36b4be84a0) into fix/p0-typing-s1-input-…
lawrencecchen Nov 4, 2026
9f1f00c
Merge feat-cmux-next before the S1.5 squash (9f173d32a4c) into fix/p0…
lawrencecchen Nov 4, 2026
6801a09
Merge the S1.5 squash (053e300dcaa, #34261) into fix/p0-typing-s1-inp…
lawrencecchen Nov 4, 2026
fbb7767
Merge feat-cmux-next (191537144e99) into fix/p0-typing-s1-input-port
lawrencecchen Nov 4, 2026
3a0af4b
Merge origin/fix/p0-typing-s1-input-port (fbb7767ad5e) into fix/p0-ty…
lawrencecchen Nov 4, 2026
4fe9cb2
Merge origin/fix/p0-typing-s1-input-port-order (3a0af4bea58) into fix…
lawrencecchen Nov 4, 2026
2133c10
test(cmux-tui-core): the input port's reconnect and reply rules from …
lawrencecchen Nov 4, 2026
bbc44c2
fix(cmux-tui-core): a route publication ends the input port's reconne…
lawrencecchen Nov 4, 2026
74d2ad1
Merge feat-cmux-next before the S1.6a squash (45901128f15) into fix/p…
lawrencecchen Nov 4, 2026
c7a4a91
Merge the S1.6a squash (1fa9cfc37ed, #34544) into fix/p0-typing-s1-in…
lawrencecchen Nov 4, 2026
ee8896f
Merge feat-cmux-next (3961c3e98ecc) into fix/p0-typing-s1-input-port-…
lawrencecchen Nov 4, 2026
f9c75f1
test(cmux-tui-core): the review-1 port tests name Frame and input_may…
lawrencecchen Nov 4, 2026
bfd3540
Merge origin/fix/p0-typing-s1-input-port-order (f9c75f1f7a7) into fix…
lawrencecchen Nov 4, 2026
0b2567c
Merge feat-cmux-next (5de31bb8c9d) into fix/p0-typing-s1-default-on
lawrencecchen Nov 4, 2026
b6b0b37
test(cmux-tui-core): a write waiting for a reconnect fails when the r…
lawrencecchen Nov 4, 2026
860edd9
fix(cmux-tui-core): the reader's end, give-up and the owner's detach …
lawrencecchen Nov 4, 2026
02d4593
Merge origin/fix/p0-typing-s1-6c-control-lane (860edd9053e) into fix/…
lawrencecchen Nov 4, 2026
1e84ed3
Merge feat-cmux-next (d1decc7c4474) into fix/p0-typing-s1-6c-control-…
lawrencecchen Nov 4, 2026
ac7ffa2
test(cmux-tui-core): a viewer size behind a held key does not wait an…
lawrencecchen Nov 4, 2026
10b577c
fix(cmux-tui-core): viewer-size frames go on the input port behind it…
lawrencecchen Nov 4, 2026
67023f5
test(cmux-tui-core): the reply-timeout tests take their frame on a ru…
lawrencecchen Nov 4, 2026
4e8dd75
test(cmux-tui-core): the reader's real give-up and the daemon's shutd…
lawrencecchen Nov 4, 2026
476e0bf
docs(cmux-tui-core): the input port docs name reconnect_ended and sta…
lawrencecchen Nov 4, 2026
b005df2
Merge branch 'feat-cmux-next' into fix/p0-typing-s1-input-port-order
cmux-bot[bot] Nov 4, 2026
0b22b65
Merge the landed S1.6b head (b005df28c6a, #35082) into fix/p0-typing-…
lawrencecchen Nov 4, 2026
73837b4
Merge feat-cmux-next before the S1.6b squash (a0cd00b1b87) into fix/p…
lawrencecchen Nov 4, 2026
6821f76
Merge the S1.6b squash (65d098cc113, #35082) into fix/p0-typing-s1-6c…
lawrencecchen Nov 4, 2026
32f0563
Merge feat-cmux-next (ca738232f32f) into fix/p0-typing-s1-6c-control-…
lawrencecchen Nov 4, 2026
65cfc4d
Merge fix/p0-typing-s1-6c-control-lane (32f0563d491: S1.6b squash and…
lawrencecchen Nov 4, 2026
edc0dfb
fix(cmux-tui-core): a viewer size queued behind a held key no longer …
lawrencecchen Nov 4, 2026
d6d7b68
Merge fix/p0-typing-s1-6c2-control-frames (edc0dfbbfae: S1.6c parts 1…
lawrencecchen Nov 4, 2026
ce2e1a6
Merge feat-cmux-next before the S1.6c part 1 squash (c29e44bfa7e) int…
lawrencecchen Nov 4, 2026
4a2b520
Merge the S1.6c part 1 squash (b9864f42e29, #35280) into fix/p0-typin…
lawrencecchen Nov 4, 2026
3bafe07
Merge feat-cmux-next (e424d61b452c) into fix/p0-typing-s1-6c2-control…
lawrencecchen Nov 4, 2026
5ae437a
test(cmux-tui-core): a viewer size or release sent while the input po…
lawrencecchen Nov 4, 2026
01af275
fix(cmux-tui-core): a viewer size sent while the input port waits for…
lawrencecchen Nov 4, 2026
0678016
Merge fix/p0-typing-s1-6c2-control-frames (01af275609c: the #35280 sq…
lawrencecchen Nov 4, 2026
b4bb38b
Merge feat-cmux-next before the S1.6c part 2 squash (cb116d41dd1) int…
lawrencecchen Nov 4, 2026
0f3c411
Merge the S1.6c part 2 squash (c694fd0e056, #35375) into fix/p0-typin…
lawrencecchen Nov 4, 2026
b078664
test(cmux-tui-core): the input port's writer runs at user-interactive…
lawrencecchen Nov 4, 2026
3690c39
fix(cmux-tui-core): the input port's writer runs at user-interactive …
lawrencecchen Nov 4, 2026
5fab0a5
test(cmux-tui-core): false, off and no turn the input lane off too (R…
lawrencecchen Nov 4, 2026
96fd6fb
fix(cmux-tui-core): false, off and no turn the input lane off too, an…
lawrencecchen Nov 4, 2026
d62017f
Merge fix/p0-typing-s1-6d-writer-qos (3690c395049: the port writer at…
lawrencecchen Nov 4, 2026
0c77eb0
test(cmux-tui-core): the port writer's QoS test seam exists only in m…
lawrencecchen Nov 4, 2026
a02e884
fix(cmux-tui-core): the lane log's match arm ends with a semicolon (c…
lawrencecchen Nov 4, 2026
6bfdf88
Merge fix/p0-typing-s1-6d-writer-qos (0c77eb0ac59: the QoS test seam …
lawrencecchen Nov 4, 2026
ad22a1f
Merge feat-cmux-next before the S1.6d squash (b1f8fc4d83e) into fix/p…
lawrencecchen Nov 4, 2026
b8d16a6
Merge the S1.6d squash (7aee9c65172, #35460) into fix/p0-typing-s1-de…
lawrencecchen Nov 4, 2026
4fe7618
Merge feat-cmux-next (8c9aae8b0d94) into fix/p0-typing-s1-default-on
lawrencecchen Nov 4, 2026
2c75845
test(cmux-tui): a terminal's next output frame must reach it while a …
lawrencecchen Nov 4, 2026
a91fb3a
fix(cmux-tui): durable publications of terminal output commit on a pe…
lawrencecchen Nov 4, 2026
bd82598
Merge feat-cmux-next (9df8d5fec0db) into fix/p0-typing-s1-default-on
lawrencecchen Nov 4, 2026
4e9076a
Merge fix/p0-typing-output-publisher (a91fb3a343e, the #35413 echo st…
lawrencecchen Nov 4, 2026
454b2c1
test(cmux-tui): output publication tests use the channel names alread…
lawrencecchen Nov 4, 2026
22eac84
Merge fix/p0-typing-output-publisher (454b2c14e7e: test-only lint fix…
lawrencecchen Nov 4, 2026
19bcc9e
test(cmux-tui): an exit commits the last reported directory; an alert…
lawrencecchen Nov 4, 2026
6a64e18
fix(cmux-tui): an exit commits the last reported directory; alerts ke…
lawrencecchen Nov 4, 2026
3108cf0
test(cmux-tui): a host loss commits the directory the shell reported …
lawrencecchen Nov 4, 2026
b2ebe68
fix(cmux-tui): a terminal's stream end settles its publications befor…
lawrencecchen Nov 4, 2026
e1e7288
test(cmux-tui): the host-loss test adopts its seeded terminal before …
lawrencecchen Nov 4, 2026
8202332
test(cmux-tui): the host-loss test moves its workspace key (clippy re…
lawrencecchen Nov 4, 2026
2f52b7e
test(cmux-tui): the tree entity check must hold when a reader changes…
lawrencecchen Nov 4, 2026
429c696
fix(cmux-tui): the tree entity check compares the two builders only o…
lawrencecchen Nov 4, 2026
dd67a78
test(cmux-tui): a person's key to an idle input port is on the host s…
lawrencecchen Nov 4, 2026
ef166da
fix(cmux-tui): a person's key to an idle input port is written on its…
lawrencecchen Nov 4, 2026
adf5500
Merge feat-cmux-next (04976c9f6c51) into fix/p0-typing-s1-default-on
lawrencecchen Nov 4, 2026
b895605
Merge fix/p0-typing-output-publisher (429c696d427, #35765 head) into …
lawrencecchen Nov 4, 2026
9411d37
Merge fix/p0-typing-s1-port-inline-write (ef166da6f4d: a key to an id…
lawrencecchen Nov 4, 2026
37fd891
test(cmux-tui): a notification queued before a terminal's exit names …
lawrencecchen Nov 4, 2026
eff16dc
fix(cmux-tui): a terminal's settle takes its notifications too; no su…
lawrencecchen Nov 4, 2026
e24fcfe
fix(cmux-tui): the publisher's settle partitions its queue into two V…
lawrencecchen Nov 4, 2026
b72a7e3
test(cmux-tui): the exit-notification test checks that the notificati…
lawrencecchen Nov 4, 2026
019ad0b
test(cmux-tui): the exit-notification test records the process end, s…
lawrencecchen Nov 4, 2026
b1e8db9
test(cmux-tui): the inline key write's fallbacks keep a key from wait…
lawrencecchen Nov 4, 2026
3eede48
test(cmux-tui): the exit-notification test names TerminalExit through…
lawrencecchen Nov 4, 2026
ecc1116
test(cmux-tui): the full-socket test relies on Frame::new's protocol …
lawrencecchen Nov 4, 2026
7293b1b
test(cmux-tui): keys to a host that stopped reading never block their…
lawrencecchen Nov 4, 2026
4cc7e1b
fix(cmux-tui): the inline key write checks the host socket has room b…
lawrencecchen Nov 4, 2026
fe7de9f
Merge fix/p0-typing-s1-port-inline-write (4cc7e1b9774: the inline key…
lawrencecchen Nov 4, 2026
b6b0309
Merge fix/p0-typing-output-publisher (3eede4880f2, #35765 head) into …
lawrencecchen Nov 4, 2026
bf46130
fix(cmux-tui): the test title hook adds no crash-class hit (#35765 cr…
lawrencecchen Nov 4, 2026
89075c0
docs(cmux-tui): the room check's poll can sleep about 10 us on macOS …
lawrencecchen Nov 4, 2026
a35e021
fix(cmux-tui): the publication check and a test hook recover a poison…
lawrencecchen Nov 4, 2026
e291928
Merge fix/p0-typing-output-publisher (a35e02157d2, #35765 head) into …
lawrencecchen Nov 4, 2026
91c7515
Merge fix/p0-typing-s1-port-inline-write (89075c0eb96, #35872 head) i…
lawrencecchen Nov 4, 2026
74d146b
Merge feat-cmux-next before the #35872 squash (728ed6cc8d3) into fix/…
lawrencecchen Nov 4, 2026
fc363f3
Merge the #35872 squash (a7fac9e4832) into fix/p0-typing-s1-default-o…
lawrencecchen Nov 4, 2026
ceeb9a0
Merge feat-cmux-next before the #35765 squash (0b9e1668a7b) into fix/…
lawrencecchen Nov 4, 2026
63e45c2
Merge the #35765 squash (2292a30d124) into fix/p0-typing-s1-default-o…
lawrencecchen Nov 4, 2026
afadf63
Merge feat-cmux-next (cd5abc2bce7e) into fix/p0-typing-s1-default-on
lawrencecchen Nov 4, 2026
ff22950
test(CmuxNextDaemon): the input lane's off switch reaches the Chief o…
lawrencecchen Nov 5, 2026
c8900c4
fix(CmuxNextDaemon): the input lane's off switch reaches the Chief ow…
lawrencecchen Nov 5, 2026
f69479f
release notes: typing stays fast while agents and scripts work (the S…
lawrencecchen Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public nonisolated struct DaemonDiagnosticKnobs: Sendable, Equatable {
/// App launch knob to daemon variable: key-press flow marks (scripts/cmux-next/trace.py), the
/// create-path debug timing marks, the terminal host model (`holder`: the install's one holder
/// instead of a host process per terminal; scripts/cmux-next/holder-dogfood.py, default off),
/// the R-DAEMON-STATE stage switches (`1` turns a stage's new path on; default off, deleted with
/// the old path when the stage passes; handoff/rewrites/R-DAEMON-STATE/DESIGN.md section 3), and
/// the R-LIFECYCLE keepers switch (`0` keeps the app's daemon and Chief daemon running after the
/// app left with nothing to keep them, as before; default on; deleted when the stage has passed
/// dogfood).
/// the R-DAEMON-STATE stage switches (stage S1's input lane is on by default and `0` keeps its old
/// path for one nightly; a switch is deleted with its old path when the stage passes;
/// handoff/rewrites/R-DAEMON-STATE/DESIGN.md section 3), and the R-LIFECYCLE keepers switch (`0`
/// keeps the app's daemon and Chief daemon running after the app left with nothing to keep them,
/// as before; default on; deleted when the stage has passed dogfood).
public static let names: [(app: String, daemon: String)] = [
("CMUX_NEXT_TRACE_FLOWS", "CMUX_TRACE_FLOWS"),
("CMUX_NEXT_TUI_DEBUG_SPANS", "CMUX_TUI_DEBUG_SPANS"),
Expand Down
3 changes: 3 additions & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ mod terminal_host_link;
mod terminal_move;
mod terminal_move_topology;
mod terminal_progress;
mod terminal_publisher;
mod terminal_reap;
#[cfg(unix)]
mod terminal_rehost;
Expand Down Expand Up @@ -669,6 +670,8 @@ pub struct Mux {
terminal_command_history: AtomicBool,
/// The command history worker's bounded queue (`mux/command_history.rs`).
command_history_worker: Mutex<Option<SyncSender<command_history::CommandHistoryMessage>>>,
/// Makes the durable commits terminal output asks for, off the output readers.
terminal_publisher: terminal_publisher::TerminalPublisher,
notification_ledger: Mutex<VecDeque<ResourceNotification>>,
/// Per-client read marks. The shared unread marker above answers "does this terminal need
/// attention on the shared console"; this map answers "has this client install seen this
Expand Down
1 change: 1 addition & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ impl Mux {
terminal_notifications: Mutex::new(terminal_notifications),
terminal_command_history: AtomicBool::new(false),
command_history_worker: Mutex::new(None),
terminal_publisher: Default::default(),
notification_ledger: Mutex::new(notification_ledger),
notification_reads: Mutex::new(notification_reads),
notification_read_prunes: Mutex::new(Vec::new()),
Expand Down
3 changes: 3 additions & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ impl Mux {
for surface in surfaces {
terminal_gaps.extend(surface.finish_terminal_reader(terminal_reader_deadline));
}
// The readers stopped: the publications they queued commit now, in
// the same grace, as when the readers made them inline.
self.finish_terminal_publications(terminal_reader_deadline);
if self.journal_ingress.is_current_writer_thread() {
// The readers stopped: the store's last write is safe here too.
self.output_store.shutdown(self);
Expand Down
219 changes: 219 additions & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux/terminal_publisher.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
//! The terminal publisher: one thread per mux makes the durable commits a
//! terminal's output asks for, so the terminal's output reader never waits
//! for the workspace registry (#35413, L6 typing echo stall).
//!
//! A terminal's output reader applies the host's (or the PTY's) output to the
//! daemon's terminal and hands it to the attached views. The same output can
//! change durable facts: the shell's directory (OSC 7), the progress and
//! program status (OSC 9;4, OSC 7501), the command and prompt facts, and
//! "last output", pushed at most every 5 s while the terminal prints
//! (`terminal_activity.rs`). Each is a resource commit under the workspace
//! registry lock, and so is a notification the output posts (OSC 9, 777, 99)
//! or a bell's attention mark. The reader made them itself, between two
//! output frames. Under load the registry lock waits up to 1.5 s, and the next
//! frame, the echo of a key the person typed, waited in the reader's queue:
//! in the s17d diagnostic rounds every echo gap over 20 ms (16, to 501 ms)
//! began inside one of those commits, with the input lane on and off.
//!
//! The reader now only checks, in memory, whether a publication is due, and
//! queues it here. The publisher runs the queue in order on its own thread. A
//! terminal has at most one publication queued: changes that arrive while it
//! waits are published with it, as the latest state, which is what every
//! publication commits. Notifications and bell marks queue one by one, in
//! output order. Callers on other threads (adoption, a reconnect's
//! settlement, a terminal read) still publish directly.

use super::*;
use crate::terminal_metadata::TerminalNotification;

/// The publisher's queue and its one worker thread.
#[derive(Default)]
pub(crate) struct TerminalPublisher {
shared: Arc<PublisherShared>,
}

#[derive(Default)]
struct PublisherShared {
queue: Mutex<PublisherQueue>,
/// Wakes the worker (a job, or the close) and a finish waiting for it.
changed: Condvar,
}

#[derive(Default)]
struct PublisherQueue {
jobs: VecDeque<PublisherJob>,
/// The worker thread, while one runs. It waits on `changed` for jobs.
worker: Option<std::thread::ThreadId>,
/// The worker runs a job it took off `jobs`.
busy: bool,
/// The terminal readers stopped (shutdown or drop): no job is taken.
closed: bool,
}

enum PublisherJob {
/// The terminal's pending directory, progress, activity and program
/// status (`Surface::publish_pending_directory`, `publish_pending_progress`).
Publish(Arc<Surface>),
/// The notifications its output asked for (OSC 9, OSC 777, OSC 99).
Notify(SurfaceId, Vec<TerminalNotification>),
/// The attention mark of a bell.
Bell(SurfaceId),
}

impl PublisherJob {
/// Whether this is `surface`'s queued publication.
fn publishes(&self, surface: &Arc<Surface>) -> bool {
matches!(self, Self::Publish(queued) if Arc::ptr_eq(queued, surface))
}

fn run(self, mux: &Weak<Mux>) {
match self {
Self::Publish(surface) => {
surface.publish_pending_directory();
surface.publish_pending_progress();
}
Self::Notify(surface, notifications) => {
if let Some(mux) = mux.upgrade() {
mux.post_terminal_notifications(surface, notifications);
}
}
Self::Bell(surface) => {
if let Some(mux) = mux.upgrade() {
mux.post_bell_notification(surface);
}
}
}
}
}

impl TerminalPublisher {
fn push(&self, mux: &Arc<Mux>, job: PublisherJob) {
let mut queue = self.shared.queue.lock().unwrap_or_else(PoisonError::into_inner);
if queue.closed {
return;
}
if let PublisherJob::Publish(surface) = &job
&& queue.jobs.iter().any(|queued| queued.publishes(surface))
{
return;
}
queue.jobs.push_back(job);
if queue.worker.is_some() {
self.shared.changed.notify_all();
return;
}
let shared = self.shared.clone();
let weak = Arc::downgrade(mux);
match std::thread::Builder::new()
.name("terminal-publisher".into())
.spawn(move || PublisherShared::run(&shared, &weak))
{
Ok(worker) => queue.worker = Some(worker.thread().id()),
Err(error) => {
// No thread: publish here, as the reader did before.
eprintln!("cmux-tui: terminal publisher did not start: {error}");
let jobs = std::mem::take(&mut queue.jobs);
drop(queue);
let weak = Arc::downgrade(mux);
for job in jobs {
job.run(&weak);
}
}
}
}

/// Close the queue, then wait (until `deadline`) for the worker to finish
/// the jobs already queued. Called after the terminal readers stopped, so
/// their publications commit before the journal stops, as when the
/// readers made them. On the worker itself (its job dropped the last mux
/// reference) it only closes.
fn finish(&self, deadline: Instant) {
let mut queue = self.shared.queue.lock().unwrap_or_else(PoisonError::into_inner);
queue.closed = true;
self.shared.changed.notify_all();
if queue.worker == Some(std::thread::current().id()) {
return;
}
while queue.worker.is_some() && (queue.busy || !queue.jobs.is_empty()) {
let Some(left) = deadline.checked_duration_since(Instant::now()) else { return };
queue = self
.shared
.changed
.wait_timeout(queue, left)
.unwrap_or_else(PoisonError::into_inner)
.0;
}
}
}

impl Drop for TerminalPublisher {
fn drop(&mut self) {
let mut queue = self.shared.queue.lock().unwrap_or_else(PoisonError::into_inner);
queue.closed = true;
self.shared.changed.notify_all();
}
}

impl PublisherShared {
/// The worker: run jobs in order until the queue is closed and empty.
fn run(&self, mux: &Weak<Mux>) {
loop {
let job = {
let mut queue = self.queue.lock().unwrap_or_else(PoisonError::into_inner);
loop {
if let Some(job) = queue.jobs.pop_front() {
queue.busy = true;
break job;
}
if queue.closed {
queue.worker = None;
self.changed.notify_all();
return;
}
queue = self.changed.wait(queue).unwrap_or_else(PoisonError::into_inner);
}
};
// A panicking publication must not stop the publications after it.
if std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| job.run(mux))).is_err() {
eprintln!("cmux-tui: a terminal publication panicked");
}
let mut queue = self.queue.lock().unwrap_or_else(PoisonError::into_inner);
queue.busy = false;
if queue.jobs.is_empty() {
// A finish may wait for the queue to drain.
self.changed.notify_all();
}
}
}
}

impl Mux {
/// Queue `surface`'s pending publication (its reader found one due). A
/// publication already queued for it publishes this change too.
pub(crate) fn queue_terminal_publication(self: &Arc<Self>, surface: &Arc<Surface>) {
self.terminal_publisher.push(self, PublisherJob::Publish(surface.clone()));
}

/// Queue the notifications `surface`'s output asked for, after the
/// publications its earlier output queued.
pub(crate) fn queue_terminal_notifications(
self: &Arc<Self>,
surface: SurfaceId,
notifications: Vec<TerminalNotification>,
) {
if !notifications.is_empty() {
self.terminal_publisher.push(self, PublisherJob::Notify(surface, notifications));
}
}

/// Queue the attention mark of a bell in `surface`'s terminal.
pub(crate) fn queue_bell_notification(self: &Arc<Self>, surface: SurfaceId) {
self.terminal_publisher.push(self, PublisherJob::Bell(surface));
}

/// After the terminal readers stopped: let what they queued commit (until
/// `deadline`), then take no more.
pub(super) fn finish_terminal_publications(&self, deadline: Instant) {
self.terminal_publisher.finish(deadline);
}
}
1 change: 1 addition & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mod tab_workspace_move;
mod tabs;
mod terminal_exit_restart;
mod terminal_moves;
mod terminal_publisher;
mod terminal_registry;
mod terminal_views;
mod view_close_replay;
Expand Down
109 changes: 109 additions & 0 deletions cmux-tui/crates/cmux-tui-core/src/mux/tests/terminal_publisher.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//! The terminal publisher (`mux/terminal_publisher.rs`, #35413): an output reader queues the durable commits its
//! output asks for and never waits for the workspace registry; the publisher still commits each of them, in output
//! order, once the registry is free.

use std::sync::mpsc::sync_channel;

use super::*;

/// Holds `mux`'s workspace registry on another thread until the returned sender fires.
fn hold_registry(mux: &Arc<Mux>) -> (SyncSender<()>, std::thread::JoinHandle<()>) {
let (entered, held) = sync_channel(1);
let (release, released): (SyncSender<()>, Receiver<()>) = sync_channel(1);
let holder = {
let mux = mux.clone();
std::thread::spawn(move || mux.hold_workspace_registry_for_test(entered, released))
};
held.recv_timeout(Duration::from_secs(10)).expect("the holder took the workspace registry");
(release, holder)
}

fn wait_for(what: &str, done: impl Fn() -> bool) {
let deadline = Instant::now() + Duration::from_secs(10);
while !done() {
assert!(Instant::now() < deadline, "timed out waiting until {what}");
std::thread::sleep(Duration::from_millis(2));
}
}

/// A terminal's output made its "last output" fact due. Queuing the publication returns at once while the
/// registry is held, nothing commits until the registry is free, and then the publication commits a revision.
#[test]
fn a_queued_publication_commits_once_the_registry_is_free() {
let mux = test_mux();
let surface = mux.new_workspace(None, Some((80, 24))).unwrap();
// What the creation left pending (its launch directory) is published first.
surface.publish_pending_directory();
surface.publish_pending_progress();
let before = mux.with_state(|state| state.resource_revision);
surface.apply_stream_output_for_test(b"output").unwrap();

let (release, holder) = hold_registry(&mux);
let queued = Instant::now();
surface.queue_pending_publications();
let queue_time = queued.elapsed();
std::thread::sleep(Duration::from_millis(50));
let while_held = mux.with_state(|state| state.resource_revision);
release.send(()).unwrap();
holder.join().unwrap();

assert!(queue_time < Duration::from_secs(1), "queuing waited {queue_time:?} for the registry");
assert_eq!(while_held, before, "a publication committed while the registry was held");
wait_for("the queued publication committed", || {
mux.with_state(|state| state.resource_revision) > before
});
// The publisher took the change: nothing is due any more.
surface.queue_pending_publications();
let after = mux.with_state(|state| state.resource_revision);
std::thread::sleep(Duration::from_millis(50));
assert_eq!(
mux.with_state(|state| state.resource_revision),
after,
"a publication with nothing due committed again"
);
}

/// The notifications a terminal's output posts and a bell's attention mark are durable notifications too: the
/// reader queues them, and they post in output order once the registry is free.
#[test]
fn queued_terminal_notifications_post_in_order_once_the_registry_is_free() {
let mux = test_mux();
let surface = mux.new_workspace(None, Some((80, 24))).unwrap();
let notification = |title: &str| crate::terminal_metadata::TerminalNotification {
title: title.into(),
body: String::new(),
level: NotificationLevel::Info,
};
let titles = || {
let mut titles = mux
.resource_notifications(16)
.into_iter()
.map(|notification| notification.title)
.collect::<Vec<_>>();
titles.reverse();
titles
};

let (release, holder) = hold_registry(&mux);
let queued = Instant::now();
// The bell first: a bell posts no mark while the terminal has an unread notification.
mux.queue_bell_notification(surface.id);
mux.queue_terminal_notifications(
surface.id,
vec![notification("first"), notification("second")],
);
mux.queue_terminal_notifications(surface.id, vec![notification("third")]);
let queue_time = queued.elapsed();
std::thread::sleep(Duration::from_millis(50));
let while_held = titles();
release.send(()).unwrap();
holder.join().unwrap();

assert!(queue_time < Duration::from_secs(1), "queuing waited {queue_time:?} for the registry");
assert!(
while_held.is_empty(),
"notifications posted while the registry was held: {while_held:?}"
);
wait_for("the queued notifications posted", || titles().len() == 4);
assert_eq!(titles(), ["Bell", "first", "second", "third"]);
}
Loading