tmux-ide 2.9.2 → 2.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/cli.js +2071 -625
- package/package.json +14 -5
- package/packages/contracts/src/desktop-host.ts +3 -0
- package/packages/contracts/src/saved-machines.ts +19 -0
- package/packages/contracts/src/terminal-replica.ts +1 -1
- package/packages/core/package.json +3 -2
- package/packages/core/src/terminal-delivery.ts +51 -3
- package/packages/core/src/terminal-fnv64-wasm.ts +4 -3
- package/packages/core/src/terminal-replica-hash-cache.ts +129 -31
- package/packages/core/src/terminal-replica-owned-row.ts +27 -0
- package/packages/core/src/terminal-replica.ts +13 -28
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +96 -10
- package/packages/daemon/dist/command-center/resources/saved-machine-route.js +40 -1
- package/packages/daemon/dist/command-center/ws-events.js +5 -24
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +8 -0
- package/packages/daemon/dist/lib/canonical-daemon.js +28 -2
- package/packages/daemon/dist/lib/daemon-embed.js +1 -1
- package/packages/daemon/dist/lib/daemon-service-manager.js +122 -0
- package/packages/daemon/dist/lib/daemon-service-plan.js +127 -0
- package/packages/daemon/dist/lib/daemon-service.js +259 -0
- package/packages/daemon/dist/lib/install-origin.js +2 -0
- package/packages/daemon/dist/lib/local-fleet-request.js +9 -3
- package/packages/daemon/dist/lib/log.js +6 -10
- package/packages/daemon/dist/lib/managed-installer-update.js +67 -0
- package/packages/daemon/dist/lib/{tui-download-lock.js → private-operation-lock.js} +11 -11
- package/packages/daemon/dist/lib/remote-daemon-info.js +3 -2
- package/packages/daemon/dist/lib/remote-daemon-lifecycle.js +4 -4
- package/packages/daemon/dist/lib/remote-tmux-command.js +10 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +28 -16
- package/packages/daemon/dist/lib/saved-machines.js +40 -2
- package/packages/daemon/dist/lib/ssh-daemon-transport.js +24 -9
- package/packages/daemon/dist/lib/tmux-server-owner.js +1 -1
- package/packages/daemon/dist/lib/tmux-server-registration.js +21 -3
- package/packages/daemon/dist/lib/tui-binary.js +2 -2
- package/packages/daemon/dist/lib/update.js +18 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.js +24 -1
- package/packages/daemon/dist/machines.js +40 -4
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/terminal/attachments/direct-websocket.js +4 -1
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +22 -13
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +101 -3
- package/packages/daemon/dist/terminal/mirror/registered-window-guard.js +62 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +75 -4
- package/packages/daemon/dist/terminal/mirror/shared-window-index.js +45 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +11 -1
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.js +1 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.js +56 -7
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.js +3 -1
- package/packages/daemon/dist/tui/mirror/dialog-model.js +2 -35
- package/packages/daemon/dist/tui/mirror/runtime/application-daemon-authority-owner.js +8 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-fleet.js +20 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agents.js +7 -1
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-authority.js +59 -9
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +27 -19
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-sidebar.jsx +23 -18
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-startup.js +31 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-search-owner.js +7 -3
- package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.js +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.js +146 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +201 -50
- package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.js +50 -10
- package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.js +6 -5
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.js +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.js +8 -2
- package/packages/daemon/dist/tui/mirror/terminal-text.js +35 -0
- package/packages/daemon/dist/tui/mirror/workspace/connection-feedback.js +5 -3
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +100 -10
- package/packages/daemon/src/command-center/resources/saved-machine-route.ts +48 -1
- package/packages/daemon/src/command-center/ws-events.ts +5 -25
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +12 -0
- package/packages/daemon/src/lib/canonical-daemon.ts +44 -2
- package/packages/daemon/src/lib/daemon-embed.ts +1 -0
- package/packages/daemon/src/lib/daemon-service-manager.ts +152 -0
- package/packages/daemon/src/lib/daemon-service-plan.ts +153 -0
- package/packages/daemon/src/lib/daemon-service.ts +301 -0
- package/packages/daemon/src/lib/install-origin.ts +5 -0
- package/packages/daemon/src/lib/local-fleet-request.ts +19 -3
- package/packages/daemon/src/lib/log.ts +13 -9
- package/packages/daemon/src/lib/managed-installer-update.ts +79 -0
- package/packages/daemon/src/lib/{tui-download-lock.ts → private-operation-lock.ts} +15 -11
- package/packages/daemon/src/lib/remote-daemon-info.ts +3 -3
- package/packages/daemon/src/lib/remote-daemon-lifecycle.ts +4 -4
- package/packages/daemon/src/lib/remote-tmux-command.ts +12 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +27 -18
- package/packages/daemon/src/lib/saved-machines.ts +40 -1
- package/packages/daemon/src/lib/ssh-daemon-transport.ts +25 -7
- package/packages/daemon/src/lib/tmux-server-owner.ts +1 -0
- package/packages/daemon/src/lib/tmux-server-registration.ts +21 -3
- package/packages/daemon/src/lib/tui-binary.ts +2 -2
- package/packages/daemon/src/lib/update.ts +24 -0
- package/packages/daemon/src/lib/workspace-multiplexer-verbs.ts +22 -0
- package/packages/daemon/src/machines.ts +53 -5
- package/packages/daemon/src/terminal/attachments/direct-websocket.ts +8 -2
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +28 -13
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +105 -3
- package/packages/daemon/src/terminal/mirror/registered-window-guard.ts +66 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +92 -4
- package/packages/daemon/src/terminal/mirror/shared-window-index.ts +42 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +12 -1
- package/packages/daemon/src/terminal/session-runtime/multiplexer-backend.ts +2 -0
- package/packages/daemon/src/terminal/session-runtime/registry.ts +70 -8
- package/packages/daemon/src/terminal/session-runtime/semantic-mutation-executor.ts +3 -1
- package/packages/daemon/src/tui/mirror/dialog-model.ts +2 -32
- package/packages/daemon/src/tui/mirror/runtime/application-daemon-authority-owner.ts +8 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-fleet.ts +19 -2
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agents.ts +6 -1
- package/packages/daemon/src/tui/mirror/runtime/application-machine-authority.ts +60 -11
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +39 -33
- package/packages/daemon/src/tui/mirror/runtime/application-machine-sidebar.tsx +31 -23
- package/packages/daemon/src/tui/mirror/runtime/application-machine-startup.ts +38 -2
- package/packages/daemon/src/tui/mirror/runtime/application-palette-search-owner.ts +7 -4
- package/packages/daemon/src/tui/mirror/runtime/application-performance-log.ts +3 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +1 -1
- package/packages/daemon/src/tui/mirror/runtime/application-shell-view.tsx +47 -46
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-input-ingress.ts +165 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +207 -53
- package/packages/daemon/src/tui/mirror/runtime/bounded-performance-record-writer.ts +49 -9
- package/packages/daemon/src/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.ts +6 -5
- package/packages/daemon/src/tui/mirror/runtime/terminal-pane-input-router.ts +4 -0
- package/packages/daemon/src/tui/mirror/runtime/workspace-terminal-fast-lane.ts +8 -3
- package/packages/daemon/src/tui/mirror/terminal-text.ts +32 -0
- package/packages/daemon/src/tui/mirror/workspace/connection-feedback.ts +6 -3
- package/packages/daemon-client/src/fleet-connection-status.ts +10 -1
- package/packages/daemon-client/src/workspace-client.ts +4 -1
- package/packages/contracts/src/__tests__/actions-contract.test.ts +0 -119
- package/packages/contracts/src/__tests__/agent-graph-overlay.test.ts +0 -428
- package/packages/contracts/src/__tests__/app-window-mutation.test.ts +0 -51
- package/packages/contracts/src/__tests__/app-window-state.test.ts +0 -34
- package/packages/contracts/src/__tests__/application-shell.test.ts +0 -645
- package/packages/contracts/src/__tests__/automation-operations.test.ts +0 -78
- package/packages/contracts/src/__tests__/causal-cell.test.ts +0 -47
- package/packages/contracts/src/__tests__/client-view-state.test.ts +0 -115
- package/packages/contracts/src/__tests__/cohesion-fixture.test.ts +0 -106
- package/packages/contracts/src/__tests__/commands.test.ts +0 -86
- package/packages/contracts/src/__tests__/control.test.ts +0 -154
- package/packages/contracts/src/__tests__/daemon-events.test.ts +0 -405
- package/packages/contracts/src/__tests__/daemon-resources.test.ts +0 -143
- package/packages/contracts/src/__tests__/daemon-wire.test.ts +0 -149
- package/packages/contracts/src/__tests__/desktop-host.test.ts +0 -269
- package/packages/contracts/src/__tests__/desktop-missions.test.ts +0 -215
- package/packages/contracts/src/__tests__/experience-conformance.test.ts +0 -153
- package/packages/contracts/src/__tests__/experience-kernel-boundary.test.ts +0 -113
- package/packages/contracts/src/__tests__/experience-shell.test.ts +0 -65
- package/packages/contracts/src/__tests__/fixtures/daemon-wire-v2.json +0 -35
- package/packages/contracts/src/__tests__/fixtures/daemon-wire-v3.json +0 -35
- package/packages/contracts/src/__tests__/fixtures/daemon-wire-v4.json +0 -35
- package/packages/contracts/src/__tests__/fixtures/scoped-receipt.ts +0 -62
- package/packages/contracts/src/__tests__/fleet-agent-graph.test.ts +0 -231
- package/packages/contracts/src/__tests__/fleet-catalog.test.ts +0 -270
- package/packages/contracts/src/__tests__/fleet-lifecycle.test.ts +0 -62
- package/packages/contracts/src/__tests__/focus-overlay.test.ts +0 -110
- package/packages/contracts/src/__tests__/ide-config.test.ts +0 -64
- package/packages/contracts/src/__tests__/interaction-evidence.test.ts +0 -288
- package/packages/contracts/src/__tests__/interaction-receipt-v2.test.ts +0 -72
- package/packages/contracts/src/__tests__/issue-error.test.ts +0 -78
- package/packages/contracts/src/__tests__/mission-projections.test.ts +0 -186
- package/packages/contracts/src/__tests__/missions.test.ts +0 -272
- package/packages/contracts/src/__tests__/multiplexer-verbs.test.ts +0 -242
- package/packages/contracts/src/__tests__/pane-appearance.test.ts +0 -146
- package/packages/contracts/src/__tests__/pane-read-result.test.ts +0 -55
- package/packages/contracts/src/__tests__/pane-stream.test.ts +0 -536
- package/packages/contracts/src/__tests__/pane-widget-marker.test.ts +0 -327
- package/packages/contracts/src/__tests__/performance-metrics.test.ts +0 -73
- package/packages/contracts/src/__tests__/performance-qualification.test.ts +0 -137
- package/packages/contracts/src/__tests__/rich-card-widget.test.ts +0 -29
- package/packages/contracts/src/__tests__/session-runtime.test.ts +0 -512
- package/packages/contracts/src/__tests__/startup-readiness.test.ts +0 -409
- package/packages/contracts/src/__tests__/terminal-attachment-stream.test.ts +0 -72
- package/packages/contracts/src/__tests__/terminal-attachments.test.ts +0 -329
- package/packages/contracts/src/__tests__/terminal-delivery.test.ts +0 -88
- package/packages/contracts/src/__tests__/terminal-runtime-inventory.test.ts +0 -68
- package/packages/contracts/src/__tests__/terminals.test.ts +0 -87
- package/packages/contracts/src/__tests__/tmux-server-scope.test.ts +0 -166
- package/packages/contracts/src/__tests__/transport-contract-loading.test.ts +0 -91
- package/packages/contracts/src/__tests__/visual-tokens.test.ts +0 -224
- package/packages/contracts/src/__tests__/window-links.test.ts +0 -243
- package/packages/contracts/src/__tests__/workspace-changes-resource.test.ts +0 -317
- package/packages/contracts/src/__tests__/workspace-changes-view.test.ts +0 -122
- package/packages/contracts/src/__tests__/workspace-config.test.ts +0 -294
- package/packages/contracts/src/__tests__/workspace-files-resource.test.ts +0 -261
- package/packages/contracts/src/__tests__/workspace-files-tree.test.ts +0 -147
- package/packages/contracts/src/__tests__/workspace-pane-creation.test.ts +0 -249
- package/packages/contracts/src/__tests__/workspace-promotion.test.ts +0 -94
- package/packages/contracts/src/__tests__/workspace-resource-identity.test.ts +0 -90
- package/packages/contracts/src/daemon-resource-request.test.ts +0 -192
- package/packages/contracts/src/native-operation-identity.test.ts +0 -23
- package/packages/contracts/src/workspace-admission.test.ts +0 -21
- package/packages/contracts/src/workspace-catalog-resource.test.ts +0 -146
- package/packages/core/src/agent-provisioning.test.ts +0 -42
- package/packages/core/src/application-shell-session.test.ts +0 -105
- package/packages/core/src/interaction-evidence.test.ts +0 -134
- package/packages/core/src/interaction-flow.test.ts +0 -66
- package/packages/core/src/interaction-receipts.test.ts +0 -671
- package/packages/core/src/navigator.test.ts +0 -34
- package/packages/core/src/optimistic-projection-conformance.test.ts +0 -75
- package/packages/core/src/optimistic-projection.test.ts +0 -118
- package/packages/core/src/performance-metrics.test.ts +0 -121
- package/packages/core/src/performance-qualification.test.ts +0 -283
- package/packages/core/src/saved-machines.test.ts +0 -80
- package/packages/core/src/terminal-compact-cold.test.ts +0 -87
- package/packages/core/src/terminal-conformance.test.ts +0 -48
- package/packages/core/src/terminal-delivery-cache-lifetime.test.ts +0 -167
- package/packages/core/src/terminal-delivery-encode-cooperative.test.ts +0 -140
- package/packages/core/src/terminal-delivery-representation-hash.test.ts +0 -77
- package/packages/core/src/terminal-delivery.test.ts +0 -1471
- package/packages/core/src/terminal-fnv64-wasm.test.ts +0 -61
- package/packages/core/src/terminal-replica-cold.test.ts +0 -31
- package/packages/core/src/terminal-replica-cooperative.test.ts +0 -170
- package/packages/core/src/terminal-replica-hash-cache.test.ts +0 -283
- package/packages/core/src/terminal-replica.test.ts +0 -347
- package/packages/core/src/workspace-selection.test.ts +0 -63
- package/packages/daemon/dist/__tests__/support.js +0 -33
- package/packages/daemon/dist/lib/__tests__/fixtures/workspace-state-writer.js +0 -58
- package/packages/daemon/dist/lib/__tests__/installed-recovery-fixture.js +0 -400
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.js +0 -182
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.js +0 -98
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.js +0 -156
- package/packages/daemon/src/tui/mirror/__snapshots__/activity-surface-renderer.test.tsx.snap +0 -42
- package/packages/daemon/src/tui/mirror/__snapshots__/changes-terminal-surface-renderer.test.tsx.snap +0 -267
- package/packages/daemon/src/tui/mirror/__snapshots__/home-files-surface-renderer.test.tsx.snap +0 -267
- package/packages/daemon/src/tui/mirror/__snapshots__/missions-surface-renderer.test.tsx.snap +0 -134
- package/packages/daemon/src/tui/mirror/__snapshots__/recipes-gallery-renderer.test.tsx.snap +0 -141
- package/packages/daemon/src/tui/mirror/__snapshots__/shell-chrome-renderer.test.tsx.snap +0 -134
- package/packages/daemon/src/tui/mirror/runtime/__snapshots__/application-shell-view-renderer.test.tsx.snap +0 -87
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/agent-terminal-canvas-renderer.test.tsx.snap +0 -348
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/application-shell-renderer.test.tsx.snap +0 -134
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/command-palette-surface-renderer.test.tsx.snap +0 -255
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/pane-frame-renderer.test.tsx.snap +0 -525
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/terminal-pane-header-polish-renderer.test.tsx.snap +0 -31
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/workbench-shell-renderer.test.tsx.snap +0 -134
- package/packages/daemon-client/src/application-shell-session.test.ts +0 -196
- package/packages/daemon-client/src/automation-client.test.ts +0 -214
- package/packages/daemon-client/src/bootstrap-coordinator.test.ts +0 -145
- package/packages/daemon-client/src/connection-supervisor.test.ts +0 -109
- package/packages/daemon-client/src/direct-application-shell-transport.test.ts +0 -941
- package/packages/daemon-client/src/first-latest-coordinator.test.ts +0 -175
- package/packages/daemon-client/src/fleet-dial-scheduler.test.ts +0 -114
- package/packages/daemon-client/src/fleet-environments.test.ts +0 -40
- package/packages/daemon-client/src/generation-bound-store-timers.test.ts +0 -74
- package/packages/daemon-client/src/owner-action-client.test.ts +0 -245
- package/packages/daemon-client/src/pane-stream-client.test.ts +0 -2841
- package/packages/daemon-client/src/pane-stream-clock-calibration.test.ts +0 -207
- package/packages/daemon-client/src/pane-stream-loopback-benchmark.test.ts +0 -51
- package/packages/daemon-client/src/push-resource-session.test.ts +0 -509
- package/packages/daemon-client/src/resource-replica.test.ts +0 -186
- package/packages/daemon-client/src/runtime-resource-ledger.test.ts +0 -18
- package/packages/daemon-client/src/scoped-tmux-server-transport.test.ts +0 -114
- package/packages/daemon-client/src/terminal-fast-lane.test.ts +0 -835
- package/packages/daemon-client/src/tmux-server-client.test.ts +0 -279
- package/packages/daemon-client/src/tmux-server-interaction-events.test.ts +0 -230
- package/packages/daemon-client/src/workspace-catalog-v2.test.ts +0 -109
- package/packages/daemon-client/src/workspace-client-boundaries.test.ts +0 -59
- package/packages/daemon-client/src/workspace-client-operations.test.ts +0 -96
- package/packages/daemon-client/src/workspace-client.test.ts +0 -2912
- package/packages/daemon-client/src/workspace-event-supervisor.test.ts +0 -1086
- package/packages/daemon-client/src/workspace-pane-client.test.ts +0 -80
- package/packages/presentation/src/presentation-contract.test.ts +0 -63
- package/packages/tmux-bridge/src/runner.test.ts +0 -614
- package/packages/tmux-bridge/src/targeting.test.ts +0 -107
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WorkspaceWindowLinkSelectArgumentsSchemaZ,
|
|
3
|
-
WorkspaceWindowLinkUnlinkArgumentsSchemaZ,
|
|
4
|
-
WorkspacePaneSelectWithWindowLinkArgumentsSchemaZ,
|
|
5
|
-
WorkspacePaneSelectArgumentsSchemaZ,
|
|
6
|
-
WorkspaceMultiplexerIntentSchemaZ,
|
|
7
|
-
} from "../workspace-multiplexer.ts";
|
|
8
|
-
import { describe, expect, it } from "vitest";
|
|
9
|
-
import {
|
|
10
|
-
WINDOW_LINK_MAX_LINKS,
|
|
11
|
-
WindowLinkTargetSchemaZ,
|
|
12
|
-
WindowLinkTopologySchemaZ,
|
|
13
|
-
} from "../window-links.ts";
|
|
14
|
-
import {
|
|
15
|
-
PaneStreamLayoutSnapshotV2FrameSchemaZ,
|
|
16
|
-
PaneStreamLayoutSnapshotFrameSchemaZ,
|
|
17
|
-
PaneStreamLayoutSnapshotV1FrameSchemaZ,
|
|
18
|
-
PaneStreamServerFrameSchemaZ,
|
|
19
|
-
PANE_STREAM_PROTOCOL_VERSION,
|
|
20
|
-
} from "../pane-stream.ts";
|
|
21
|
-
|
|
22
|
-
const linkId = (index: number) => `window-link.${index.toString(16).padStart(32, "0")}`;
|
|
23
|
-
const topology = () => ({
|
|
24
|
-
liveSessionId: `live-session.${"a".repeat(20)}`,
|
|
25
|
-
linkRevision: 1,
|
|
26
|
-
activeLinkId: linkId(1),
|
|
27
|
-
links: [
|
|
28
|
-
{ linkId: linkId(1), semanticWindowId: "window.one", displayIndex: 0 },
|
|
29
|
-
{ linkId: linkId(2), semanticWindowId: "window.one", displayIndex: 1 },
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
const layout = (window = "window.one", pane: string | null = "pane.one", currentWindow = true) => ({
|
|
33
|
-
type: "layout" as const,
|
|
34
|
-
semanticWindowId: window,
|
|
35
|
-
windowName: "shell",
|
|
36
|
-
currentWindow,
|
|
37
|
-
cols: 80,
|
|
38
|
-
rows: 24,
|
|
39
|
-
zoomed: false,
|
|
40
|
-
panes: [{ pane, left: 0, top: 0, width: 80, height: 24, active: true }],
|
|
41
|
-
});
|
|
42
|
-
const snapshot = () => ({
|
|
43
|
-
type: "layout-snapshot" as const,
|
|
44
|
-
topologyEpoch: 1,
|
|
45
|
-
layouts: [layout()],
|
|
46
|
-
windowLinks: topology(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe("window link contracts", () => {
|
|
50
|
-
it("allows multiple links sharing one unique backing and pane", () => {
|
|
51
|
-
expect(WindowLinkTopologySchemaZ.safeParse(topology()).success).toBe(true);
|
|
52
|
-
expect(PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse(snapshot()).success).toBe(true);
|
|
53
|
-
expect(
|
|
54
|
-
PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse({
|
|
55
|
-
...snapshot(),
|
|
56
|
-
windowLinks: { ...topology(), activeLinkId: linkId(2) },
|
|
57
|
-
}).success,
|
|
58
|
-
).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("rejects duplicate handles/indexes and missing active links", () => {
|
|
62
|
-
const original = topology();
|
|
63
|
-
for (const invalid of [
|
|
64
|
-
{ ...original, links: [original.links[0], { ...original.links[1], linkId: linkId(1) }] },
|
|
65
|
-
{ ...original, links: [original.links[0], { ...original.links[1], displayIndex: 0 }] },
|
|
66
|
-
{ ...original, activeLinkId: linkId(3) },
|
|
67
|
-
{ ...original, links: [] },
|
|
68
|
-
])
|
|
69
|
-
expect(WindowLinkTopologySchemaZ.safeParse(invalid).success).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("bounds topology size and integer revisions/indexes", () => {
|
|
73
|
-
const links = Array.from({ length: WINDOW_LINK_MAX_LINKS }, (_, index) => ({
|
|
74
|
-
linkId: linkId(index + 1),
|
|
75
|
-
semanticWindowId: "window.one",
|
|
76
|
-
displayIndex: index,
|
|
77
|
-
}));
|
|
78
|
-
expect(WindowLinkTopologySchemaZ.safeParse({ ...topology(), links }).success).toBe(true);
|
|
79
|
-
expect(
|
|
80
|
-
WindowLinkTopologySchemaZ.safeParse({
|
|
81
|
-
...topology(),
|
|
82
|
-
links: [
|
|
83
|
-
...links,
|
|
84
|
-
{
|
|
85
|
-
linkId: linkId(WINDOW_LINK_MAX_LINKS + 1),
|
|
86
|
-
semanticWindowId: "window.one",
|
|
87
|
-
displayIndex: WINDOW_LINK_MAX_LINKS,
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
}).success,
|
|
91
|
-
).toBe(false);
|
|
92
|
-
for (const value of [-1, 0.5, Number.MAX_SAFE_INTEGER + 1, Infinity]) {
|
|
93
|
-
expect(
|
|
94
|
-
WindowLinkTopologySchemaZ.safeParse({ ...topology(), linkRevision: value }).success,
|
|
95
|
-
).toBe(false);
|
|
96
|
-
expect(
|
|
97
|
-
WindowLinkTopologySchemaZ.safeParse({
|
|
98
|
-
...topology(),
|
|
99
|
-
links: [{ ...links[0], displayIndex: value }],
|
|
100
|
-
}).success,
|
|
101
|
-
).toBe(false);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("accepts only opaque targets and rejects native or display action addresses", () => {
|
|
106
|
-
const target = {
|
|
107
|
-
liveSessionId: topology().liveSessionId,
|
|
108
|
-
linkId: linkId(1),
|
|
109
|
-
expectedSemanticWindowId: "window.one",
|
|
110
|
-
linkRevision: 0,
|
|
111
|
-
};
|
|
112
|
-
expect(WindowLinkTargetSchemaZ.safeParse(target).success).toBe(true);
|
|
113
|
-
for (const invalid of [
|
|
114
|
-
{ ...target, linkId: "@0" },
|
|
115
|
-
{ ...target, linkId: "/tmp/tmux/socket" },
|
|
116
|
-
{ ...target, linkId: "window-link.abc" },
|
|
117
|
-
{ ...target, liveSessionId: "$0" },
|
|
118
|
-
{ ...target, expectedSemanticWindowId: "@0" },
|
|
119
|
-
{ ...target, displayIndex: 0 },
|
|
120
|
-
{ ...target, linkRevision: -1 },
|
|
121
|
-
{ ...target, linkRevision: Number.MAX_SAFE_INTEGER + 1 },
|
|
122
|
-
])
|
|
123
|
-
expect(WindowLinkTargetSchemaZ.safeParse(invalid).success).toBe(false);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("requires a complete join and a matching active backing", () => {
|
|
127
|
-
const second = layout("window.two", "pane.two", false);
|
|
128
|
-
for (const invalid of [
|
|
129
|
-
{ ...snapshot(), layouts: [layout("window.two")] },
|
|
130
|
-
{ ...snapshot(), layouts: [layout(), second] },
|
|
131
|
-
{
|
|
132
|
-
...snapshot(),
|
|
133
|
-
layouts: [layout("window.one", "pane.one", false), { ...second, currentWindow: true }],
|
|
134
|
-
windowLinks: {
|
|
135
|
-
...topology(),
|
|
136
|
-
links: [
|
|
137
|
-
...topology().links,
|
|
138
|
-
{ linkId: linkId(3), semanticWindowId: "window.two", displayIndex: 2 },
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
])
|
|
143
|
-
expect(PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse(invalid).success).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("preserves unique backing/pane and exactly-one-current invariants", () => {
|
|
147
|
-
for (const layouts of [
|
|
148
|
-
[layout(), layout()],
|
|
149
|
-
[layout(), layout("window.two", "pane.one", false)],
|
|
150
|
-
[layout("window.one", null)],
|
|
151
|
-
[{ ...layout(), semanticWindowId: null }],
|
|
152
|
-
[layout("window.one", "pane.one", false)],
|
|
153
|
-
[layout(), layout("window.two", "pane.two", true)],
|
|
154
|
-
])
|
|
155
|
-
expect(
|
|
156
|
-
PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse({ ...snapshot(), layouts }).success,
|
|
157
|
-
).toBe(false);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("requires v2 topology and refuses the old v1 shape", () => {
|
|
161
|
-
const v1 = { type: "layout-snapshot", topologyEpoch: 1, layouts: [layout()] };
|
|
162
|
-
expect(PANE_STREAM_PROTOCOL_VERSION).toBe(2);
|
|
163
|
-
expect(PaneStreamLayoutSnapshotV1FrameSchemaZ.safeParse(v1).success).toBe(true);
|
|
164
|
-
expect(PaneStreamLayoutSnapshotFrameSchemaZ.safeParse(v1).success).toBe(false);
|
|
165
|
-
expect(PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse(v1).success).toBe(false);
|
|
166
|
-
expect(PaneStreamLayoutSnapshotFrameSchemaZ.safeParse(snapshot()).success).toBe(true);
|
|
167
|
-
expect(PaneStreamServerFrameSchemaZ.safeParse(snapshot()).success).toBe(true);
|
|
168
|
-
expect(
|
|
169
|
-
PaneStreamLayoutSnapshotV2FrameSchemaZ.safeParse({ ...snapshot(), unexpected: true }).success,
|
|
170
|
-
).toBe(false);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe("window link action arguments", () => {
|
|
175
|
-
const target = () => ({
|
|
176
|
-
liveSessionId: topology().liveSessionId,
|
|
177
|
-
linkId: linkId(1),
|
|
178
|
-
expectedSemanticWindowId: "window.one",
|
|
179
|
-
linkRevision: 1,
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("accepts opaque select/unlink targets and explicit-link pane selection", () => {
|
|
183
|
-
for (const schema of [
|
|
184
|
-
WorkspaceWindowLinkSelectArgumentsSchemaZ,
|
|
185
|
-
WorkspaceWindowLinkUnlinkArgumentsSchemaZ,
|
|
186
|
-
]) {
|
|
187
|
-
expect(schema.safeParse({ workspaceName: "project", target: target() }).success).toBe(true);
|
|
188
|
-
}
|
|
189
|
-
expect(
|
|
190
|
-
WorkspacePaneSelectWithWindowLinkArgumentsSchemaZ.safeParse({
|
|
191
|
-
workspaceName: "project",
|
|
192
|
-
semanticPaneId: "pane.one",
|
|
193
|
-
windowLink: target(),
|
|
194
|
-
}).success,
|
|
195
|
-
).toBe(true);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("rejects native addresses, display indexes, command/force flags and unknown fields", () => {
|
|
199
|
-
for (const schema of [
|
|
200
|
-
WorkspaceWindowLinkSelectArgumentsSchemaZ,
|
|
201
|
-
WorkspaceWindowLinkUnlinkArgumentsSchemaZ,
|
|
202
|
-
]) {
|
|
203
|
-
const args = { workspaceName: "project", target: target() };
|
|
204
|
-
for (const invalid of [
|
|
205
|
-
{ ...args, target: "@0" },
|
|
206
|
-
{ ...args, target: { ...target(), linkId: "@0" } },
|
|
207
|
-
{ ...args, target: { ...target(), expectedSemanticWindowId: "@0" } },
|
|
208
|
-
{ ...args, target: { ...target(), displayIndex: 0 } },
|
|
209
|
-
{ ...args, target: { ...target(), runtimeSessionId: "$0" } },
|
|
210
|
-
{ ...args, displayIndex: 0 },
|
|
211
|
-
{ ...args, command: "kill-server" },
|
|
212
|
-
{ ...args, force: true },
|
|
213
|
-
{ ...args, socketPath: "/tmp/tmux/socket" },
|
|
214
|
-
{ ...args, workspaceName: "" },
|
|
215
|
-
])
|
|
216
|
-
expect(schema.safeParse(invalid).success).toBe(false);
|
|
217
|
-
}
|
|
218
|
-
const args = { workspaceName: "project", semanticPaneId: "pane.one", windowLink: target() };
|
|
219
|
-
for (const invalid of [
|
|
220
|
-
{ ...args, semanticPaneId: "%0" },
|
|
221
|
-
{ ...args, command: "select-pane -t %0" },
|
|
222
|
-
{ ...args, windowLink: { ...target(), linkId: "project:0" } },
|
|
223
|
-
{ workspaceName: "project", semanticPaneId: "pane.one" },
|
|
224
|
-
])
|
|
225
|
-
expect(WorkspacePaneSelectWithWindowLinkArgumentsSchemaZ.safeParse(invalid).success).toBe(
|
|
226
|
-
false,
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("accepts registered link verbs and explicit-link pane selection", () => {
|
|
231
|
-
const args = { workspaceName: "project", target: target() };
|
|
232
|
-
for (const verb of ["workspace.window.link.select", "workspace.window.link.unlink"]) {
|
|
233
|
-
expect(WorkspaceMultiplexerIntentSchemaZ.safeParse({ verb, ...args }).success).toBe(true);
|
|
234
|
-
}
|
|
235
|
-
expect(
|
|
236
|
-
WorkspacePaneSelectArgumentsSchemaZ.safeParse({
|
|
237
|
-
workspaceName: "project",
|
|
238
|
-
semanticPaneId: "pane.one",
|
|
239
|
-
windowLink: target(),
|
|
240
|
-
}).success,
|
|
241
|
-
).toBe(true);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
WORKSPACE_CHANGE_DIFF_RESOURCE_VERSION,
|
|
4
|
-
WORKSPACE_CHANGES_CATALOG_RESOURCE_VERSION,
|
|
5
|
-
WorkspaceChangeDiffEnvelopeV1SchemaZ,
|
|
6
|
-
WorkspaceChangeDiffResourceV1SchemaZ,
|
|
7
|
-
WorkspaceChangeEntrySchemaZ,
|
|
8
|
-
WorkspaceChangesCatalogEnvelopeV1SchemaZ,
|
|
9
|
-
WorkspaceChangesCatalogResourceV1SchemaZ,
|
|
10
|
-
WorkspaceDiffHunkSchemaZ,
|
|
11
|
-
} from "../workspace-changes-resource.ts";
|
|
12
|
-
|
|
13
|
-
const daemon = {
|
|
14
|
-
protocolVersion: 1,
|
|
15
|
-
productVersion: "2.8.0",
|
|
16
|
-
instanceId: "9bcf33b0-c837-4a94-b5e8-c0977f54464f",
|
|
17
|
-
startedAt: "2026-07-21T12:00:00.000Z",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const changeId = (token: string) => `change.${token.padEnd(16, "0")}`;
|
|
21
|
-
const changesRev = (token: string) => `changes-rev.${token.padEnd(16, "0")}`;
|
|
22
|
-
|
|
23
|
-
const modifiedUnstaged = {
|
|
24
|
-
id: changeId("mod"),
|
|
25
|
-
group: "unstaged" as const,
|
|
26
|
-
status: "modified" as const,
|
|
27
|
-
name: "app.tsx",
|
|
28
|
-
relativePath: "apps/desktop-renderer/app.tsx",
|
|
29
|
-
originPath: null,
|
|
30
|
-
binary: false,
|
|
31
|
-
additions: 12,
|
|
32
|
-
deletions: 3,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
describe("workspace change entry", () => {
|
|
36
|
-
it("accepts modified, untracked, renamed, and binary entries", () => {
|
|
37
|
-
expect(WorkspaceChangeEntrySchemaZ.safeParse(modifiedUnstaged).success).toBe(true);
|
|
38
|
-
expect(
|
|
39
|
-
WorkspaceChangeEntrySchemaZ.safeParse({
|
|
40
|
-
id: changeId("unt"),
|
|
41
|
-
group: "untracked",
|
|
42
|
-
status: "untracked",
|
|
43
|
-
name: "scratch.md",
|
|
44
|
-
relativePath: "scratch.md",
|
|
45
|
-
originPath: null,
|
|
46
|
-
binary: false,
|
|
47
|
-
additions: 5,
|
|
48
|
-
deletions: 0,
|
|
49
|
-
}).success,
|
|
50
|
-
).toBe(true);
|
|
51
|
-
expect(
|
|
52
|
-
WorkspaceChangeEntrySchemaZ.safeParse({
|
|
53
|
-
id: changeId("ren"),
|
|
54
|
-
group: "staged",
|
|
55
|
-
status: "renamed",
|
|
56
|
-
name: "renamed.ts",
|
|
57
|
-
relativePath: "src/renamed.ts",
|
|
58
|
-
originPath: "src/original.ts",
|
|
59
|
-
binary: false,
|
|
60
|
-
additions: 0,
|
|
61
|
-
deletions: 0,
|
|
62
|
-
}).success,
|
|
63
|
-
).toBe(true);
|
|
64
|
-
expect(
|
|
65
|
-
WorkspaceChangeEntrySchemaZ.safeParse({
|
|
66
|
-
id: changeId("bin"),
|
|
67
|
-
group: "staged",
|
|
68
|
-
status: "modified",
|
|
69
|
-
name: "logo.png",
|
|
70
|
-
relativePath: "assets/logo.png",
|
|
71
|
-
originPath: null,
|
|
72
|
-
binary: true,
|
|
73
|
-
additions: null,
|
|
74
|
-
deletions: null,
|
|
75
|
-
}).success,
|
|
76
|
-
).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("rejects inconsistent group, status, origin, and count combinations", () => {
|
|
80
|
-
// untracked status must ride in the untracked group.
|
|
81
|
-
expect(
|
|
82
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, status: "untracked" }).success,
|
|
83
|
-
).toBe(false);
|
|
84
|
-
// renames must carry an origin path.
|
|
85
|
-
expect(
|
|
86
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, status: "renamed" }).success,
|
|
87
|
-
).toBe(false);
|
|
88
|
-
// a non-rename must not carry one.
|
|
89
|
-
expect(
|
|
90
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, originPath: "src/other.ts" })
|
|
91
|
-
.success,
|
|
92
|
-
).toBe(false);
|
|
93
|
-
// origin path cannot equal the current path.
|
|
94
|
-
expect(
|
|
95
|
-
WorkspaceChangeEntrySchemaZ.safeParse({
|
|
96
|
-
...modifiedUnstaged,
|
|
97
|
-
status: "renamed",
|
|
98
|
-
group: "staged",
|
|
99
|
-
originPath: modifiedUnstaged.relativePath,
|
|
100
|
-
}).success,
|
|
101
|
-
).toBe(false);
|
|
102
|
-
// binary entries cannot report line counts.
|
|
103
|
-
expect(
|
|
104
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, binary: true }).success,
|
|
105
|
-
).toBe(false);
|
|
106
|
-
// text entries must report line counts.
|
|
107
|
-
expect(
|
|
108
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, additions: null }).success,
|
|
109
|
-
).toBe(false);
|
|
110
|
-
// the name must be the basename of the display path.
|
|
111
|
-
expect(
|
|
112
|
-
WorkspaceChangeEntrySchemaZ.safeParse({ ...modifiedUnstaged, name: "wrong.tsx" }).success,
|
|
113
|
-
).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("workspace changes catalog resource", () => {
|
|
118
|
-
const stagedTwin = {
|
|
119
|
-
...modifiedUnstaged,
|
|
120
|
-
id: changeId("staged"),
|
|
121
|
-
group: "staged" as const,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const catalog = {
|
|
125
|
-
status: "ready" as const,
|
|
126
|
-
workspaceName: "tmux-ide",
|
|
127
|
-
revision: changesRev("gen1"),
|
|
128
|
-
branch: "main",
|
|
129
|
-
detached: false,
|
|
130
|
-
entries: [modifiedUnstaged, stagedTwin],
|
|
131
|
-
totalEntries: 2,
|
|
132
|
-
truncated: false,
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
it("accepts a catalog where one path appears in two different groups", () => {
|
|
136
|
-
expect(WorkspaceChangesCatalogResourceV1SchemaZ.safeParse(catalog).success).toBe(true);
|
|
137
|
-
expect(
|
|
138
|
-
WorkspaceChangesCatalogEnvelopeV1SchemaZ.safeParse({
|
|
139
|
-
version: WORKSPACE_CHANGES_CATALOG_RESOURCE_VERSION,
|
|
140
|
-
daemon,
|
|
141
|
-
resource: catalog,
|
|
142
|
-
}).success,
|
|
143
|
-
).toBe(true);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("rejects duplicate ids and duplicate paths within one group", () => {
|
|
147
|
-
expect(
|
|
148
|
-
WorkspaceChangesCatalogResourceV1SchemaZ.safeParse({
|
|
149
|
-
...catalog,
|
|
150
|
-
entries: [modifiedUnstaged, { ...stagedTwin, id: modifiedUnstaged.id }],
|
|
151
|
-
}).success,
|
|
152
|
-
).toBe(false);
|
|
153
|
-
expect(
|
|
154
|
-
WorkspaceChangesCatalogResourceV1SchemaZ.safeParse({
|
|
155
|
-
...catalog,
|
|
156
|
-
entries: [modifiedUnstaged, { ...modifiedUnstaged, id: changeId("dup") }],
|
|
157
|
-
}).success,
|
|
158
|
-
).toBe(false);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("rejects a detached workspace that also names a branch", () => {
|
|
162
|
-
expect(
|
|
163
|
-
WorkspaceChangesCatalogResourceV1SchemaZ.safeParse({ ...catalog, detached: true }).success,
|
|
164
|
-
).toBe(false);
|
|
165
|
-
expect(
|
|
166
|
-
WorkspaceChangesCatalogResourceV1SchemaZ.safeParse({
|
|
167
|
-
...catalog,
|
|
168
|
-
branch: null,
|
|
169
|
-
detached: true,
|
|
170
|
-
}).success,
|
|
171
|
-
).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("rejects a truncation flag inconsistent with totalEntries", () => {
|
|
175
|
-
expect(
|
|
176
|
-
WorkspaceChangesCatalogResourceV1SchemaZ.safeParse({
|
|
177
|
-
...catalog,
|
|
178
|
-
totalEntries: 40,
|
|
179
|
-
truncated: false,
|
|
180
|
-
}).success,
|
|
181
|
-
).toBe(false);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe("workspace change diff resource", () => {
|
|
186
|
-
const editHunk = {
|
|
187
|
-
header: "@@ -1,3 +1,4 @@",
|
|
188
|
-
oldStart: 1,
|
|
189
|
-
oldLines: 3,
|
|
190
|
-
newStart: 1,
|
|
191
|
-
newLines: 4,
|
|
192
|
-
lines: [
|
|
193
|
-
{ kind: "context" as const, content: "unchanged", oldLine: 1, newLine: 1 },
|
|
194
|
-
{ kind: "delete" as const, content: "removed", oldLine: 2, newLine: null },
|
|
195
|
-
{ kind: "insert" as const, content: "added one", oldLine: null, newLine: 2 },
|
|
196
|
-
{ kind: "insert" as const, content: "added two", oldLine: null, newLine: 3 },
|
|
197
|
-
{ kind: "context" as const, content: "tail", oldLine: 3, newLine: 4 },
|
|
198
|
-
],
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const additionHunk = {
|
|
202
|
-
header: "@@ -0,0 +1,2 @@",
|
|
203
|
-
oldStart: 0,
|
|
204
|
-
oldLines: 0,
|
|
205
|
-
newStart: 1,
|
|
206
|
-
newLines: 2,
|
|
207
|
-
lines: [
|
|
208
|
-
{ kind: "insert" as const, content: "first", oldLine: null, newLine: 1 },
|
|
209
|
-
{ kind: "insert" as const, content: "second", oldLine: null, newLine: 2 },
|
|
210
|
-
],
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
it("accepts hunks with consistent line numbering", () => {
|
|
214
|
-
expect(WorkspaceDiffHunkSchemaZ.safeParse(editHunk).success).toBe(true);
|
|
215
|
-
expect(WorkspaceDiffHunkSchemaZ.safeParse(additionHunk).success).toBe(true);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("rejects hunks whose line numbers or counts do not line up", () => {
|
|
219
|
-
expect(
|
|
220
|
-
WorkspaceDiffHunkSchemaZ.safeParse({
|
|
221
|
-
...editHunk,
|
|
222
|
-
lines: [{ ...editHunk.lines[0], oldLine: 5 }, ...editHunk.lines.slice(1)],
|
|
223
|
-
}).success,
|
|
224
|
-
).toBe(false);
|
|
225
|
-
// oldLines claims one more old-side line than the hunk actually carries.
|
|
226
|
-
expect(WorkspaceDiffHunkSchemaZ.safeParse({ ...editHunk, oldLines: 4 }).success).toBe(false);
|
|
227
|
-
// an insert line cannot carry an old line number.
|
|
228
|
-
expect(
|
|
229
|
-
WorkspaceDiffHunkSchemaZ.safeParse({
|
|
230
|
-
...additionHunk,
|
|
231
|
-
lines: [{ kind: "insert", content: "x", oldLine: 1, newLine: 1 }],
|
|
232
|
-
newLines: 1,
|
|
233
|
-
}).success,
|
|
234
|
-
).toBe(false);
|
|
235
|
-
// content is a single line without control breaks.
|
|
236
|
-
expect(
|
|
237
|
-
WorkspaceDiffHunkSchemaZ.safeParse({
|
|
238
|
-
...additionHunk,
|
|
239
|
-
lines: [{ kind: "insert", content: "a\nb", oldLine: null, newLine: 1 }],
|
|
240
|
-
newLines: 1,
|
|
241
|
-
}).success,
|
|
242
|
-
).toBe(false);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("accepts a ready diff envelope and enforces truncation accounting", () => {
|
|
246
|
-
const ready = {
|
|
247
|
-
status: "ready" as const,
|
|
248
|
-
workspaceName: "tmux-ide",
|
|
249
|
-
changesRevision: changesRev("gen1"),
|
|
250
|
-
changeId: changeId("mod"),
|
|
251
|
-
group: "unstaged" as const,
|
|
252
|
-
relativePath: "apps/desktop-renderer/app.tsx",
|
|
253
|
-
originPath: null,
|
|
254
|
-
hunks: [editHunk],
|
|
255
|
-
totalHunks: 1,
|
|
256
|
-
totalLines: 5,
|
|
257
|
-
truncated: false,
|
|
258
|
-
};
|
|
259
|
-
expect(
|
|
260
|
-
WorkspaceChangeDiffEnvelopeV1SchemaZ.safeParse({
|
|
261
|
-
version: WORKSPACE_CHANGE_DIFF_RESOURCE_VERSION,
|
|
262
|
-
daemon,
|
|
263
|
-
resource: ready,
|
|
264
|
-
}).success,
|
|
265
|
-
).toBe(true);
|
|
266
|
-
// More hunks omitted than reported, yet truncated stays false.
|
|
267
|
-
expect(
|
|
268
|
-
WorkspaceChangeDiffResourceV1SchemaZ.safeParse({ ...ready, totalHunks: 6 }).success,
|
|
269
|
-
).toBe(false);
|
|
270
|
-
// truncated true is required when lines are omitted.
|
|
271
|
-
expect(
|
|
272
|
-
WorkspaceChangeDiffResourceV1SchemaZ.safeParse({
|
|
273
|
-
...ready,
|
|
274
|
-
totalLines: 40,
|
|
275
|
-
truncated: true,
|
|
276
|
-
}).success,
|
|
277
|
-
).toBe(true);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it("accepts binary, too-large, and unavailable diff variants", () => {
|
|
281
|
-
const base = {
|
|
282
|
-
workspaceName: "tmux-ide",
|
|
283
|
-
changesRevision: changesRev("gen1"),
|
|
284
|
-
changeId: changeId("bin"),
|
|
285
|
-
group: "staged" as const,
|
|
286
|
-
relativePath: "assets/logo.png",
|
|
287
|
-
originPath: null,
|
|
288
|
-
};
|
|
289
|
-
expect(
|
|
290
|
-
WorkspaceChangeDiffResourceV1SchemaZ.safeParse({
|
|
291
|
-
status: "binary",
|
|
292
|
-
...base,
|
|
293
|
-
oldBytes: 100,
|
|
294
|
-
newBytes: 220,
|
|
295
|
-
}).success,
|
|
296
|
-
).toBe(true);
|
|
297
|
-
expect(
|
|
298
|
-
WorkspaceChangeDiffResourceV1SchemaZ.safeParse({
|
|
299
|
-
status: "too-large",
|
|
300
|
-
...base,
|
|
301
|
-
totalBytes: 9_000_000,
|
|
302
|
-
limitBytes: 1_048_576,
|
|
303
|
-
}).success,
|
|
304
|
-
).toBe(true);
|
|
305
|
-
expect(
|
|
306
|
-
WorkspaceChangeDiffResourceV1SchemaZ.safeParse({
|
|
307
|
-
status: "unavailable",
|
|
308
|
-
workspaceName: "tmux-ide",
|
|
309
|
-
changesRevision: changesRev("gen1"),
|
|
310
|
-
changeId: changeId("bin"),
|
|
311
|
-
reason: "change-not-found",
|
|
312
|
-
message: "stale",
|
|
313
|
-
retryable: false,
|
|
314
|
-
}).success,
|
|
315
|
-
).toBe(true);
|
|
316
|
-
});
|
|
317
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { WorkspaceChangeEntry } from "../workspace-changes-resource.ts";
|
|
3
|
-
import {
|
|
4
|
-
filterWorkspaceChanges,
|
|
5
|
-
flattenWorkspaceChangesView,
|
|
6
|
-
groupWorkspaceChanges,
|
|
7
|
-
moveWorkspaceChangeSelection,
|
|
8
|
-
summarizeWorkspaceChanges,
|
|
9
|
-
} from "../workspace-changes-view.ts";
|
|
10
|
-
|
|
11
|
-
const changeId = (token: string) => `change.${token.padEnd(16, "0")}`;
|
|
12
|
-
|
|
13
|
-
const entries: WorkspaceChangeEntry[] = [
|
|
14
|
-
{
|
|
15
|
-
id: changeId("b-unstaged"),
|
|
16
|
-
group: "unstaged",
|
|
17
|
-
status: "modified",
|
|
18
|
-
name: "b.ts",
|
|
19
|
-
relativePath: "src/b.ts",
|
|
20
|
-
originPath: null,
|
|
21
|
-
binary: false,
|
|
22
|
-
additions: 4,
|
|
23
|
-
deletions: 1,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: changeId("a-unstaged"),
|
|
27
|
-
group: "unstaged",
|
|
28
|
-
status: "modified",
|
|
29
|
-
name: "a.ts",
|
|
30
|
-
relativePath: "src/a.ts",
|
|
31
|
-
originPath: null,
|
|
32
|
-
binary: false,
|
|
33
|
-
additions: 2,
|
|
34
|
-
deletions: 2,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: changeId("staged"),
|
|
38
|
-
group: "staged",
|
|
39
|
-
status: "added",
|
|
40
|
-
name: "new.ts",
|
|
41
|
-
relativePath: "src/new.ts",
|
|
42
|
-
originPath: null,
|
|
43
|
-
binary: false,
|
|
44
|
-
additions: 10,
|
|
45
|
-
deletions: 0,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: changeId("binary"),
|
|
49
|
-
group: "untracked",
|
|
50
|
-
status: "untracked",
|
|
51
|
-
name: "logo.png",
|
|
52
|
-
relativePath: "assets/logo.png",
|
|
53
|
-
originPath: null,
|
|
54
|
-
binary: true,
|
|
55
|
-
additions: null,
|
|
56
|
-
deletions: null,
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
describe("workspace changes view projection", () => {
|
|
61
|
-
it("groups entries and sorts each group by path", () => {
|
|
62
|
-
const grouped = groupWorkspaceChanges(entries);
|
|
63
|
-
expect(grouped.staged.map((e) => e.name)).toEqual(["new.ts"]);
|
|
64
|
-
expect(grouped.unstaged.map((e) => e.name)).toEqual(["a.ts", "b.ts"]);
|
|
65
|
-
expect(grouped.untracked.map((e) => e.name)).toEqual(["logo.png"]);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("summarizes counts and line totals, ignoring binary counts", () => {
|
|
69
|
-
expect(summarizeWorkspaceChanges(entries)).toEqual({
|
|
70
|
-
staged: 1,
|
|
71
|
-
unstaged: 2,
|
|
72
|
-
untracked: 1,
|
|
73
|
-
total: 4,
|
|
74
|
-
additions: 16,
|
|
75
|
-
deletions: 3,
|
|
76
|
-
binary: 1,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("filters by group and by case-insensitive path query", () => {
|
|
81
|
-
expect(filterWorkspaceChanges(entries, { group: "unstaged" }).length).toBe(2);
|
|
82
|
-
expect(filterWorkspaceChanges(entries, { query: "LOGO" }).map((e) => e.name)).toEqual([
|
|
83
|
-
"logo.png",
|
|
84
|
-
]);
|
|
85
|
-
expect(filterWorkspaceChanges(entries, { group: "staged", query: "b.ts" }).length).toBe(0);
|
|
86
|
-
expect(filterWorkspaceChanges(entries, {}).length).toBe(entries.length);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("flattens to group headers followed by their changes", () => {
|
|
90
|
-
const view = flattenWorkspaceChangesView({ entries });
|
|
91
|
-
expect(view.rows.map((r) => (r.kind === "group" ? `#${r.group}` : r.entry!.name))).toEqual([
|
|
92
|
-
"#staged",
|
|
93
|
-
"new.ts",
|
|
94
|
-
"#unstaged",
|
|
95
|
-
"a.ts",
|
|
96
|
-
"b.ts",
|
|
97
|
-
"#untracked",
|
|
98
|
-
"logo.png",
|
|
99
|
-
]);
|
|
100
|
-
// Header rows carry their group's count and are not selectable.
|
|
101
|
-
const header = view.rows.find((r) => r.kind === "group" && r.group === "unstaged")!;
|
|
102
|
-
expect(header.count).toBe(2);
|
|
103
|
-
expect(header.selectable).toBe(false);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("omits a group header when its filtered set is empty", () => {
|
|
107
|
-
const view = flattenWorkspaceChangesView({ entries, filter: { group: "staged" } });
|
|
108
|
-
expect(view.rows.every((r) => r.group === "staged")).toBe(true);
|
|
109
|
-
expect(view.rows.filter((r) => r.kind === "group")).toHaveLength(1);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("moves the selection across change rows, skipping headers", () => {
|
|
113
|
-
const rows = flattenWorkspaceChangesView({ entries }).rows;
|
|
114
|
-
const staged = changeId("staged");
|
|
115
|
-
const firstUnstaged = changeId("a-unstaged");
|
|
116
|
-
expect(moveWorkspaceChangeSelection(rows, null, "down")).toBe(staged);
|
|
117
|
-
// Stepping down from the last staged change lands on the first unstaged one.
|
|
118
|
-
expect(moveWorkspaceChangeSelection(rows, staged, "down")).toBe(firstUnstaged);
|
|
119
|
-
expect(moveWorkspaceChangeSelection(rows, staged, "up")).toBe(staged);
|
|
120
|
-
expect(moveWorkspaceChangeSelection([], null, "down")).toBeNull();
|
|
121
|
-
});
|
|
122
|
-
});
|