Skip to content

Commit 454cef7

Browse files
committed
Remove unused queue logic
1 parent 4f8db58 commit 454cef7

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

packages/code-link-cli/src/controller.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ function disconnectedState() {
1313
mode: "disconnected" as const,
1414
socket: null,
1515
pendingRemoteChanges: [],
16-
pendingOperations: new Map(),
17-
nextOperationId: 1,
1816
}
1917
}
2018

@@ -23,8 +21,6 @@ function watchingState() {
2321
mode: "watching" as const,
2422
socket: mockSocket,
2523
pendingRemoteChanges: [],
26-
pendingOperations: new Map(),
27-
nextOperationId: 1,
2824
}
2925
}
3026

@@ -33,8 +29,6 @@ function handshakingState() {
3329
mode: "handshaking" as const,
3430
socket: mockSocket,
3531
pendingRemoteChanges: [],
36-
pendingOperations: new Map(),
37-
nextOperationId: 1,
3832
}
3933
}
4034

@@ -43,8 +37,6 @@ function snapshotProcessingState() {
4337
mode: "snapshot_processing" as const,
4438
socket: mockSocket,
4539
pendingRemoteChanges: [],
46-
pendingOperations: new Map(),
47-
nextOperationId: 1,
4840
}
4941
}
5042

@@ -64,8 +56,6 @@ function conflictResolutionState(
6456
socket: mockSocket,
6557
pendingConflicts,
6658
pendingRemoteChanges: [],
67-
pendingOperations: new Map(),
68-
nextOperationId: 1,
6959
}
7060
}
7161

@@ -249,16 +239,17 @@ describe("Code Link", () => {
249239
expect(result.effects.some(e => e.type === "WRITE_FILES")).toBe(true)
250240
})
251241

252-
it("queues changes during initial sync", () => {
253-
// Changes arriving during snapshot processing are queued, not applied immediately
242+
it("ignores changes during initial sync", () => {
243+
// Changes arriving during snapshot processing are ignored - snapshot handles reconciliation
254244
const state = snapshotProcessingState()
255245
const result = transition(state, {
256246
type: "REMOTE_FILE_CHANGE",
257247
file: { name: "Button.tsx", content: "late arrival", modifiedAt: Date.now() },
258248
})
259249

260-
expect(result.state.pendingRemoteChanges).toHaveLength(1)
250+
expect(result.state.pendingRemoteChanges).toHaveLength(0)
261251
expect(result.effects.some(e => e.type === "WRITE_FILES")).toBe(false)
252+
expect(result.effects.some(e => e.type === "LOG")).toBe(true)
262253
})
263254

264255
it("creates new local file and uploads to Framer", () => {

packages/code-link-cli/src/controller.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,11 @@ import { hashFileContent } from "./utils/state-persistence.ts"
5050
*/
5151
export type SyncMode = "disconnected" | "handshaking" | "snapshot_processing" | "conflict_resolution" | "watching"
5252

53-
/**
54-
* Pending operation for echo suppression and replay
55-
*/
56-
type PendingOperation =
57-
| { id: string; type: "write"; file: string; hash: string }
58-
| { id: string; type: "delete"; file: string; previousHash?: string }
59-
6053
/**
6154
* Shared state that persists across all lifecycle modes
6255
*/
6356
interface SyncStateBase {
6457
pendingRemoteChanges: FileInfo[]
65-
pendingOperations: Map<string, PendingOperation>
66-
nextOperationId: number
6758
}
6859

6960
type DisconnectedState = SyncStateBase & {
@@ -380,15 +371,9 @@ function transition(state: SyncState, event: SyncEvent): { state: SyncState; eff
380371
const validation = validateIncomingChange(event.fileMeta, state.mode)
381372

382373
if (validation.action === "queue") {
383-
effects.push(log("debug", `Queueing file change: ${event.file.name} (${validation.reason})`))
384-
385-
return {
386-
state: {
387-
...state,
388-
pendingRemoteChanges: [...state.pendingRemoteChanges, event.file],
389-
},
390-
effects,
391-
}
374+
// Changes during initial sync are ignored - the snapshot handles reconciliation
375+
effects.push(log("debug", `Ignoring file change during sync: ${event.file.name}`))
376+
return { state, effects }
392377
}
393378

394379
if (validation.action === "reject") {
@@ -996,8 +981,6 @@ export async function start(config: Config): Promise<void> {
996981
mode: "disconnected",
997982
socket: null,
998983
pendingRemoteChanges: [],
999-
pendingOperations: new Map(),
1000-
nextOperationId: 1,
1001984
}
1002985

1003986
const userActions = new PluginUserPromptCoordinator()

0 commit comments

Comments
 (0)