Skip to content

Commit b4f0ebb

Browse files
committed
github copilot/vsc extension standardize hook input field casing
1 parent 30e7f39 commit b4f0ebb

File tree

3 files changed

+285
-24
lines changed

3 files changed

+285
-24
lines changed

agent-support/vscode/src/ai-edit-manager.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ export class AIEditManager {
181181
console.log('[git-ai] AIEditManager: Dirty files with saved file content:', dirtyFiles);
182182
this.checkpoint("ai", JSON.stringify({
183183
hook_event_name: "after_edit",
184-
chatSessionPath,
185-
sessionId,
184+
chat_session_path: chatSessionPath,
185+
session_id: sessionId,
186186
edited_filepaths: [filePath],
187-
workspaceFolder: workspaceFolder.uri.fsPath,
188-
dirtyFiles,
187+
workspace_folder: workspaceFolder.uri.fsPath,
188+
dirty_files: dirtyFiles,
189189
}));
190190
checkpointTriggered = true;
191191
}
@@ -265,9 +265,9 @@ export class AIEditManager {
265265
// Prepare hook input for human checkpoint (session ID is not reliable, so we skip it)
266266
const hookInput = JSON.stringify({
267267
hook_event_name: "before_edit",
268-
workspaceFolder: workspaceFolder.uri.fsPath,
268+
workspace_folder: workspaceFolder.uri.fsPath,
269269
will_edit_filepaths: filesToCheckpoint,
270-
dirtyFiles: dirtyFiles,
270+
dirty_files: dirtyFiles,
271271
});
272272

273273
this.checkpoint("human", hookInput);

src/commands/checkpoint_agent/agent_presets.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -834,20 +834,23 @@ impl AgentCheckpointPreset for GithubCopilotPreset {
834834
}
835835

836836
// Required working directory provided by the extension
837+
// Accept snake_case (new) with fallback to camelCase (old) for backward compatibility
837838
let repo_working_dir: String = hook_data
838-
.get("workspaceFolder")
839+
.get("workspace_folder")
839840
.and_then(|v| v.as_str())
841+
.or_else(|| hook_data.get("workspaceFolder").and_then(|v| v.as_str()))
840842
.ok_or_else(|| {
841843
GitAiError::PresetError(
842-
"workspaceFolder not found in hook_input for GitHub Copilot preset".to_string(),
844+
"workspace_folder or workspaceFolder not found in hook_input for GitHub Copilot preset".to_string(),
843845
)
844846
})?
845847
.to_string();
846848

847-
// Extract dirtyFiles if available
849+
// Extract dirty_files if available (snake_case with fallback to camelCase)
848850
let dirty_files = hook_data
849-
.get("dirtyFiles")
851+
.get("dirty_files")
850852
.and_then(|v| v.as_object())
853+
.or_else(|| hook_data.get("dirtyFiles").and_then(|v| v.as_object()))
851854
.map(|obj| {
852855
obj.iter()
853856
.filter_map(|(key, value)| {
@@ -898,21 +901,26 @@ impl AgentCheckpointPreset for GithubCopilotPreset {
898901
}
899902

900903
// Handle after_edit (AI checkpoint)
904+
// Accept snake_case (new) with fallback to camelCase (old) for backward compatibility
901905
let chat_session_path = hook_data
902-
.get("chatSessionPath")
906+
.get("chat_session_path")
903907
.and_then(|v| v.as_str())
908+
.or_else(|| hook_data.get("chatSessionPath").and_then(|v| v.as_str()))
904909
.ok_or_else(|| {
905-
GitAiError::PresetError("chatSessionPath not found in hook_input for after_edit".to_string())
910+
GitAiError::PresetError("chat_session_path or chatSessionPath not found in hook_input for after_edit".to_string())
906911
})?;
907912

908913
let agent_metadata = HashMap::from([
909914
("chat_session_path".to_string(), chat_session_path.to_string()),
910915
]);
911916

912-
// Accept either chatSessionId (old) or sessionId (from VS Code extension)
917+
// Accept snake_case (new) with fallback to camelCase (old) for backward compatibility
918+
// Accept either chat_session_id/session_id (new) or chatSessionId/sessionId (old)
913919
let chat_session_id = hook_data
914-
.get("chatSessionId")
920+
.get("chat_session_id")
915921
.and_then(|v| v.as_str())
922+
.or_else(|| hook_data.get("session_id").and_then(|v| v.as_str()))
923+
.or_else(|| hook_data.get("chatSessionId").and_then(|v| v.as_str()))
916924
.or_else(|| hook_data.get("sessionId").and_then(|v| v.as_str()))
917925
.unwrap_or("unknown")
918926
.to_string();

0 commit comments

Comments
 (0)