Merge eafde73b93bb1c3a6b0b5cb5f260f8cd60ff6877 into 43513cd1df63af0704dfb351ee7864607f955dcc

This commit is contained in:
LIU Yaohua 2026-03-21 13:36:20 +08:00 committed by GitHub
commit 0a7916268d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 16 deletions

View File

@ -304,30 +304,28 @@ export function registerNodesStatusCommands(nodes: Command) {
await runNodesCommand("list", async () => {
const connectedOnly = Boolean(opts.connected);
const sinceMs = parseSinceMs(opts.lastConnected, "Invalid --last-connected");
const result = await callGatewayCli("node.pair.list", opts, {});
const { pending, paired } = parsePairingList(result);
const nodeListResult = await callGatewayCli("node.list", opts, {});
const pairingListResult = await callGatewayCli("node.pair.list", opts, {});
const { pending, paired } = parsePairingList(pairingListResult);
const { heading, muted, warn } = getNodesTheme();
const tableWidth = getTerminalTableWidth();
const now = Date.now();
const hasFilters = connectedOnly || sinceMs !== undefined;
const pendingRows = hasFilters ? [] : pending;
const connectedById = hasFilters
? new Map(
parseNodeList(await callGatewayCli("node.list", opts, {})).map((node) => [
node.nodeId,
node,
]),
)
: null;
const liveNodesById = new Map(
parseNodeList(nodeListResult).map((node) => [node.nodeId, node]),
);
const pendingRows = connectedOnly || sinceMs !== undefined ? [] : pending;
const filteredPaired = paired.filter((node) => {
if (connectedOnly) {
const live = connectedById?.get(node.nodeId);
const live = liveNodesById.get(node.nodeId);
if (!live?.connected) {
return false;
}
}
if (sinceMs !== undefined) {
const live = connectedById?.get(node.nodeId);
const live = liveNodesById.get(node.nodeId);
const lastConnectedAtMs =
typeof node.lastConnectedAtMs === "number"
? node.lastConnectedAtMs
@ -343,8 +341,14 @@ export function registerNodesStatusCommands(nodes: Command) {
}
return true;
});
const hasFilters = connectedOnly || sinceMs !== undefined;
const livePairedNodes = Array.from(liveNodesById.values()).filter((n) => n.paired);
const totalPairedCount = paired.length > 0 ? paired.length : livePairedNodes.length;
const filteredLabel =
hasFilters && filteredPaired.length !== paired.length ? ` (of ${paired.length})` : "";
hasFilters && filteredPaired.length !== totalPairedCount
? ` (of ${totalPairedCount})`
: "";
defaultRuntime.log(
`Pending: ${pendingRows.length} · Paired: ${filteredPaired.length}${filteredLabel}`,
);
@ -370,7 +374,7 @@ export function registerNodesStatusCommands(nodes: Command) {
if (filteredPaired.length > 0) {
const pairedRows = filteredPaired.map((n) => {
const live = connectedById?.get(n.nodeId);
const live = liveNodesById.get(n.nodeId);
const lastConnectedAtMs =
typeof n.lastConnectedAtMs === "number"
? n.lastConnectedAtMs

View File

@ -273,6 +273,21 @@ describe("gateway sessions patch", () => {
expect(entry.modelOverride).toBe("claude-sonnet-4-6");
});
test.each([
{ name: "list", model: "list" },
{ name: "LIST (uppercase)", model: "LIST" },
{ name: "List (mixed case)", model: "List" },
{ name: "status", model: "status" },
{ name: "STATUS (uppercase)", model: "STATUS" },
{ name: "Status (mixed case)", model: "Status" },
])("rejects model command alias '$name' as invalid model", async ({ model }) => {
const result = await runPatch({
patch: { key: MAIN_SESSION_KEY, model },
});
expectPatchError(result, `invalid model`);
expectPatchError(result, `command alias`);
});
test("sets spawnDepth for subagent sessions", async () => {
const entry = expectPatchOk(
await runPatch({

View File

@ -389,6 +389,11 @@ export async function applySessionsPatchToStore(params: {
if (!trimmed) {
return invalid("invalid model: empty");
}
if (trimmed.toLowerCase() === "list" || trimmed.toLowerCase() === "status") {
return invalid(
`invalid model: "${trimmed}" is a command alias, not a model. Use /models list or /model status in chat instead.`,
);
}
if (!params.loadGatewayModelCatalog) {
return {
ok: false,