Skip to content
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

bug: mentioned files content not always being included #2402

Closed
DanTup opened this issue Dec 15, 2023 · 1 comment · Fixed by #2405
Closed

bug: mentioned files content not always being included #2402

DanTup opened this issue Dec 15, 2023 · 1 comment · Fixed by #2405
Assignees
Labels
bug Something isn't working clients/vscode

Comments

@DanTup
Copy link
Contributor

DanTup commented Dec 15, 2023

Version

main 2a00da0

Describe the bug

I mentioned two files, but they were not both included:

image

The exported chat shows:

"usedContextFiles": [
	{
		"fileName": "c:\\Dev\\Test Projects\\cody_testing\\analysis_options.yaml",
		"source": "user",
		"content": "# This file configures the static analysis results for your project (errors,\n# warnings, and lints).\n#\n# This enables the 'recommended' set of lints from `package:lints`.\n# This set helps identify many issues that may lead to problems when running\n# or consuming Dart code, and enforces writing Dart using a single, idiomatic\n# style and format.\n#\n# If you want a smaller set of lints you can change this to specify\n# 'package:lints/core.yaml'. These are just the most critical lints\n# (the recommended set includes the core lints).\n# The core lints are also what is used by pub.dev for scoring packages.\n\ninclude: package:lints/recommended.yaml\n\n# Uncomment the following section to specify additional rules.\n\n# linter:\n#   rules:\n#     - camel_case_types\n\n# analyzer:\n#   exclude:\n#     - path/to/excluded/files/**\n\n# For more information about the core and recommended set of lints, see\n# https://dart.dev/go/core-lints\n\n# For additional information about configuring this file, see\n# https://dart.dev/guides/language/analysis-options\n"
	},
	{
		"fileName": "README.md",
		"content": "A sample command-line application with an entrypoint in `bin/`, library code\nin `lib/`, and example unit test in `test/`.\n"
	}
],

It includes the README and one of the files I mentioned, but not the other file mentioned.

Expected behavior

Any mentioned file should be included.

Additional context

No response

@DanTup DanTup added bug Something isn't working clients/vscode labels Dec 15, 2023
@DanTup DanTup self-assigned this Dec 15, 2023
@DanTup
Copy link
Contributor Author

DanTup commented Dec 15, 2023

With some debugging, I ended up here. We have some code that tries to de-dupe items here, and it's building an ID by calling toString() on a URI, but it's [Object object], so every file mentioned in the chat looks like a dupe and it seems like we'll only keep the first.

image

(perhaps this URI has been serialised/deserialised somewhere?)

DanTup added a commit that referenced this issue Dec 15, 2023
Because the search results come from inside the webview, the URIs are not real vscode.Uri instances. The code that computes IDs for each context to de-dupe them uses `contextItem.uri.toString()` which would be `[Object object]`.

This converts them back to real `vscode.Uris` which fixes the de-dupe check.

Fixes #2402
DanTup added a commit that referenced this issue Dec 22, 2023
Because the search results come from inside the webview, the URIs are
not real vscode.Uri instances. The code that computes IDs for each
context to de-dupe them uses `contextItem.uri.toString()` which would be
`[Object object]`.


![image](https://github.com/sourcegraph/cody/assets/1078012/272f9ef4-0c89-40ab-9b8b-8eb10e3e619f)

This converts them back to real `vscode.Uris` which fixes the de-dupe
check.

Fixes #2402

## Test plan

- Run `pnpm test:e2e at-file` to run the automated test which verifies
after asking about two files that the context has a count of two
- Or manually mention two files in chat and ensure both appear in
context and that the model is aware of both file contents (or export the
chat and confirm that both files appear in the context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working clients/vscode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant