Skip to content

fix: onFileClick logic is crashing the whole process if no workspace … #1119

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

volodkevych
Copy link
Contributor

@volodkevych volodkevych commented Apr 24, 2025

…is open

Problem

This logic was throwing exception and crashing the whole process:

        const workspaceRoot = workspaceUtils.getWorkspaceFolderPaths(this.#features.lsp)[0]
        let absolutePath = path.join(workspaceRoot, params.filePath) <--- HERE, because workspaceRoot is undefined if no workspace is open

Solution

  • Move the code for workspace resolution to the proper condition inside of onFileClick
  • For context items, pass the full path to client, so that client can return the fullpath back, and full path resolution is not needed anymore
  • For cases, where fullpath is not known or not passed for some reason (there can be cases - I did not go through the whole codebase), we still have this full path resolve logic, but now we search in all the workspaces and more importantly - catch the errors

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@volodkevych volodkevych marked this pull request as ready for review April 24, 2025 18:01
@volodkevych volodkevych requested a review from a team as a code owner April 24, 2025 18:01
"@aws/language-server-runtimes-types": "^0.1.23",
"@aws/mynah-ui": "^4.31.0-beta.6"
"@aws/language-server-runtimes-types": "^0.1.25",
"@aws/mynah-ui": "^4.31.0-beta.7"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to update it, because 6 did not contain fileDetails yet. It does not impact the final bundle as we always include latest Mynah there.

@@ -1354,6 +1347,29 @@ export class AgenticChatController implements ChatHandlers {
return triggerContext
}

async #resolveAbsolutePath(relativePath: string): Promise<string | undefined> {
Copy link
Contributor

@justinmk3 justinmk3 Apr 24, 2025

Choose a reason for hiding this comment

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

Is there a shared module this can live in, instead of this controller? Isn't this a generally useful function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, can be refactored to something reusable - for now, it contains prompts specifics

@volodkevych volodkevych merged commit 0211223 into main Apr 24, 2025
7 checks passed
@volodkevych volodkevych deleted the fix-file-clicked-crash branch April 24, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants