Skip to content

feat: add Trae and Tongyi Lingma presets for checkpointing#716

Open
luoweb wants to merge 1 commit intogit-ai-project:mainfrom
luoweb:main-dev-roweb
Open

feat: add Trae and Tongyi Lingma presets for checkpointing#716
luoweb wants to merge 1 commit intogit-ai-project:mainfrom
luoweb:main-dev-roweb

Conversation

@luoweb
Copy link

@luoweb luoweb commented Mar 16, 2026

  • Implemented TraePreset and its functionality to handle checkpointing with Trae JSON input.
  • Added TongyiLingmaPreset for checkpointing with Tongyi Lingma JSON input.
  • Updated the command handler to support both new presets, allowing users to specify them in the checkpoint command.
  • Enhanced error handling for JSON parsing and added appropriate logging for failures.

Open with Devin

- Implemented TraePreset and its functionality to handle checkpointing with Trae JSON input.
- Added TongyiLingmaPreset for checkpointing with Tongyi Lingma JSON input.
- Updated the command handler to support both new presets, allowing users to specify them in the checkpoint command.
- Enhanced error handling for JSON parsing and added appropriate logging for failures.
@CLAassistant
Copy link

CLAassistant commented Mar 16, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment on lines +485 to 492
} else if (activeEditor && (activeEditor.document.uri.scheme === "tongyi-lingma-snapshot")) {
args.push("tongyi-lingma");
} else if (activeEditor && (activeEditor.document.uri.scheme === "continue-snapshot")) {
args.push("continue-cli");
} else if (activeEditor && (activeEditor.document.uri.scheme === "trae-snapshot")) {
args.push("trae");
} else {
args.push("github-copilot");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Agent type routing in checkpoint() always falls through to github-copilot for new agents

The checkpoint method at agent-support/vscode/src/ai-edit-manager.ts:485-492 determines which CLI preset to use by checking activeEditor.document.uri.scheme against snapshot schemes like tongyi-lingma-snapshot, continue-snapshot, and trae-snapshot. However, activeEditor (vscode.window.activeTextEditor at line 452) is the user's focused text editor, which will have scheme "file" — not a snapshot scheme. Snapshot documents are internal virtual documents that VS Code opens for diff/comparison; they are never the active text editor.

As a result, for all Tongyi Lingma, Continue, and Trae AI edit checkpoints, the conditions at lines 485-490 will never match, and the code always falls through to args.push("github-copilot"). The checkpoint is then dispatched to GithubCopilotPreset on the Rust side, which attributes all edits to "github-copilot" instead of the correct agent tool. The agentType field correctly computed in evaluateSaveForCheckpoint (line 221) and included in the hook JSON as agent_type (line 348) is effectively unused because the wrong preset processes it.

The correct approach would be to pass agentType through to checkpoint()

The evaluateSaveForCheckpoint method already computes the correct agentType at line 221 and includes it in the JSON payload. The checkpoint method should accept and use this value to determine the CLI preset argument, rather than relying on the unreliable activeEditor.document.uri.scheme check.

Prompt for agents
In agent-support/vscode/src/ai-edit-manager.ts, the checkpoint() method at line 439 should accept an optional agentType parameter (e.g., agentType?: string) that overrides the preset selection. When author is 'ai', the calling code in evaluateSaveForCheckpoint (around line 341) should pass the already-computed agentType variable. Then in the checkpoint method around lines 482-493, use the passed agentType to determine args instead of checking activeEditor.document.uri.scheme. For example:

checkpoint signature: async checkpoint(author: 'human' | 'ai' | 'ai_tab', hookInput: string, agentType?: string): Promise<boolean>

In the args building section (lines 482-493):
  const args = ['checkpoint'];
  if (author === 'ai_tab') {
    args.push('ai_tab');
  } else if (agentType) {
    args.push(agentType);
  } else {
    args.push('github-copilot');
  }

Update the call site in evaluateSaveForCheckpoint (line 341) to pass agentType:
  this.checkpoint('ai', JSON.stringify({...}), agentType);

Similarly update the triggerHumanCheckpoint call at line 436 if needed.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

// Handle VS Code native snapshots
if (!snapshotInfo.uri.query) {
console.warn('[git-ai] AIEditManager: Snapshot URI missing query, skipping AI checkpoint for', filePath);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Early return statements in evaluateSaveForCheckpoint skip cleanup of pendingSaves and snapshotOpenEvents

The refactored evaluateSaveForCheckpoint introduces early return statements at lines 282, 306, 317, and 323 that bypass the cleanup code at lines 363-364 (this.pendingSaves.delete(filePath) and this.snapshotOpenEvents.delete(filePath)). In the old code, all error paths fell through to the cleanup block (missing query just failed the outer if condition; missing session id just logged a warning without returning).

When an early return is hit, the stale snapshotOpenEvents entry persists in the map. On the next save event for the same file, if a new snapshot was opened but is for a different URI or different session, the stale entry may cause incorrect behavior because handleOpenEvent (line 148-150) increments the existing entry's count rather than creating a fresh one. The stale pendingSaves entry also leaks (the timer has already fired, but the map entry remains until the next save overwrites it at handleSaveEvent:94-96).

Prompt for agents
In agent-support/vscode/src/ai-edit-manager.ts, the evaluateSaveForCheckpoint method has early return statements at lines 282, 306, 317, and 323 that skip the cleanup code at lines 363-364. To fix this, either:

1. Replace each early `return;` with setting a flag and breaking out of the block, so cleanup always runs. Or:

2. Add cleanup calls before each early return. Add these two lines before each `return;` at lines 282, 306, 317, and 323:
   this.pendingSaves.delete(filePath);
   this.snapshotOpenEvents.delete(filePath);

3. Or wrap the logic in a try-finally where the finally block always runs cleanup:
   try { ... all the processing with returns ... } finally { this.pendingSaves.delete(filePath); this.snapshotOpenEvents.delete(filePath); }

Option 3 is cleanest as it also handles any future returns added to this method.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants