Fix terminal slot review issues
This commit is contained in:
@@ -2613,7 +2613,7 @@ export class DaemonClient {
|
|||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
options: { skipQueue: true },
|
options: { skipQueue: true },
|
||||||
});
|
});
|
||||||
if (!payload.error) {
|
if (payload.error === null) {
|
||||||
this.setTerminalSlot(terminalId, payload.slot);
|
this.setTerminalSlot(terminalId, payload.slot);
|
||||||
}
|
}
|
||||||
return payload;
|
return payload;
|
||||||
|
|||||||
@@ -404,6 +404,11 @@ async function subscribeRawTerminal(
|
|||||||
if (message.message.type !== "subscribe_terminal_response") {
|
if (message.message.type !== "subscribe_terminal_response") {
|
||||||
throw new Error("Expected subscribe_terminal_response");
|
throw new Error("Expected subscribe_terminal_response");
|
||||||
}
|
}
|
||||||
|
if (message.message.payload.error !== null) {
|
||||||
|
throw new Error(
|
||||||
|
`Expected successful subscribe_terminal_response: ${message.message.payload.error}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
expect(message.message.payload).not.toHaveProperty("state");
|
expect(message.message.payload).not.toHaveProperty("state");
|
||||||
return message.message.payload.slot;
|
return message.message.payload.slot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7661,7 +7661,6 @@ export class Session {
|
|||||||
type: "subscribe_terminal_response",
|
type: "subscribe_terminal_response",
|
||||||
payload: {
|
payload: {
|
||||||
terminalId: msg.terminalId,
|
terminalId: msg.terminalId,
|
||||||
slot: 0,
|
|
||||||
error: "Terminal manager not available",
|
error: "Terminal manager not available",
|
||||||
requestId: msg.requestId,
|
requestId: msg.requestId,
|
||||||
},
|
},
|
||||||
@@ -7675,7 +7674,6 @@ export class Session {
|
|||||||
type: "subscribe_terminal_response",
|
type: "subscribe_terminal_response",
|
||||||
payload: {
|
payload: {
|
||||||
terminalId: msg.terminalId,
|
terminalId: msg.terminalId,
|
||||||
slot: 0,
|
|
||||||
error: "Terminal not found",
|
error: "Terminal not found",
|
||||||
requestId: msg.requestId,
|
requestId: msg.requestId,
|
||||||
},
|
},
|
||||||
@@ -7686,11 +7684,17 @@ export class Session {
|
|||||||
|
|
||||||
const slot = this.bindActiveTerminalStream(session);
|
const slot = this.bindActiveTerminalStream(session);
|
||||||
if (slot === null) {
|
if (slot === null) {
|
||||||
|
this.sessionLogger.warn(
|
||||||
|
{
|
||||||
|
terminalId: msg.terminalId,
|
||||||
|
activeTerminalStreamCount: this.activeTerminalStreams.size,
|
||||||
|
},
|
||||||
|
"Terminal stream slot exhaustion",
|
||||||
|
);
|
||||||
this.emit({
|
this.emit({
|
||||||
type: "subscribe_terminal_response",
|
type: "subscribe_terminal_response",
|
||||||
payload: {
|
payload: {
|
||||||
terminalId: msg.terminalId,
|
terminalId: msg.terminalId,
|
||||||
slot: 0,
|
|
||||||
error: "No terminal stream slots available",
|
error: "No terminal stream slots available",
|
||||||
requestId: msg.requestId,
|
requestId: msg.requestId,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2161,12 +2161,19 @@ export const CreateTerminalResponseSchema = z.object({
|
|||||||
|
|
||||||
export const SubscribeTerminalResponseSchema = z.object({
|
export const SubscribeTerminalResponseSchema = z.object({
|
||||||
type: z.literal("subscribe_terminal_response"),
|
type: z.literal("subscribe_terminal_response"),
|
||||||
payload: z.object({
|
payload: z.union([
|
||||||
terminalId: z.string(),
|
z.object({
|
||||||
slot: z.number().int().min(0).max(255),
|
terminalId: z.string(),
|
||||||
error: z.string().nullable(),
|
slot: z.number().int().min(0).max(255),
|
||||||
requestId: z.string(),
|
error: z.null(),
|
||||||
}),
|
requestId: z.string(),
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
terminalId: z.string(),
|
||||||
|
error: z.string(),
|
||||||
|
requestId: z.string(),
|
||||||
|
}),
|
||||||
|
]),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const KillTerminalResponseSchema = z.object({
|
export const KillTerminalResponseSchema = z.object({
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function decodeTerminalStreamFrame(bytes: Uint8Array): TerminalStreamFram
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
opcode,
|
opcode,
|
||||||
slot: bytes[1] ?? 0,
|
slot: bytes[1],
|
||||||
payload: bytes.subarray(2),
|
payload: bytes.subarray(2),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user