Skip to content

refactor: ♻️ Refactor CodeBaseIndexer out of core #5894

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chezsmithy
Copy link
Contributor

@chezsmithy chezsmithy commented May 29, 2025

Description

Refector CodeBaseIndexer out of core.ts in a way that it can be independently passed to tools which might need to perform reindexing. Not in #5564 we would now pass core (this.codeBaseIndexer) to the tools implementations rather than the the entire core object.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ]

Tests

I've manually tested the following in debug:

  1. At startup Indexing starts and suceeds.
  2. Force Reindex works.
  3. Rebuild index works.
  4. Pausing and resuming indexing work.
  5. Files in the test project show up in the index confirmed by using @files to lookup test.js

I've added new tests for CodeBaseIndexer.ts to cover the changes.

@chezsmithy chezsmithy requested a review from a team as a code owner May 29, 2025 05:04
@chezsmithy chezsmithy requested review from sestinj and removed request for a team May 29, 2025 05:04
Copy link

cubic-dev-ai bot commented May 29, 2025

Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label May 29, 2025
Copy link

netlify bot commented May 29, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit c38fca4
🔍 Latest deploy log https://app.netlify.com/projects/continuedev/deploys/6838faee2e562400080d8c51

@chezsmithy
Copy link
Contributor Author

@Patrick-Erichsen related to #5564 I've performed a refactor of CodeBaseIndxer.ts and core.ts to refactor the indexing functions out of core. I'm going to note a few questions in a self review for you.

@@ -244,6 +244,7 @@ export class VsCodeExtension {
this.consoleView,
this.configHandler,
this.verticalDiffManager,
// This is expected to exist, but it's no longer used? Can I remove it?
this.core.continueServerClientPromise,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Patrick-Erichsen this is no longer used anywhere in core. I can't see anywhere else it is used as well. Note in CodeBaseIndexer I just created a self contained new instance of this class. I'm not sure if this was meant to be a singleton or it's used in some other way? If it's no longer used we can refactor it out of here, and remove the initalization from core.ts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch @chezsmithy - I think this is safe to remove and would be appreciated if you could do so.

cc @sestinj for a sanity check however.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just poked around, seems like we might use it in extensions/vscode/src/commands.ts?

    "continue.giveAutocompleteFeedback": async () => {
      const feedback = await vscode.window.showInputBox({
        ignoreFocusOut: true,
        prompt:
          "Please share what went wrong with the last completion. The details of the completion as well as this message will be sent to the Continue team in order to improve.",
      });
      if (feedback) {
        const client = await continueServerClientPromise;
        const completionsPath = getDevDataFilePath(
          "autocomplete",
          LOCAL_DEV_DATA_VERSION,
        );

        const lastLines = await readLastLines.read(completionsPath, 2);
        client.sendFeedback(feedback, lastLines);
      }
    },

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah we should just remove this

this.codebaseIndexerPromise = new Promise(
async (resolve) => (codebaseIndexerResolve = resolve),
);

let continueServerClientResolve: (_: any) => void | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Patrick-Erichsen note this is no longer used anywhere in core. I've moved initalization into CodeBaseIndexer rather than relying on this instance. Should we just remove it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, let's remove this one too, thanks for calling it out 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sestinj cc on this question along with the other.

Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

This is a great cleanup, will make the callTools logic we originally discussed less dependent on core and this is just a solid cleanup in general. Nice we we can remove the awkward codebaseIndexerResolve things.

Going to wait to merge until I double check with @sestinj on that one comment but otherwise good to go 🚀

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs May 29, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 29, 2025
@chezsmithy chezsmithy force-pushed the feat-refactor-codebaseIndexer-from-core branch from f5d7f91 to f6d114d Compare May 30, 2025 00:05
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels May 30, 2025
@sestinj
Copy link
Contributor

sestinj commented Jun 1, 2025

All good to go from me except I think we should just completely remove "continue.giveAutocompleteFeedback"

Copy link
Contributor

@sestinj sestinj left a comment

Choose a reason for hiding this comment

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

all looks great. as we're removing the continueServerClient, let's take out the "continue.giveAutocompleteFeedback" command in VS Code

@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants