Skip to content

Commit 6c41687

Browse files
CCR feedback and CI fixes
1 parent 9ef88cc commit 6c41687

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

nodejs/src/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ export class CopilotSession {
649649
if (options?.minLength != null) field.minLength = options.minLength;
650650
if (options?.maxLength != null) field.maxLength = options.maxLength;
651651
if (options?.format) field.format = options.format;
652-
if (options?.default) field.default = options.default;
652+
if (options?.default != null) field.default = options.default;
653653

654654
const result = await this.rpc.ui.elicitation({
655655
message,

nodejs/test/client.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,14 @@ describe("CopilotClient", () => {
869869
expect(session.capabilities).toEqual({ ui: { elicitation: true } });
870870
});
871871

872-
it("defaults capabilities to empty when not in response", async () => {
872+
it("defaults capabilities when not injected", async () => {
873873
const client = new CopilotClient();
874874
await client.start();
875875
onTestFinished(() => client.forceStop());
876876

877877
const session = await client.createSession({ onPermissionRequest: approveAll });
878-
expect(session.capabilities).toEqual({});
878+
// CLI returns actual capabilities (elicitation false in headless mode)
879+
expect(session.capabilities.ui?.elicitation).toBe(false);
879880
});
880881

881882
it("elicitation throws when capability is missing", async () => {

nodejs/test/e2e/commands.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ describe("Commands", async () => {
2828
onPermissionRequest: approveAll,
2929
});
3030

31-
// Collect events after session creation
32-
const events: SessionEvent[] = [];
33-
session1.on((event) => events.push(event));
31+
type CommandsChangedEvent = Extract<SessionEvent, { type: "commands.changed" }>;
32+
33+
// Wait for the commands.changed event deterministically
34+
const commandsChangedPromise = new Promise<CommandsChangedEvent>((resolve) => {
35+
session1.on((event) => {
36+
if (event.type === "commands.changed") resolve(event);
37+
});
38+
});
3439

3540
// Client2 joins with commands
3641
const session2 = await client2.resumeSession(session1.sessionId, {
@@ -41,12 +46,9 @@ describe("Commands", async () => {
4146
disableResume: true,
4247
});
4348

44-
// Wait for events to propagate
45-
await new Promise((resolve) => setTimeout(resolve, 2000));
46-
47-
const commandsChanged = events.filter((e) => e.type === "commands.changed");
48-
expect(commandsChanged).toHaveLength(1);
49-
expect(commandsChanged[0].data.commands).toEqual(
49+
// Rely on default vitest timeout
50+
const commandsChanged = await commandsChangedPromise;
51+
expect(commandsChanged.data.commands).toEqual(
5052
expect.arrayContaining([
5153
expect.objectContaining({ name: "deploy", description: "Deploy the app" }),
5254
]),

0 commit comments

Comments
 (0)