Skip to content
Closed
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
fc2c172
Add cmux share worker: per-session Durable Object for multiplayer wor…
lawrencecchen Jul 19, 2026
edabd35
Share worker: token-claim host identity, deploy workflow
lawrencecchen Jul 19, 2026
1f72e6e
Web: /share/[code] viewer, share token mint API, session chat + cursors
lawrencecchen Jul 19, 2026
fd17277
Share token route: optional host-claim refresh for Mac reconnect
lawrencecchen Jul 19, 2026
19ea0cf
Slices 2-3 relay + web: compose ops, pixel panes (WebCodecs), browser…
lawrencecchen Jul 19, 2026
c33f67d
Chat panel: track unread via collapse-time state, not render-time ref
lawrencecchen Jul 19, 2026
a26c27e
Document multiplayer workspace sharing
lawrencecchen Jul 19, 2026
089b4c6
Add dev-proof script: end-to-end session flow against a deployed shar…
lawrencecchen Jul 19, 2026
7f6b7fa
Add macOS host for multiplayer workspace sharing (slice 1)
lawrencecchen Jul 19, 2026
ba5ae65
Pixel still codec: JPEG or WebP, sniffed by the viewer
lawrencecchen Jul 19, 2026
d0f5e39
Add guest-probe script for live host dogfood
lawrencecchen Jul 19, 2026
80c6b16
Share host slices 2+3: pixel streaming, composer co-editing, browser …
lawrencecchen Jul 19, 2026
dd03e02
Share DO: report dropped subscriber counts on disconnect/deny
lawrencecchen Jul 19, 2026
017dbb4
Share DO: named NUL sub-key separator; fix dropped-subscriber split
lawrencecchen Jul 19, 2026
6aa0435
Address review findings: create-gated sessions, unshare pruning, sub …
lawrencecchen Jul 19, 2026
b61d750
Regenerate legacy agent-session bundles from shared composer sources
lawrencecchen Jul 19, 2026
7b0724f
Extract spliceDiff into a pure module
lawrencecchen Jul 19, 2026
017507c
Merge remote-tracking branch 'origin/main' into feat-mpshare-do
lawrencecchen Jul 24, 2026
f4f6ba9
Add red tests: session capacity caps, share API rate limits, token-re…
lawrencecchen Jul 24, 2026
b1fa20c
test: define Swift multiplayer boundaries
lawrencecchen Jul 24, 2026
1743212
test: harden multiplayer transport boundaries
lawrencecchen Jul 24, 2026
f53161a
Build terminal-only workspace sharing v1
lawrencecchen Jul 24, 2026
8392eb3
Merge remote-tracking branch 'origin/main' into feat-mpshare-do
lawrencecchen Jul 24, 2026
e059ab4
test: cover multiplayer dogfood blockers
lawrencecchen Jul 24, 2026
85f073a
Fix multiplayer dogfood blockers
lawrencecchen Jul 24, 2026
31d28c9
Fix share header test isolation
lawrencecchen Jul 24, 2026
00dab51
test: cover final multiplayer interaction gaps
lawrencecchen Jul 24, 2026
7eb8515
Close final multiplayer interaction gaps
lawrencecchen Jul 24, 2026
f15d141
test: cover ACK backpressure during reconnect
lawrencecchen Jul 24, 2026
a983838
Preserve shares across ACK reconnect races
lawrencecchen Jul 24, 2026
8227a2e
test: cover stale share socket cancellation
lawrencecchen Jul 24, 2026
829b37a
Preserve replacement share sockets after backpressure
lawrencecchen Jul 24, 2026
803aedb
test: record exact share socket cancellation
lawrencecchen Jul 24, 2026
7ec2746
test: cover delayed share acknowledgements
lawrencecchen Jul 24, 2026
f6e56c6
Bind share acknowledgements to socket generations
lawrencecchen Jul 24, 2026
ad29d54
test: cover stale final share acknowledgement
lawrencecchen Jul 24, 2026
1a29f66
Preserve replacement sockets during final acknowledgements
lawrencecchen Jul 24, 2026
6773d33
test: cover stale session-end teardown
lawrencecchen Jul 24, 2026
5e61dd4
Defer share teardown until the current socket stops
lawrencecchen Jul 24, 2026
cc628f6
test: cover manual share stop behind acknowledgement
lawrencecchen Jul 24, 2026
17b9e2c
Make manual share teardown bypass delivery barriers
lawrencecchen Jul 24, 2026
5f3168f
test: cover stalled send during manual share stop
lawrencecchen Jul 24, 2026
c7efbcd
Bound final share teardown delivery
lawrencecchen Jul 24, 2026
7ba1b1b
test: cover multiplayer terminal transport failures
lawrencecchen Jul 24, 2026
0a0c5fd
test: cover multiplayer terminal delivery gaps
lawrencecchen Jul 25, 2026
54c23bc
Fix multiplayer terminal transport and DO restore
lawrencecchen Jul 25, 2026
d7847c4
Fix live multiplayer proof clients
lawrencecchen Jul 25, 2026
aba9410
test: cover tagged multiplayer share origin
lawrencecchen Jul 25, 2026
08eb352
Fix tagged multiplayer share origin
lawrencecchen Jul 25, 2026
36118ef
Merge remote-tracking branch 'origin/main' into feat-mpshare-do
lawrencecchen Jul 28, 2026
d16d731
test: cover unused recent document controller
lawrencecchen Jul 28, 2026
af4eaa2
Fix accessibility stalls from unused recent items
lawrencecchen Jul 28, 2026
46144d6
test: cover headless shortcut window routing
lawrencecchen Jul 28, 2026
8df256b
Fix tagged shortcut window routing
lawrencecchen Jul 28, 2026
938f6aa
test: cover command palette debug activation
lawrencecchen Jul 28, 2026
0c694cb
Add deterministic command palette debug controls
lawrencecchen Jul 28, 2026
0a1142d
test: cover multiplayer live protocol races
lawrencecchen Jul 28, 2026
f8733ad
Fix multiplayer live protocol races
lawrencecchen Jul 28, 2026
b3b1de3
test: cover authoritative share approval state
lawrencecchen Jul 28, 2026
dfd6632
Make share approvals converge authoritatively
lawrencecchen Jul 28, 2026
d6a3bd5
Document relay-owned terminal authorization
lawrencecchen Jul 28, 2026
a23cce0
Fix authoritative approval reconciliation build
lawrencecchen Jul 28, 2026
4ca198e
test: cover hibernation wake and edge layouts
lawrencecchen Jul 28, 2026
f8e97a3
Preserve hibernation delivery ordering
lawrencecchen Jul 28, 2026
4193496
Update deployed hibernation proof ordering
lawrencecchen Jul 28, 2026
d203022
test: cover multiplayer lifecycle backpressure gaps
lawrencecchen Jul 28, 2026
39cd18d
Fix multiplayer restore and backpressure lifecycles
lawrencecchen Jul 28, 2026
73573cd
test: cover wake input and cumulative browser pacing
lawrencecchen Jul 28, 2026
0de73b3
Fix hibernation input and shared browser pacing
lawrencecchen Jul 28, 2026
f2c7418
test: cover multiplayer lifecycle gaps
lawrencecchen Jul 28, 2026
15d6707
Fix multiplayer session lifecycles
lawrencecchen Jul 28, 2026
cb8047b
test: prove share reconnect and revocation
lawrencecchen Jul 28, 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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ jobs:
CmuxTerminal
CmuxTerminalCore
CmuxUpdater
CmuxWorkspaceShare
CMUXAgentLaunch
)
# SwiftPM emits an error-severity diagnostic while planning the
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/share.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# CI/CD for the workspace sharing service (workers/share).
#
# Pull requests touching the service run its tests and dry-run both deploy
# configurations. Manual runs may deploy the selected ref to development;
# production remains restricted to main.
# `wrangler deploy` applies the Durable Object migrations declared in
# wrangler.toml atomically with the code upload.
#
# Required repository secrets (deploy job):
# CLOUDFLARE_API_TOKEN API token with Workers Scripts:Edit on the account
# CLOUDFLARE_ACCOUNT_ID the Cloudflare account id
#
# One-time Worker secret (set once via `wrangler secret put`, survives every
# deploy; see workers/share/README.md):
# SHARE_JWT_PUBLIC_KEY

name: share

on:
pull_request:
paths:
- ".github/workflows/share.yml"
- "workers/share/**"
workflow_dispatch:
inputs:
target:
description: Cloudflare Worker environment to deploy
required: true
type: choice
default: development
options:
- development
- production

permissions:
contents: read

jobs:
test:
runs-on: ${{ vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}
defaults:
run:
working-directory: workers/share
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2

# Wrangler requires Node >= 22; the Blacksmith ubuntu-2404 image ships
# Node 20, so pin it explicitly.
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Typecheck
run: bun run typecheck

- name: Unit tests
run: bun test

- name: Wrangler dry-run builds
run: |
bunx wrangler deploy --dry-run \
--outdir "$RUNNER_TEMP/cmux-share-wrangler-production"
bunx wrangler deploy --config wrangler.dev.toml --dry-run \
--outdir "$RUNNER_TEMP/cmux-share-wrangler-development"

deploy:
if: >-
github.event_name == 'workflow_dispatch' &&
(inputs.target == 'development' || github.ref == 'refs/heads/main')
needs: test
runs-on: ${{ vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}
concurrency:
group: share-deploy-${{ inputs.target }}
cancel-in-progress: false
defaults:
run:
working-directory: workers/share
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2

# Wrangler requires Node >= 22; Blacksmith ubuntu-2404 ships Node 20.
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Check Cloudflare secrets
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
missing=()
[ -n "$CLOUDFLARE_API_TOKEN" ] || missing+=(CLOUDFLARE_API_TOKEN)
[ -n "$CLOUDFLARE_ACCOUNT_ID" ] || missing+=(CLOUDFLARE_ACCOUNT_ID)
if [ "${#missing[@]}" -gt 0 ]; then
echo "::error::Share deploy needs repository secrets ${missing[*]}." \
"Create an API token with Workers Scripts:Edit on the Cloudflare" \
"account and add both secrets in repo Settings -> Secrets and" \
"variables -> Actions (see workers/share/README.md)."
exit 1
fi

- name: Deploy development (applies DO migrations atomically)
if: inputs.target == 'development'
run: bunx wrangler deploy --config wrangler.dev.toml
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Deploy production (applies DO migrations atomically)
if: inputs.target == 'production' && github.ref == 'refs/heads/main'
run: bunx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Foundation

/// Errors emitted while constructing xterm's private host-configuration
/// preamble. The preamble is parsed by cmux's pinned xterm integration before
/// the baseline's standard OSC reset sequences are applied.
public enum TerminalThemeXtermPreambleError: Error, Equatable, Sendable {
case invalidTheme
case payloadTooLarge
}

public extension TerminalTheme {
/// Private OSC identifier used only to install the host's configuration
/// theme as xterm's reset base before replaying a terminal baseline.
static let xtermConfigurationOSC = 777

/// Encodes this complete validated theme as bounded base64url JSON in an
/// OSC preamble. Keeping the metadata inside the VT payload preserves the
/// transport's directly-consumable xterm byte stream.
func xtermConfigurationPreambleBytes() throws -> Data {
guard isValid else {
throw TerminalThemeXtermPreambleError.invalidTheme
}
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
let json = try encoder.encode(self)
guard json.count < 12 * 1_024 else {
throw TerminalThemeXtermPreambleError.payloadTooLarge
}
let encoded = json.base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
let preamble =
"\u{1B}]\(Self.xtermConfigurationOSC);cmux-theme-v1;" +
encoded +
"\u{1B}\\"
let bytes = Data(preamble.utf8)
guard bytes.count < 16 * 1_024 else {
throw TerminalThemeXtermPreambleError.payloadTooLarge
}
return bytes
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Foundation
import Testing
@testable import CMUXMobileCore

@Suite("xterm configuration theme preamble")
struct TerminalThemeXtermPreambleTests {
@Test
func `Preamble carries the complete validated config theme as bounded base64url JSON`() throws {
var theme = TerminalTheme.monokai
theme.background = "#010203"
theme.foreground = "#a0b0c0"
theme.cursorText = "#112233"
theme.palette = (0..<TerminalTheme.extendedPaletteCount).map {
String(format: "#%06x", $0)
}

let bytes = try theme.xtermConfigurationPreambleBytes()
let text = try #require(String(data: bytes, encoding: .utf8))
let prefix = "\u{1B}]777;cmux-theme-v1;"
let suffix = "\u{1B}\\"
#expect(text.hasPrefix(prefix))
#expect(text.hasSuffix(suffix))
#expect(bytes.count < 16 * 1_024)

let encoded = String(text.dropFirst(prefix.count).dropLast(suffix.count))
#expect(!encoded.contains("+"))
#expect(!encoded.contains("/"))
#expect(!encoded.contains("="))
let padded = encoded
.replacingOccurrences(of: "-", with: "+")
.replacingOccurrences(of: "_", with: "/")
.padding(
toLength: encoded.count + (4 - encoded.count % 4) % 4,
withPad: "=",
startingAt: 0
)
let decodedData = try #require(Data(base64Encoded: padded))
let decoded = try JSONDecoder().decode(TerminalTheme.self, from: decodedData)
#expect(decoded == theme)
}

@Test
func `Invalid themes cannot enter a baseline preamble`() {
var theme = TerminalTheme.monokai
theme.palette = ["#000000"]

#expect(throws: (any Error).self) {
try theme.xtermConfigurationPreambleBytes()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,20 @@ extension ControlCommandCoordinator {
return debugWorkspaceTodoChecklistAddField()
case "debug.pro_welcome_checklist.show":
return debugShowProWelcomeChecklist()
case "debug.share.state":
return debugShareState()
case "debug.share.approve":
return debugShareApprove(request.params)
case "debug.share.set_role":
return debugShareSetRole(request.params)
case "debug.share.stop":
return debugShareStop()
case "debug.command_palette.toggle":
return debugCommandPaletteEvent(.toggle, request.params)
case "debug.command_palette.submit":
return debugCommandPaletteEvent(.submit, request.params)
case "debug.command_palette.move":
return debugCommandPaletteMove(request.params)
case "debug.command_palette.rename_tab.open":
return debugCommandPaletteEvent(.renameTabOpen, request.params)
case "debug.command_palette.visible":
Expand Down Expand Up @@ -224,6 +236,50 @@ extension ControlCommandCoordinator {
return .ok(.object(["shown": .bool(true)]))
}

// MARK: - debug.share.*

func debugShareState() -> ControlCallResult {
guard let debugContext else {
return .err(code: "unavailable", message: "Control context unavailable", data: nil)
}
return .ok(debugContext.controlDebugShareState())
}

func debugShareApprove(_ params: [String: JSONValue]) -> ControlCallResult {
guard let user = string(params, "user"),
let role = string(params, "role") else {
return .err(code: "invalid_params", message: "Missing user/role", data: nil)
}
guard role == "editor" || role == "viewer" else {
return .err(code: "invalid_params", message: "role must be editor or viewer", data: nil)
}
guard debugContext?.controlDebugShareApprove(user: user, role: role) == true else {
return .err(code: "not_found", message: "Pending access request not found", data: nil)
}
return .ok(.object(["approved": .bool(true)]))
}

func debugShareSetRole(_ params: [String: JSONValue]) -> ControlCallResult {
guard let user = string(params, "user"),
let role = string(params, "role") else {
return .err(code: "invalid_params", message: "Missing user/role", data: nil)
}
guard role == "editor" || role == "viewer" else {
return .err(code: "invalid_params", message: "role must be editor or viewer", data: nil)
}
guard debugContext?.controlDebugShareSetRole(user: user, role: role) == true else {
return .err(code: "not_found", message: "Participant not found", data: nil)
}
return .ok(.object(["updated": .bool(true)]))
}

func debugShareStop() -> ControlCallResult {
guard debugContext?.controlDebugShareStop() == true else {
return .err(code: "not_found", message: "No active share session", data: nil)
}
return .ok(.object(["stopped": .bool(true)]))
}

// MARK: - debug.textbox.*

/// `debug.textbox.inline_fixture` — install the inline text-box fixture.
Expand Down Expand Up @@ -335,6 +391,19 @@ extension ControlCommandCoordinator {
return .ok(.object([:]))
}

/// `debug.command_palette.move` posts the same selection notification as
/// an Up/Down key event, without depending on an AppKit field editor.
func debugCommandPaletteMove(_ params: [String: JSONValue]) -> ControlCallResult {
guard let delta = int(params, "delta"), delta != 0 else {
return .err(
code: "invalid_params",
message: "Missing or invalid non-zero delta",
data: nil
)
}
return debugCommandPaletteEvent(.moveSelection(delta: delta), params)
}

// MARK: - debug.command_palette.* (reads)

/// `debug.command_palette.visible` — palette visibility in a window.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ public enum ControlDebugCommandPaletteEvent: Sendable, Equatable {
/// `debug.command_palette.rename_input.delete_backward`
/// (`commandPaletteRenameInputDeleteBackwardRequested`).
case renameInputDeleteBackward
/// `debug.command_palette.submit` (`commandPaletteSubmitRequested`).
case submit
/// `debug.command_palette.move` (`commandPaletteMoveSelection`).
case moveSelection(delta: Int)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ public protocol ControlDebugContext: AnyObject {
/// `debug.pro_welcome_checklist.show`.
func controlDebugShowProWelcomeChecklist()

/// Returns the active multiplayer-share state for `debug.share.state`.
func controlDebugShareState() -> JSONValue

/// Approves one pending multiplayer access request for
/// `debug.share.approve`.
func controlDebugShareApprove(user: String, role: String) -> Bool

/// Changes one connected multiplayer participant's role for
/// `debug.share.set_role`.
func controlDebugShareSetRole(user: String, role: String) -> Bool

/// Stops the active multiplayer session for `debug.share.stop`.
func controlDebugShareStop() -> Bool

/// Runs the shared v1 `is_terminal_focused` body for
/// `debug.terminal.is_focused`.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ extension ControlDebugContext {
func controlDebugActivateApp() -> String { "ERROR: not implemented" }
func controlDebugRequestWorkspaceTodoChecklistAddField() -> UUID? { nil }
func controlDebugShowProWelcomeChecklist() {}
func controlDebugShareState() -> JSONValue { .object([:]) }
func controlDebugShareApprove(user: String, role: String) -> Bool { false }
func controlDebugShareSetRole(user: String, role: String) -> Bool { false }
func controlDebugShareStop() -> Bool { false }
func controlDebugIsTerminalFocused(surfaceArgument: String) -> String { "ERROR: not implemented" }
func controlDebugReadTerminalText(surfaceArgument: String) -> String { "ERROR: not implemented" }
func controlDebugRenderStats(surfaceArgument: String) -> String { "ERROR: not implemented" }
Expand Down
Loading