Skip to content

Conversation

@ctlai95
Copy link
Contributor

@ctlai95 ctlai95 commented Apr 4, 2025

Problem

Use https://www.npmjs.com/package/diff for diffs

Solution

  • Update diffs for FsWrite
  • Remove hardcoded changed lines
  • Remove hardcoded diff language
  • Use file name instead of file path in card header
image
  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

github-actions bot commented Apr 4, 2025

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@ctlai95 ctlai95 marked this pull request as ready for review April 4, 2025 19:14
@ctlai95 ctlai95 requested review from a team as code owners April 4, 2025 19:14
let oldContent
try {
oldContent = await fs.readFileText(sanitizedPath)
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we log it? what is the expected UX if we cannot read the file, do we still want to proceed with showing diffs?

Copy link
Contributor

Choose a reason for hiding this comment

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

LLM sends the filePath which may or may not exist
If fileExists we take the oldContent if not we consider this as a new file and keep oldContent as ''.
I think we should not inform end customer about this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah in the create command case, this is expected to fail because the file doesn't exist yet. So I don't think its necessary to show an error


private async handleStrReplace(params: StrReplaceParams, sanitizedPath: string): Promise<void> {
const newContent = await this.getStrReplaceContent(params, sanitizedPath)
await fs.writeFile(sanitizedPath, newContent)
Copy link
Contributor

Choose a reason for hiding this comment

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

does caller has error handling for these?

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 any error thrown from a tool will get sent back to the LLM

*/
export async function getLanguageForFilePath(filePath: string): Promise<string | undefined> {
try {
const document = await vscode.workspace.openTextDocument(filePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this one recognize the languages that's not supported by VS Code natively?

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 think right now no, the language will have to be recognized by vscode

Copy link
Contributor

Choose a reason for hiding this comment

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

did product ack this? or we can switch to use the file extension matching logic that we have

Copy link
Contributor

Choose a reason for hiding this comment

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

This will only recognize languages natively supported by Visual Studio Code, though it covers most programming languages. For unsupported languages, it defaults to plaintext.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that, my question is if this is what product/UX expected, because some of them are technically supported by Q although not by VS Code

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 think if we use our file extension matching logic it might be too restrictive? For new languages we have to always update the map.

Another reason I was thinking to use VSCode API is that the markdown diff view and the native diff view should have consistent syntax highlighting

Copy link
Contributor

Choose a reason for hiding this comment

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

this is ok to follow up

@zixlin7 zixlin7 merged commit aefe920 into aws:feature/agentic-chat Apr 4, 2025
21 of 22 checks passed
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