Skip to content

Conversation

@hediet
Copy link
Member

@hediet hediet commented Nov 21, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 21, 2025 20:32
@hediet hediet enabled auto-merge (squash) November 21, 2025 20:32
@hediet hediet self-assigned this Nov 21, 2025
@vs-code-engineering
Copy link

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/workbench/contrib/chat/browser/chatStatus.ts

@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 21, 2025
Copilot finished reviewing on behalf of hediet November 21, 2025 20:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ChatStatusDashboard class into a separate file and introduces a new DomWidget base class to provide a standard pattern for reusable UI components with hot module replacement support.

Key Changes:

  • Extracted ChatStatusDashboard from chatStatus.ts into a new dedicated file chatStatusDashboard.ts
  • Introduced new DomWidget abstract class in src/vs/platform/ui/browser/domWidget.ts as a base for reusable UI components
  • Updated chatStatus.ts to use the new DomWidget pattern with instantiateInContents() instead of the lazy Lazy<> pattern
  • Modified Vite build configuration to automatically inject hot reload support for DomWidget classes

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/vs/workbench/contrib/chat/browser/chatStatusDashboard.ts New file containing the extracted ChatStatusDashboard class that now extends DomWidget and renders immediately in constructor
src/vs/workbench/contrib/chat/browser/chatStatus.ts Refactored to remove the inlined ChatStatusDashboard class, export utility functions, and use DomWidget.instantiateInContents() for tooltip creation
src/vs/platform/ui/browser/domWidget.ts New base class providing standard patterns for disposable UI widgets with static helpers for instantiation and hot reload support
build/vite/vite.config.ts Enhanced hot reload plugin to detect and inject hot replacement code for classes extending DomWidget


if (hasDomWidget) {
const matches = code.matchAll(/class\s+([a-zA-Z0-9_]+)\s+extends\s+DomWidget/g);
/// @ts-ignore
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The /// @ts-ignore comment should be replaced with // @ts-expect-error for better type checking. When using @ts-expect-error, TypeScript will error if the suppression becomes unnecessary, helping maintain code quality over time.

Suggested change
/// @ts-ignore
// @ts-expect-error

Copilot uses AI. Check for mistakes.
timerDisposables.add(disposableWindowInterval(
getWindow(container),
() => update(enabled),
1000
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The interval value should use a numeric separator for consistency with other parts of the codebase: 1_000 instead of 1000. This improves readability for millisecond values.

Suggested change
1000
1_000

Copilot uses AI. Check for mistakes.
}

if (hasDomWidget) {
const matches = code.matchAll(/class\s+([a-zA-Z0-9_]+)\s+extends\s+DomWidget/g);
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The regex pattern /class\s+([a-zA-Z0-9_]+)\s+extends\s+DomWidget/g may not correctly handle all cases. It won't match classes that have TypeScript generic parameters (e.g., class MyWidget<T> extends DomWidget) or those with multiple spaces/line breaks. Consider using a more robust pattern or AST-based parsing for reliability.

Suggested change
const matches = code.matchAll(/class\s+([a-zA-Z0-9_]+)\s+extends\s+DomWidget/g);
const matches = code.matchAll(/class\s+([a-zA-Z0-9_]+)\s*(<[^>]*>)?\s*extends\s*DomWidget/smg);

Copilot uses AI. Check for mistakes.
const elem = ChatStatusDashboard.instantiateInContents(this.instantiationService, store);

// todo@connor4312/@benibenj: workaround for #257923
store.add(disposableWindowInterval(mainWindow, () => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we please avoid a hack like this, why is it now needed when it was not before?

};
tooltip: {
element: (token: CancellationToken) => {
const store = new DisposableStore();
Copy link
Member

Choose a reason for hiding this comment

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

This block would probably read better if it was extracted into a method?

import { isHotReloadEnabled } from '../../../base/common/hotReload.js';
import { Disposable, DisposableStore, toDisposable } from '../../../base/common/lifecycle.js';
import { ISettableObservable, IObservable, autorun, constObservable, derived, observableValue } from '../../../base/common/observable.js';
import { IInstantiationService, GetLeadingNonServiceArgs } from '../../instantiation/common/instantiation.js';
Copy link
Member

Choose a reason for hiding this comment

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

I find platform/ui not very specific, lets try to find folder names in platform that are explanatory of what is going on inside. The original intent was to make it easy to understand what kind of service is provided.

import { defaultChat, canUseChat, isNewUser, isCompletionsEnabled } from './chatStatus.js';
import { IChatStatusItemService, ChatStatusEntry } from './chatStatusItemService.js';

interface ISettingsAccessor {
Copy link
Member

Choose a reason for hiding this comment

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

If you are splitting up chat status, then why not introduce a new folder status in contrib/chat to make this intent really clear?

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.

4 participants