Skip to content

Commit 4f8db58

Browse files
committed
Typesafe file content restoration
1 parent 699c3c9 commit 4f8db58

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ export async function start(config: Config): Promise<void> {
11631163
await processEvent({
11641164
type: "LOCAL_DELETE_REJECTED",
11651165
fileName: file.fileName,
1166-
content: file.content ?? "",
1166+
content: file.content,
11671167
})
11681168
}
11691169

packages/code-link-shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export { getPortFromHash } from "./ports.ts"
1919
// Sync tracker
2020
export { createSyncTracker, type SyncTracker } from "./sync-tracker.ts"
2121
export type {
22+
CancelledDelete,
2223
CliToPluginMessage,
2324
ConflictSummary,
2425
ConflictVersionData,

packages/code-link-shared/src/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export interface PendingDelete {
1212
content?: string
1313
}
1414

15+
/** File with content to restore when delete is cancelled - content is required */
16+
export interface CancelledDelete {
17+
fileName: string
18+
content: string
19+
}
20+
1521
export interface ConflictSummary {
1622
fileName: string
1723
/** null means the file was deleted on this side */
@@ -78,7 +84,7 @@ export type PluginToCliMessage =
7884
| { type: "file-change"; fileName: string; content: string }
7985
| { type: "file-delete"; fileNames: string[] }
8086
| { type: "delete-confirmed"; fileNames: string[] }
81-
| { type: "delete-cancelled"; files: PendingDelete[] }
87+
| { type: "delete-cancelled"; files: CancelledDelete[] }
8288
| { type: "file-synced"; fileName: string; remoteModifiedAt: number }
8389
| {
8490
type: "conflicts-resolved"

plugins/code-link/src/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,14 @@ function createMessageHandler({
659659
const files: PendingDelete[] = []
660660
for (const fileName of message.fileNames) {
661661
const content = await api.readCurrentContent(fileName)
662-
files.push({ fileName, content })
662+
// Only include files that exist in Framer (have content to restore)
663+
if (content !== undefined) {
664+
files.push({ fileName, content })
665+
}
666+
}
667+
if (files.length === 0) {
668+
// No files exist in Framer, nothing to confirm
669+
break
663670
}
664671
dispatch({
665672
type: "pending-deletes",

0 commit comments

Comments
 (0)