Skip to content

Commit bb2ae8d

Browse files
playcationshannesrudolph
authored andcommitted
ix: code quality improvements for FCO feature and address more comments
- Remove duplicate enableCheckpoints check in checkpoints/index.ts - Remove unused _CheckpointEventData interface from FilesChangedOverview.tsx - Fix message type naming consistency: checkpoint_created -> checkpointCreated, checkpoint_restored -> checkpointRestored - Remove debug console.log statements from checkpoints/index.ts
1 parent 3048471 commit bb2ae8d

File tree

4 files changed

+11
-40
lines changed

4 files changed

+11
-40
lines changed

src/core/checkpoints/index.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export async function getCheckpointService(
4343
}
4444
}
4545

46-
console.log("[Task#getCheckpointService] initializing checkpoints service")
47-
4846
try {
4947
const workspaceDir = task.cwd || getWorkspacePath()
5048

@@ -72,7 +70,6 @@ export async function getCheckpointService(
7270
if (task.checkpointServiceInitializing) {
7371
await pWaitFor(
7472
() => {
75-
console.log("[Task#getCheckpointService] waiting for service to initialize")
7673
return !!task.checkpointService && !!task?.checkpointService?.isInitialized
7774
},
7875
{ interval, timeout },
@@ -133,22 +130,9 @@ async function checkGitInstallation(
133130
log("[Task#getCheckpointService] service initialized")
134131

135132
try {
136-
// Debug logging to understand checkpoint detection
137-
console.log("[DEBUG] Checkpoint detection - total messages:", task.clineMessages.length)
138-
console.log(
139-
"[DEBUG] Checkpoint detection - message types:",
140-
task.clineMessages.map((m) => ({ ts: m.ts, type: m.type, say: m.say, ask: m.ask })),
141-
)
142-
143133
const checkpointMessages = task.clineMessages.filter(({ say }) => say === "checkpoint_saved")
144-
console.log(
145-
"[DEBUG] Found checkpoint messages:",
146-
checkpointMessages.length,
147-
checkpointMessages.map((m) => ({ ts: m.ts, text: m.text })),
148-
)
149134

150135
const isCheckpointNeeded = checkpointMessages.length === 0
151-
console.log("[DEBUG] isCheckpointNeeded result:", isCheckpointNeeded)
152136

153137
task.checkpointService = service
154138
task.checkpointServiceInitializing = false
@@ -375,7 +359,6 @@ export async function getInitializedCheckpointService(
375359
try {
376360
await pWaitFor(
377361
() => {
378-
console.log("[Task#getCheckpointService] waiting for service to initialize")
379362
return service.isInitialized
380363
},
381364
{ interval, timeout },
@@ -418,20 +401,17 @@ export async function checkpointSave(task: Task, force = false, files?: vscode.U
418401
const provider = task.providerRef.deref()
419402

420403
// Capture the previous checkpoint BEFORE saving the new one
421-
const previousCheckpoint = service.baseHash
422-
console.log(`[checkpointSave] Previous checkpoint: ${previousCheckpoint}`)
404+
const previousCheckpoint = service.getCurrentCheckpoint()
423405

424406
// Start the checkpoint process in the background and track it
425407
const savePromise = service
426408
.saveCheckpoint(`Task: ${task.taskId}, Time: ${Date.now()}`, { allowEmpty: force, files, suppressMessage })
427409
.then(async (result: any) => {
428-
console.log(`[checkpointSave] New checkpoint created: ${result?.commit}`)
429-
430410
// Notify FCO that checkpoint was created
431411
if (provider && result) {
432412
try {
433413
provider.postMessageToWebview({
434-
type: "checkpoint_created",
414+
type: "checkpointCreated",
435415
checkpoint: result.commit,
436416
previousCheckpoint: previousCheckpoint,
437417
} as any)
@@ -440,9 +420,6 @@ export async function checkpointSave(task: Task, force = false, files?: vscode.U
440420
// to avoid duplicate/conflicting messages that override cumulative tracking.
441421
// The checkpoint event handler calculates cumulative changes from the baseline
442422
// and sends the complete filesChanged message with all accumulated changes.
443-
console.log(
444-
`[checkpointSave] FCO update delegated to checkpoint event for cumulative tracking`,
445-
)
446423
} catch (error) {
447424
console.error("[Task#checkpointSave] Failed to notify FCO of checkpoint creation:", error)
448425
}
@@ -509,8 +486,8 @@ export async function checkpointRestore(
509486
}
510487

511488
// Calculate and send current changes with LLM-only filtering (should be empty immediately after restore)
512-
if (cline.taskId && cline.fileContextTracker) {
513-
const changes = await fileChangeManager.getLLMOnlyChanges(cline.taskId, cline.fileContextTracker)
489+
if (task.taskId && task.fileContextTracker) {
490+
const changes = await fileChangeManager.getLLMOnlyChanges(task.taskId, task.fileContextTracker)
514491
provider?.postMessageToWebview({
515492
type: "filesChanged",
516493
filesChanged: changes.files.length > 0 ? changes : undefined,
@@ -525,7 +502,7 @@ export async function checkpointRestore(
525502
// Notify FCO that checkpoint was restored
526503
try {
527504
await provider?.postMessageToWebview({
528-
type: "checkpoint_restored",
505+
type: "checkpointRestored",
529506
checkpoint: commitHash,
530507
} as any)
531508
} catch (error) {

src/shared/ExtensionMessage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export interface ExtensionMessage {
129129
| "commands"
130130
| "insertTextIntoTextarea"
131131
| "filesChanged"
132-
| "checkpoint_created"
133-
| "checkpoint_restored"
132+
| "checkpointCreated"
133+
| "checkpointRestored"
134134
| "say"
135135
text?: string
136136
payload?: any // Add a generic payload for now, can refine later
@@ -209,7 +209,7 @@ export interface ExtensionMessage {
209209
commands?: Command[]
210210
queuedMessages?: QueuedMessage[]
211211
filesChanged?: FileChangeset // Added filesChanged property
212-
checkpoint?: string // For checkpoint_created and checkpoint_restored messages
212+
checkpoint?: string // For checkpointCreated and checkpointRestored messages
213213
previousCheckpoint?: string // For checkpoint_created message
214214
say?: ClineSay // Added say property
215215
}

webview-ui/src/components/file-changes/FilesChangedOverview.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import { useExtensionState } from "@/context/ExtensionStateContext"
55
import { vscode } from "@/utils/vscode"
66
import { useDebouncedAction } from "@/components/ui/hooks/useDebouncedAction"
77

8-
interface _CheckpointEventData {
9-
type: "checkpoint_created" | "checkpoint_restored"
10-
checkpoint: string
11-
previousCheckpoint?: string
12-
}
13-
148
/**
159
* FilesChangedOverview is a self-managing component that listens for checkpoint events
1610
* and displays file changes. It manages its own state and communicates with the backend
@@ -149,7 +143,7 @@ const FilesChangedOverview: React.FC = () => {
149143
case "checkpoint_created":
150144
handleCheckpointCreated(message.checkpoint, message.previousCheckpoint)
151145
break
152-
case "checkpoint_restored":
146+
case "checkpointRestored":
153147
handleCheckpointRestored(message.checkpoint)
154148
break
155149
}

webview-ui/src/components/file-changes/__tests__/FilesChangedOverview.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe("FilesChangedOverview (Self-Managing)", () => {
233233
})
234234
})
235235

236-
it("should handle checkpoint_restored message", async () => {
236+
it("should handle checkpointRestored message", async () => {
237237
renderComponent()
238238

239239
// First set up some files
@@ -248,7 +248,7 @@ describe("FilesChangedOverview (Self-Managing)", () => {
248248

249249
// Simulate checkpoint restore
250250
simulateMessage({
251-
type: "checkpoint_restored",
251+
type: "checkpointRestored",
252252
checkpoint: "restored-checkpoint-hash",
253253
})
254254

0 commit comments

Comments
 (0)