Skip to content

Commit 328fe57

Browse files
committed
Update commit prompt matching to check file overlap for empty prompts
- > Please fix a context-leak issue in `apps/editor/src/utils/commit-message-details.ts`. > **The Problem:** > Unprompted Code-at-Cursor actions pass an empty string `""` as the prompt. Currently, `CommitMessageDetails.add` finds the first entry matching this empty prompt and merges all new `files` and `selected_files` into it. Over a session, this creates one massive workspace-wide entry for `""`, causing unrelated context files to bleed into the ASCII file tree when committing. > **The Solution:** > We still want to save context files for unprompted completions, but we need to isolate them per edited file. > Update the `existing` lookup logic in `CommitMessageDetails.add`: > 1. If `simplified_prompt` is NOT empty, match by `p.prompt == simplified_prompt` (current behavior). > 2. If `simplified_prompt` IS empty `""`, only match an existing empty prompt entry if it shares at least one modified file (e.g., `p.files.some(f => files_to_add.includes(f))`). > 3. If no matching file is found f... └── apps └── editor └── src ├── commands │ ├── apply-response-command │ │ └── utils │ │ └── preview-handler.ts │ ├── code-at-cursor-command │ │ ├── code-at-cursor-commands.ts │ │ └── utils │ │ └── perform-code-at-cursor.ts │ ├── generate-commit-message-commands │ │ └── actions │ │ ├── get-prompt-data.ts │ │ └── run-generate-action.ts │ └── history-command │ └── actions │ └── restore-checkpoint.ts ├── services │ └── git-discard-file-watcher.ts └── utils └── commit-message-details.ts
1 parent 1e78bfe commit 328fe57

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎apps/editor/src/utils/commit-message-details.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ export namespace CommitMessageDetails {
9090
const files_to_add = params.files.map(normalize)
9191
const selected_files_to_add = params.selected_files.map(normalize)
9292

93-
const existing = all_prompts[params.workspace_root].find(
94-
(p) => p.prompt == simplified_prompt
95-
)
93+
const existing = all_prompts[params.workspace_root].find((p) => {
94+
if (simplified_prompt !== '') {
95+
return p.prompt == simplified_prompt
96+
}
97+
return p.prompt == '' && p.files.some((f) => files_to_add.includes(f))
98+
})
9699

97100
if (existing) {
98101
existing.files = Array.from(new Set([...existing.files, ...files_to_add]))

0 commit comments

Comments
 (0)