Skip to content

Commit b268541

Browse files
authored
dev: improve clarity of sample contributions (#16937)
Clearly mark contributions of api-samples in UI and logs. This is useful for Theia developers to easily separate between framework and api-samples behavior when testing. - Use named logger 'api-samples' for consistent log identification - Prefix console logs with [api-samples] in electron-main context - Use unified 'API Samples' category for all commands - Append 'Sample' suffix to chat agent IDs and names - Prefix MCP tool and resource names with 'sample-' - Update notification messages to include 'Sample Updater' prefix
1 parent 7a3a06d commit b268541

22 files changed

+133
-94
lines changed

examples/api-samples/src/browser/chat/ask-and-continue-chat-agent-contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ Do not ask further questions once the text contains 5 or more "Question/Answer"
109109
*/
110110
@injectable()
111111
export class AskAndContinueChatAgent extends AbstractStreamParsingChatAgent {
112-
id = 'AskAndContinue';
113-
name = 'AskAndContinue';
112+
id = 'AskAndContinueSample';
113+
name = 'AskAndContinueSample';
114114
override description = 'This chat will ask questions related to the input and continues after that.';
115115
protected defaultLanguageModelPurpose = 'chat';
116116
override languageModelRequirements = [

examples/api-samples/src/browser/chat/change-set-chat-agent-contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function bindChangeSetChatAgentContribution(bind: interfaces.Bind): void
4040
*/
4141
@injectable()
4242
export class ChangeSetChatAgent extends AbstractStreamParsingChatAgent {
43-
readonly id = 'ChangeSet';
44-
readonly name = 'ChangeSet';
43+
readonly id = 'ChangeSetSample';
44+
readonly name = 'ChangeSetSample';
4545
readonly defaultLanguageModelPurpose = 'chat';
4646
override readonly description = 'This chat will create and modify a change set.';
4747
override languageModelRequirements: LanguageModelRequirement[] = [];

examples/api-samples/src/browser/chat/chat-node-toolbar-action-contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function bindChatNodeToolbarActionContribution(bind: interfaces.Bind): vo
3131
return [{
3232
commandId: 'sample-command',
3333
icon: 'codicon codicon-feedback',
34-
tooltip: 'Example command'
34+
tooltip: 'API Samples: Example command'
3535
}];
3636
} else {
3737
return [];

examples/api-samples/src/browser/chat/custom-response-content-agent-contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class CustomNonSerializableContentRenderer implements ChatResponsePartRen
240240

241241
@injectable()
242242
export class CustomResponseContentRendererAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
243-
id = 'CustomContent';
243+
id = 'CustomContentSample';
244244
name = this.id;
245245
override description = 'Demonstrates custom serializable and non-serializable chat response content';
246246
languageModelRequirements = [];

examples/api-samples/src/browser/chat/mode-chat-agent-contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export function bindModeChatAgentContribution(bind: interfaces.Bind): void {
3636
*/
3737
@injectable()
3838
export class ModeChatAgent extends AbstractStreamParsingChatAgent {
39-
readonly id = 'ModeTest';
40-
readonly name = 'ModeTest';
39+
readonly id = 'ModeTestSample';
40+
readonly name = 'ModeTestSample';
4141
readonly defaultLanguageModelPurpose = 'chat';
4242
override readonly description = 'A test agent that demonstrates different response modes (concise vs detailed).';
4343
override languageModelRequirements: LanguageModelRequirement[] = [];

examples/api-samples/src/browser/chat/original-state-test-agent-contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function bindOriginalStateTestAgentContribution(bind: interfaces.Bind): v
4040
*/
4141
@injectable()
4242
export class OriginalStateTestAgent extends AbstractStreamParsingChatAgent {
43-
readonly id = 'OriginalStateTest';
44-
readonly name = 'OriginalStateTest';
43+
readonly id = 'OriginalStateTestSample';
44+
readonly name = 'OriginalStateTestSample';
4545
readonly defaultLanguageModelPurpose = 'chat';
4646
override readonly description = 'This chat will test originalState functionality with sequential changes.';
4747
override languageModelRequirements: LanguageModelRequirement[] = [];

examples/api-samples/src/browser/contribution-filter/sample-filtered-command-contribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ import { injectable, interfaces } from '@theia/core/shared/inversify';
1919

2020
export namespace SampleFilteredCommand {
2121

22-
const EXAMPLE_CATEGORY = 'Examples';
22+
const API_SAMPLES_CATEGORY = 'API Samples';
2323

2424
export const FILTERED: Command = {
2525
id: 'example_command.filtered',
26-
category: EXAMPLE_CATEGORY,
26+
category: API_SAMPLES_CATEGORY,
2727
label: 'This command should be filtered out'
2828
};
2929

3030
export const FILTERED2: Command = {
3131
id: 'example_command.filtered2',
32-
category: EXAMPLE_CATEGORY,
32+
category: API_SAMPLES_CATEGORY,
3333
label: 'This command should be filtered out (2)'
3434
};
3535
}

examples/api-samples/src/browser/file-system/sample-file-system-capabilities.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class SampleFileSystemCapabilities implements CommandContribution {
2929
registerCommands(commands: CommandRegistry): void {
3030
commands.registerCommand({
3131
id: 'toggleFileSystemReadonly',
32-
label: 'Toggle File System Readonly'
32+
label: 'Toggle File System Readonly',
33+
category: 'API Samples'
3334
}, {
3435
execute: () => {
3536
const readonly = (this.remoteFileSystemProvider.capabilities & FileSystemProviderCapabilities.Readonly) !== 0;
@@ -43,7 +44,8 @@ export class SampleFileSystemCapabilities implements CommandContribution {
4344

4445
commands.registerCommand({
4546
id: 'addFileSystemReadonlyMessage',
46-
label: 'Add a File System ReadonlyMessage for readonly'
47+
label: 'Add File System ReadonlyMessage',
48+
category: 'API Samples'
4749
}, {
4850
execute: () => {
4951
const readonlyMessage = new MarkdownStringImpl(`Added new **Markdown** string '+${Date.now()}`);
@@ -53,7 +55,8 @@ export class SampleFileSystemCapabilities implements CommandContribution {
5355

5456
commands.registerCommand({
5557
id: 'removeFileSystemReadonlyMessage',
56-
label: 'Remove File System ReadonlyMessage for readonly'
58+
label: 'Remove File System ReadonlyMessage',
59+
category: 'API Samples'
5760
}, {
5861
execute: () => {
5962
this.remoteFileSystemProvider['setReadOnlyMessage'](undefined);

examples/api-samples/src/browser/file-watching/sample-file-watching-contribution.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
1515
// *****************************************************************************
1616

17-
import { postConstruct, injectable, inject, interfaces } from '@theia/core/shared/inversify';
17+
import { postConstruct, injectable, inject, interfaces, named } from '@theia/core/shared/inversify';
1818
import {
1919
FrontendApplicationContribution, LabelProvider,
2020
} from '@theia/core/lib/browser';
21+
import { ILogger } from '@theia/core/lib/common/logger';
2122
import { FileService } from '@theia/filesystem/lib/browser/file-service';
2223
import { WorkspaceService } from '@theia/workspace/lib/browser';
2324
import { createPreferenceProxy, PreferenceService, PreferenceProxy, PreferenceContribution } from '@theia/core';
@@ -55,6 +56,9 @@ class SampleFileWatchingContribution implements FrontendApplicationContribution
5556
@inject(FileWatchingPreferences)
5657
protected readonly fileWatchingPreferences: FileWatchingPreferences;
5758

59+
@inject(ILogger) @named('api-samples')
60+
protected readonly logger: ILogger;
61+
5862
@postConstruct()
5963
protected init(): void {
6064
this.verbose = this.fileWatchingPreferences['sample.file-watching.verbose'];
@@ -75,7 +79,7 @@ class SampleFileWatchingContribution implements FrontendApplicationContribution
7579
const workspace = roots.length > 0
7680
? roots.map(root => this.labelProvider.getLongName(root.resource)).join('+')
7781
: '<no workspace>';
78-
console.log(`Sample File Watching: ${event.changes.length} file(s) changed! ${workspace}`);
82+
this.logger.info(`Sample File Watching: ${event.changes.length} file(s) changed! ${workspace}`);
7983
}
8084
});
8185
}

examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { FrontendApplicationContribution, LabelProviderContribution } from '@the
2020
import { SampleDynamicLabelProviderContribution } from './sample-dynamic-label-provider-contribution';
2121

2222
export namespace ExampleLabelProviderCommands {
23-
const EXAMPLE_CATEGORY = 'Examples';
23+
const API_SAMPLES_CATEGORY = 'API Samples';
2424
export const TOGGLE_SAMPLE: Command = {
2525
id: 'example_label_provider.toggle',
26-
category: EXAMPLE_CATEGORY,
26+
category: API_SAMPLES_CATEGORY,
2727
label: 'Toggle Dynamically-Changing Labels'
2828
};
2929
}

0 commit comments

Comments
 (0)