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

Forbid file mentioning for large files #4790

Conversation

Jazzcort
Copy link
Contributor

@Jazzcort Jazzcort commented Mar 24, 2025

Description

When the context items provided by user overflow the context length and are truncated, it is very confusing for the user. This is a first step that catches an common case at the least confusing time - when the user is selecting a file. A more general check that warns whenever the most recent message is truncated is something that can be added later.
Granite-Code/granite-code#22

Screenshots

large-file-mentioning

Testing instructions

Select a file that is large enough to exceed contextLength - maxTokens, then the mention should be canceled and a error dialog should pop up.

@Jazzcort Jazzcort requested a review from a team as a code owner March 24, 2025 18:56
@Jazzcort Jazzcort requested review from sestinj and removed request for a team March 24, 2025 18:56
Copy link

netlify bot commented Mar 24, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit 1611bae
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67f43ec5884f5d0008820905
😎 Deploy Preview https://deploy-preview-4790--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Jazzcort Jazzcort force-pushed the Jazzcort/show-error-log-when-mention-big-item branch 2 times, most recently from 0e6b1e3 to ed1f842 Compare March 25, 2025 18:25
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.

Generally looks good. I left some comments that should be pretty quickly resolvable

props.command({ ...item, itemType: item.type });
if (item.type === "file" && item.query) {
console.log(item);
isItemTooBig(item.type, item.query).then(([fileExceeds, fileSize]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this callback could be broken out into a separate function to reduce the complexity of this logic

core/core.ts Outdated
const { config } = await this.configHandler.loadConfig();

if (!config) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to be very careful that we don't accidentally return true, so I think this should default to false. The consequences are pretty bad if we accidentally return true.

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 spent some time considering whether we should return true or false for these situations and I was still not sure when I submitted this PR. I agree that this might be too aggressive to return true by default.

);

if (contextResult.status === "error") {
return [true, -1];
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, we should default to false

});

if (result.status === "error") {
return [true, -1];
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

@Jazzcort
Copy link
Contributor Author

Jazzcort commented Apr 1, 2025

I'm still in the middle of something but I'll get the modification done by the end of today!

@Jazzcort Jazzcort force-pushed the Jazzcort/show-error-log-when-mention-big-item branch from ed1f842 to e8c9592 Compare April 1, 2025 20:03
@Jazzcort
Copy link
Contributor Author

Jazzcort commented Apr 1, 2025

Hey @sestinj, I’ve pushed the updated version. Let me know if any further changes are needed for this PR.

When the context items provided by user overflow the context length
and are truncated, it is very confusing for the user. This is a
first step that catches an common case at the least confusing
time - when the user is selecting a file. A more general check that
warns whenever the most recent message is truncated is something
that can be added later.
Granite-Code/granite-code#22
@Jazzcort Jazzcort force-pushed the Jazzcort/show-error-log-when-mention-big-item branch from e8c9592 to 1611bae Compare April 7, 2025 21:08
@sestinj sestinj merged commit 578ce98 into continuedev:main Apr 8, 2025
29 checks passed
@sestinj
Copy link
Contributor

sestinj commented Apr 8, 2025

It looks good to me, thanks!

@Jazzcort Jazzcort deleted the Jazzcort/show-error-log-when-mention-big-item branch April 8, 2025 21:25
@Jazzcort Jazzcort restored the Jazzcort/show-error-log-when-mention-big-item branch April 8, 2025 21:33
@Jazzcort Jazzcort deleted the Jazzcort/show-error-log-when-mention-big-item branch April 8, 2025 21:34
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.

2 participants