Skip to content

Commit

Permalink
Make log history only for non-chat edit actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vovakulikov committed Oct 25, 2024
1 parent 6ae80ae commit 56ae168
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions vscode/src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export interface CodyCommandArgs extends ExecuteEditArguments {
requestID: string
// where the command was triggered from
source?: EventSource
// runs the command in chat mode, even if it's an edit command
runInChatMode?: boolean
// current context to add on top of the command context
userContextFiles?: ContextItem[]
additionalInstruction?: PromptString
Expand Down
2 changes: 2 additions & 0 deletions vscode/src/edit/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface ExecuteEditArguments {
insertionPoint?: vscode.Position
}
source?: EventSource
// runs the command in chat mode, even if it's an edit command
runInChatMode?: boolean
telemetryMetadata?: FixupTelemetryMetadata
}

Expand Down
3 changes: 2 additions & 1 deletion vscode/src/edit/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class EditManager implements vscode.Disposable {

public async executeEdit(args: ExecuteEditArguments = {}): Promise<FixupTask | undefined> {
const {
runInChatMode,
configuration = {},
/**
* Note: Source must default to `editor` as these are
Expand Down Expand Up @@ -231,7 +232,7 @@ export class EditManager implements vscode.Disposable {
)
}
const provider = this.getProviderForTask(task)
await provider.startEdit()
await provider.startEdit({ saveInHistory: !runInChatMode })
return task
}

Expand Down
8 changes: 5 additions & 3 deletions vscode/src/edit/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class EditProvider {

constructor(public config: EditProviderOptions) {}

public async startEdit(): Promise<void> {
public async startEdit(options?: { saveInHistory: boolean }): Promise<void> {
return wrapInActiveSpan('command.edit.start', async span => {
this.config.controller.startTask(this.config.task)
const model = this.config.task.model
Expand Down Expand Up @@ -103,7 +103,9 @@ export class EditProvider {
onTurnComplete: async () => {
typewriter.close()
typewriter.stop()
void this.saveEditAsChatEntry(text)
if (options?.saveInHistory) {
void this.saveEditAsChatEntry(text)
}
void this.handleResponse(text, false)
return Promise.resolve()
},
Expand Down Expand Up @@ -213,7 +215,7 @@ export class EditProvider {
responseMessage += '```\n' + `${responseContent}\n` + '```'

const chatEntry: SerializedChatTranscript = {
id: this.config.task.id,
id: Date.now().toString(36).replaceAll(/\d+/g, ''),
interactions: [
{
humanMessage: {
Expand Down

0 comments on commit 56ae168

Please sign in to comment.