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

Error: There are no document for untitled:/Untitled-1aichatviewlanguage #14842

Closed
Tracked by #14923
kittaakos opened this issue Feb 5, 2025 · 8 comments · Fixed by #14957
Closed
Tracked by #14923

Error: There are no document for untitled:/Untitled-1aichatviewlanguage #14842

kittaakos opened this issue Feb 5, 2025 · 8 comments · Fixed by #14957
Assignees

Comments

@kittaakos
Copy link
Contributor

kittaakos commented Feb 5, 2025

Bug Description:

When I start Theia from the sources, I see this error twice in the console:

root ERROR Error: There are no document for untitled:/Untitled-1aichatviewlanguage
    at CodeActionAdapter.provideCodeAction (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_shared_reflect-metadata_index_js-packages_plugin-ext_lib_hosted_node_plugin-hos-48197a.js:8188:35)
    at /Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_shared_reflect-metadata_index_js-packages_plugin-ext_lib_hosted_node_plugin-hos-48197a.js:7705:93
    at LanguagesExtImpl.withAdapter (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_shared_reflect-metadata_index_js-packages_plugin-ext_lib_hosted_node_plugin-hos-48197a.js:7448:20)
    at LanguagesExtImpl.$provideCodeActions (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_shared_reflect-metadata_index_js-packages_plugin-ext_lib_hosted_node_plugin-hos-48197a.js:7705:21)
    at RPCProtocolImpl.handleRequest (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_plugin-ext_lib_common_plugin-api-rpc_js.js:2081:31)
    at RpcProtocol.requestHandler (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_plugin-ext_lib_common_plugin-api-rpc_js.js:2063:96)
    at RpcProtocol.handleRequest (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3625:39)
    at RpcProtocol.handleMessage (/Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3512:26)
    at /Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3498:66
    at /Users/kittaakos/dev/git/theia/examples/browser/lib/backend/packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:1414:69

I do not see this causing any malfunction, but it does not make the development very pleasant (#12693). When I am working on something, I have to scroll through these unrelated lines in the terminal and browser logs every time.

Steps to Reproduce:

  1. Start the browser example from the sources
  2. Open Theia as your workspace
  3. See the errors

Additional Information

  • Operating System:
  • Theia Version: 451464e

Merged in from #14927 (comment):

Bug Description:

Steps to Reproduce:

  1. Do anything in the chat interface.
  2. Observe lots of logs about the absence of a document, generated by various plugin classes, e.g. this one

We use the createInline method to get our editor:

theia/packages/ai-chat-ui/src/browser/chat-input-widget.tsx

Line 174 in c681f89

const editor = await props.editorProvider.createInline(resource.uri, editorContainerRef.current!, {
That method creates the document model using new:

theia/packages/monaco/src/browser/monaco-editor-provider.ts

Lines 376 to 380 in c681f89

const document = new MonacoEditorModel({
uri,
readContents: async () => '',
dispose: () => { }
}, this.m2p, this.p2m);
The plugin backend, where the error we're seeing is thrown, gets its knowledge of documents from EditorAndDocumentsStateComputer, which learns about models from the onModelAdded event:

https://github.com/eclipse-theia/theia/blob/master/packages/plugin-ext/src/main/browser/editors-and-documents-main.ts#L248

which requires that you go through the text model service:

theia/packages/monaco/src/browser/monaco-text-model-service.ts

Lines 97 to 99 in c681f89

get onDidCreate(): Event {
return this._models.onDidCreate;
}
Really, we probably don't mind if the plugin backend doesn't know about this particular editor: we likely won't set a known language, so plugins couldn't do much of use with it anyway. But we should also shut off the editor's mechanisms that request anything from the backend, if we intend not to let the backend know.

Additional Information

  • Operating System:
  • Theia Version:
@tsmaeder
Copy link
Contributor

tsmaeder commented Feb 6, 2025

@planger maybe you can speak to this?

@sdirix
Copy link
Member

sdirix commented Feb 6, 2025

I did not yet look into the issue, however I noticed that it only occurs when there are active VS code extensions, i.e. running Theia without download:plugins will not produce these errors.

@planger
Copy link
Contributor

planger commented Feb 6, 2025

Thanks for tracking this issue! I saw this too. I found that Colin investigated a similar issue some time ago and it seems to be related to certain services that are still active and invoke features that should served by VS Code extensions, but they can't deal with the temporary document we create, so they log the error.

It seems the only way to get rid of this logged error is to find out which enabled Monaco features are causing this and turn those off.

@planger
Copy link
Contributor

planger commented Feb 6, 2025

I briefly tried a few editor options (below) and registering an empty code action provider, but this didn't help.

lightbulb: { enabled: ShowLightbulbIconMode.Off },
quickSuggestions: false,
codeActionsOnSaveTimeout: 0,

@JonasHelming
Copy link
Contributor

Scan #14927 for additional findings

@tsmaeder
Copy link
Contributor

We probably should manage models in two distinct model managers: one that tracks the models to be synced to the background and one that is strictly local: for example the changeset text models could be shared by different editors (and should thus be reference-counted) but should not be sent to the back end.

@msujew
Copy link
Member

msujew commented Feb 17, 2025

I'll take a look at this, since I'm already working on something that is heavily related to this wrt notebook cell editors. I'll probably take the approach that @tsmaeder outlined.

@msujew msujew self-assigned this Feb 17, 2025
@msujew
Copy link
Member

msujew commented Feb 17, 2025

I've made some progress on this: I've fixed the notebook issue that I originally planned to fix but made little progress on this issue. Unfortunately, the errors are presented because the models are not synced to the backend. It currently works like this:

  1. The monaco model is registered only in the frontend.
  2. The user presses a button and therefore starts the whole code action provider routine
  3. Our own code then asks the plugin host to retrieve all code actions for the document
  4. The plugin host goes "what document?"
  5. We present this error to the user.

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 a pull request may close this issue.

6 participants