-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Focus the extension when receiving bridge commands #7633
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,13 @@ describe("ExtensionChannel", () => { | |
| let extensionChannel: ExtensionChannel | ||
| const instanceId = "test-instance-123" | ||
| const userId = "test-user-456" | ||
| const extensionMetadata = { | ||
| name: "roo-code", | ||
| publisher: "Roocode", | ||
| version: "1.0.0", | ||
| outputChannel: "Roo Code", | ||
| sha: undefined, | ||
| } | ||
|
|
||
| // Track registered event listeners | ||
| const eventListeners = new Map<keyof TaskProviderEvents, Set<(...args: unknown[]) => unknown>>() | ||
|
|
@@ -80,7 +87,12 @@ describe("ExtensionChannel", () => { | |
| } as unknown as TaskProviderLike | ||
|
|
||
| // Create extension channel instance | ||
| extensionChannel = new ExtensionChannel(instanceId, userId, mockProvider) | ||
| extensionChannel = new ExtensionChannel({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job updating the tests to accommodate the new constructor signatures! However, would it be valuable to add specific tests that verify the focus command is called before command handling? This would help ensure the new behavior is properly tested. |
||
| instanceId, | ||
| extensionMetadata, | ||
| userId, | ||
| provider: mockProvider, | ||
| }) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
|
|
@@ -155,7 +167,12 @@ describe("ExtensionChannel", () => { | |
|
|
||
| it("should not have duplicate listeners after multiple channel creations", () => { | ||
| // Create a second channel with the same provider | ||
| const secondChannel = new ExtensionChannel("instance-2", userId, mockProvider) | ||
| const secondChannel = new ExtensionChannel({ | ||
| instanceId: "instance-2", | ||
| extensionMetadata, | ||
| userId, | ||
| provider: mockProvider, | ||
| }) | ||
|
|
||
| // Each event should have exactly 2 listeners (one from each channel) | ||
| eventListeners.forEach((listeners) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@roo-code/types", | ||
| "version": "1.69.0", | ||
| "version": "1.70.0", | ||
|
||
| "description": "TypeScript type definitions for Roo Code.", | ||
| "publishConfig": { | ||
| "access": "public", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export interface ExtensionMetadata { | ||
| publisher: string | ||
| name: string | ||
| version: string | ||
| outputChannel: string | ||
| sha: string | undefined | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of the template method pattern! The separation between common functionality (focus) and subclass-specific logic is clean.
However, I have two concerns about the focus command execution:
Potential Race Condition: The focus command is executed asynchronously, but we don't wait for confirmation that the focus actually succeeded before proceeding. Could this lead to commands being processed before the UI is ready?
Error Handling: Consider wrapping this in a try-catch block. If the focus command fails (e.g., extension not fully loaded), should we still proceed with command handling?