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
This commit is contained in:
Shawn 2025-09-01 09:18:26 -04:00
parent a06779c37a
commit 91a6587a4c
4 changed files with 8 additions and 41 deletions

View file

@ -29,12 +29,6 @@ export async function getCheckpointService(
if (cline.checkpointService) {
return cline.checkpointService
}
console.log(
`[DEBUG] getCheckpointService called for task ${cline.taskId}. Service exists: ${!!cline.checkpointService}`,
)
if (!cline.enableCheckpoints) {
return undefined
}
const provider = cline.providerRef.deref()
@ -48,8 +42,6 @@ export async function getCheckpointService(
}
}
console.log("[Task#getCheckpointService] initializing checkpoints service")
try {
const workspaceDir = cline.cwd || getWorkspacePath()
@ -76,7 +68,6 @@ export async function getCheckpointService(
if (cline.checkpointServiceInitializing) {
await pWaitFor(
() => {
console.log("[Task#getCheckpointService] waiting for service to initialize")
return !!cline.checkpointService && !!cline?.checkpointService?.isInitialized
},
{ interval, timeout },
@ -136,21 +127,10 @@ async function checkGitInstallation(
try {
// Debug logging to understand checkpoint detection
console.log("[DEBUG] Checkpoint detection - total messages:", cline.clineMessages.length)
console.log(
"[DEBUG] Checkpoint detection - message types:",
cline.clineMessages.map((m) => ({ ts: m.ts, type: m.type, say: m.say, ask: m.ask })),
)
const checkpointMessages = cline.clineMessages.filter(({ say }) => say === "checkpoint_saved")
console.log(
"[DEBUG] Found checkpoint messages:",
checkpointMessages.length,
checkpointMessages.map((m) => ({ ts: m.ts, text: m.text })),
)
const isCheckpointNeeded = checkpointMessages.length === 0
console.log("[DEBUG] isCheckpointNeeded result:", isCheckpointNeeded)
cline.checkpointService = service
cline.checkpointServiceInitializing = false
@ -369,7 +349,6 @@ export async function getInitializedCheckpointService(
try {
await pWaitFor(
() => {
console.log("[Task#getCheckpointService] waiting for service to initialize")
return service.isInitialized
},
{ interval, timeout },
@ -413,19 +392,16 @@ export async function checkpointSave(cline: Task, force = false, files?: vscode.
// Capture the previous checkpoint BEFORE saving the new one
const previousCheckpoint = service.getCurrentCheckpoint()
console.log(`[checkpointSave] Previous checkpoint: ${previousCheckpoint}`)
// Start the checkpoint process in the background and track it
const savePromise = service
.saveCheckpoint(`Task: ${cline.taskId}, Time: ${Date.now()}`, { allowEmpty: force, files })
.then(async (result: any) => {
console.log(`[checkpointSave] New checkpoint created: ${result?.commit}`)
// Notify FCO that checkpoint was created
if (provider && result) {
try {
provider.postMessageToWebview({
type: "checkpoint_created",
type: "checkpointCreated",
checkpoint: result.commit,
previousCheckpoint: previousCheckpoint,
} as any)
@ -434,9 +410,6 @@ export async function checkpointSave(cline: Task, force = false, files?: vscode.
// to avoid duplicate/conflicting messages that override cumulative tracking.
// The checkpointCreated event handler calculates cumulative changes from the baseline
// and sends the complete filesChanged message with all accumulated changes.
console.log(
`[checkpointSave] FCO update delegated to checkpointCreated event for cumulative tracking`,
)
} catch (error) {
console.error("[Task#checkpointSave] Failed to notify FCO of checkpoint creation:", error)
}
@ -515,7 +488,7 @@ export async function checkpointRestore(cline: Task, { ts, commitHash, mode }: C
// Notify FCO that checkpoint was restored
try {
await provider?.postMessageToWebview({
type: "checkpoint_restored",
type: "checkpointRestored",
checkpoint: commitHash,
} as any)
} catch (error) {

View file

@ -126,8 +126,8 @@ export interface ExtensionMessage {
| "commands"
| "insertTextIntoTextarea"
| "filesChanged"
| "checkpoint_created"
| "checkpoint_restored"
| "checkpointCreated"
| "checkpointRestored"
| "say"
text?: string
payload?: any // Add a generic payload for now, can refine later
@ -204,7 +204,7 @@ export interface ExtensionMessage {
context?: string
commands?: Command[]
filesChanged?: FileChangeset // Added filesChanged property
checkpoint?: string // For checkpoint_created and checkpoint_restored messages
checkpoint?: string // For checkpointCreated and checkpointRestored messages
previousCheckpoint?: string // For checkpoint_created message
say?: ClineSay // Added say property
}

View file

@ -5,12 +5,6 @@ import { useExtensionState } from "@/context/ExtensionStateContext"
import { vscode } from "@/utils/vscode"
import { useDebouncedAction } from "@/components/ui/hooks/useDebouncedAction"
interface _CheckpointEventData {
type: "checkpoint_created" | "checkpoint_restored"
checkpoint: string
previousCheckpoint?: string
}
/**
* FilesChangedOverview is a self-managing component that listens for checkpoint events
* and displays file changes. It manages its own state and communicates with the backend
@ -149,7 +143,7 @@ const FilesChangedOverview: React.FC = () => {
case "checkpoint_created":
handleCheckpointCreated(message.checkpoint, message.previousCheckpoint)
break
case "checkpoint_restored":
case "checkpointRestored":
handleCheckpointRestored(message.checkpoint)
break
}

View file

@ -233,7 +233,7 @@ describe("FilesChangedOverview (Self-Managing)", () => {
})
})
it("should handle checkpoint_restored message", async () => {
it("should handle checkpointRestored message", async () => {
renderComponent()
// First set up some files
@ -248,7 +248,7 @@ describe("FilesChangedOverview (Self-Managing)", () => {
// Simulate checkpoint restore
simulateMessage({
type: "checkpoint_restored",
type: "checkpointRestored",
checkpoint: "restored-checkpoint-hash",
})