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

When you create a output channel without showing it be default , data are not visible in it if you open the output table after. #15081

Open
STDeslandes opened this issue Feb 27, 2025 · 1 comment · May be fixed by #15101

Comments

@STDeslandes
Copy link

Bug Description:

My use case is the following one:
I want to logs information in a dedicated channel of the output console, but by default I don't want to show the output console. Then I add logs inside my channel.
But when I want to see the output console, the channel is available and seems selected , but I need to select the channel again in the pick list to see the logs.

Steps to Reproduce:

  1. Create an outputchannel but don't use the channel.show().
  2. Add logs in this channel.
  3. Open the output console, the channel seems selected but the logs are not visible.

What I can see is that the output widget is not refreshed for the following events :
onSelectedChannelChanged
onChannelAdded

But only on
onChannelWasHidden
onChannelWasShown

I corrected the code of OutputChannelManager and OutputWidget to make it work. But I'm not so sure about all the side effects :

getChannel(name: string): OutputChannel {
        const existing = this.channels.get(name);
        if (existing) {
            return existing;
        }

        // We have to register the resource first, because `textModelService#createModelReference` will require it
        // right after creating the monaco.editor.ITextModel.
        // All `append` and `appendLine` will be deferred until the underlying text-model instantiation.
        let resource = this.resources.get(name);
        if (!resource) {
            const uri = OutputUri.create(name);
            const editorModelRef = new Deferred<IReference<MonacoEditorModel>>();
            resource = this.createResource({ uri, editorModelRef });
            this.resources.set(name, resource);
            this.textModelService.createModelReference(uri).then(ref => editorModelRef.resolve(ref));
        }

        const channel = this.createChannel(resource);
        this.channels.set(name, channel);
        this.toDisposeOnChannelDeletion.set(name, this.registerListeners(channel));
       
        if (!this.selectedChannel) {
            this.selectedChannel = channel;
        }
        this.channelAddedEmitter.fire(channel);
        return channel;
    }

Here I moved the this.channelAddedEmitter.fire(channel) after the this.selectedChannel = channel; to be sure that the widget has the right channel to manage.
And for the init of OutputWidget , I added the listener of channel added :

@postConstruct()
    protected init(): void {
        this.toDispose.pushAll([
            this.outputChannelManager.onChannelAdded(() => this.refreshEditorWidget()),
            this.outputChannelManager.onChannelWasHidden(() => this.refreshEditorWidget()),
            this.outputChannelManager.onChannelWasShown(({ preserveFocus }) => this.refreshEditorWidget({ preserveFocus: !!preserveFocus })),
            this.toDisposeOnSelectedChannelChanged,
            this.onStateChangedEmitter,
            this.onStateChanged(() => this.update())
        ]);
        this.refreshEditorWidget();
    }

What is your view on it ?
I can provide the PR if needed.

Additional Information

  • Operating System: Ubuntu & Windows
  • Theia Version: 1.55.1
@JonasHelming
Copy link
Contributor

@rschnekenbu

STDeslandes added a commit to STDeslandes/theia that referenced this issue Mar 3, 2025
Make sure the output widget is refreshed even if the show function is used if there is only one channel.

Contributed by STMicroelectronics
STDeslandes added a commit to STDeslandes/theia that referenced this issue Mar 3, 2025
Make sure the output widget is refreshed even if the channel.show() function is not used if there is only one channel.

Contributed by STMicroelectronics
@msujew msujew linked a pull request Mar 3, 2025 that will close this issue
2 tasks
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.

2 participants