Skip to content

fix(files-context)-refresh-on-new-file-and-save #5564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ export class Core {
tool,
toolCallId: toolCall.id,
onPartialOutput,
core: this, // Add a reference to the Core instance
});
});

Expand Down Expand Up @@ -1075,7 +1076,7 @@ export class Core {
this.indexingCancellationController = undefined;
}

private async refreshCodebaseIndexFiles(files: string[]) {
async refreshCodebaseIndexFiles(files: string[]) {
// Can be cancelled by codebase index but not vice versa
if (
this.indexingCancellationController &&
Expand Down Expand Up @@ -1103,7 +1104,7 @@ export class Core {
}

this.messenger.send("refreshSubmenuItems", {
providers: "dependsOnIndexing",
providers: "all",
});
this.indexingCancellationController = undefined;
}
Expand Down
2 changes: 2 additions & 0 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import Parser from "web-tree-sitter";
import { LLMConfigurationStatuses } from "./llm/constants";
import { GetGhTokenArgs } from "./protocol/ide";
import { Core } from "./core";

declare global {
interface Window {
Expand Down Expand Up @@ -972,6 +973,7 @@ export interface ToolExtras {
toolCallId: string;
contextItems: ContextItem[];
}) => void;
core?: Core; // Reference to the Core instance
}

export interface Tool {
Expand Down
4 changes: 4 additions & 0 deletions core/tools/implementations/createNewFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const createNewFileImpl: ToolImpl = async (args, extras) => {
}
await extras.ide.writeFile(resolvedFileUri, args.contents);
await extras.ide.openFile(resolvedFileUri);
await extras.ide.saveFile(resolvedFileUri);
if (extras.core) {
await extras.core.refreshCodebaseIndexFiles([resolvedFileUri]);
}
return [
{
name: getUriPathBasename(resolvedFileUri),
Expand Down
Loading