ITADN

showMessage in Theia doesn't show calling extension (no source field) unlike VS Code

#17382OpenNO-MAP 创建于 2026-04-21
N
NO-MAPcommented
Description: When calling showMessage from an extension, VS Code displays the caller (the extension) in the message UI, but Theia does not. Screenshots: <img width="554" height="146" alt="Image" src="https://github.com/user-attachments/assets/a63e0b2f-ff91-4996-9ceb-755ee4c0946e" /> <img width="564" height="108" alt="Image" src="https://github.com/user-attachments/assets/efb54e44-ee22-4bcb-9b44-b402b4de7301" /> What I found - In VS Code ext host, showInformationMessage calls extHostMessageService.showMessage and the implementation fills a source field with extension info: - extHost.api.impl.ts: https://github.com/microsoft/vscode/blob/938f78a972c8aec490d2687bea319c01a5725223/src/vs/workbench/api/common/extHost.api.impl.ts#L880 ```typescript showInformationMessage(message: string, ...rest: Array<vscode.MessageOptions | string | vscode.MessageItem>) { return <Thenable<any>>extHostMessageService.showMessage(extension, Severity.Info, message, rest[0], <Array<string | vscode.MessageItem>>rest.slice(1)); }, ``` - extHostMessageService.ts: https://github.com/microsoft/vscode/blob/018a47f3df8dd2121e9bf96c5e24cbbabd8ed9da/src/vs/workbench/api/common/extHostMessageService.ts#L32 (Here vscode builds MainThreadMessageOptions with source: { identifier: extension.identifier, label: extension.displayName || extension.name } so the message shows the extension.) - In Theia, the analogous code in plugin message-registry does not populate a source field: https://github.com/eclipse-theia/theia/blob/631e361dbd0ab7ec2da64be1f24ec5769125b838/packages/plugin-ext/src/plugin/message-registry.ts#L35 ```typescript async showMessage(type: MainMessageType, message: string, optionsOrFirstItem?: MessageOptions | string | MessageItem, ...rest: (string | MessageItem)[]): Promise<string | MessageItem | undefined> { const options: MainMessageOptions = {}; ... const actionHandle = await this.proxy.$showMessage(type, message, options, actions); return actionHandle !== undefined ? items[actionHandle] : undefined; } ``` There is no options.source being set from the extension info. What I tried - I attempted to rebind MessageRegistryExt in the node container: ```typescript if (isBound(MessageRegistryExt)) { rebind(MessageRegistryExt).to(NewMessageRegistryExt).inSingletonScope(); } else { bind(MessageRegistryExt).to(NewMessageRegistryExt).inSingletonScope(); } ``` It had no effect. I discovered the plugin runs in a separate process with its own DI container, so the rebind needs to be done in plugin-host. - The plugin-host is loaded by the Theia backend entry: ```javascript entry: { 'main': require.resolve('./src-gen/backend/main'), 'ipc-bootstrap': require.resolve('@theia/core/lib/node/messaging/ipc-bootstrap'), 'plugin-host': require.resolve('@theia/plugin-ext/lib/hosted/node/plugin-host'), 'plugin-host-headless': require.resolve('@theia/plugin-ext-headless/lib/hosted/node/plugin-host-headless'), ... } ``` Problem / question - I could not find a way to extend or contribute bindings into the plugin-host container without changing Theia sources. - Is there a way to make Theia populate the message source (so extension name/identifier appears in showMessage) without modifying Theia core/source code? Any guidance on extending plugin-host bindings from an external plugin or a custom extension point would be appreciated. Thanks for any pointers or workarounds!
1 条评论