惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
P
Proofpoint News Feed
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
博客园 - 聂微东
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
美团技术团队
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
U
Unit 42
博客园 - 叶小钗
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
MongoDB | Blog
MongoDB | Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
Add TUI context mode selector (#71760) · openclaw/opencla...
kevinlin-ope · 2026-04-26 · via Recent Commits to openclaw:main

@@ -3,9 +3,16 @@ import { createCommandHandlers } from "./tui-command-handlers.js";

3344

type LoadHistoryMock = ReturnType<typeof vi.fn> & (() => Promise<void>);

55

type RunAuthFlow = NonNullable<Parameters<typeof createCommandHandlers>[0]["runAuthFlow"]>;

6+

type SelectableOverlay = {

7+

onSelect?: (item: { value: string; label?: string; description?: string }) => void;

8+

};

69

type SetActivityStatusMock = ReturnType<typeof vi.fn> & ((text: string) => void);

710

type SetSessionMock = ReturnType<typeof vi.fn> & ((key: string) => Promise<void>);

81112+

async function flushAsyncSelect() {

13+

await new Promise<void>((resolve) => setImmediate(resolve));

14+

}

15+916

function createHarness(params?: {

1017

sendChat?: ReturnType<typeof vi.fn>;

1118

getGatewayStatus?: ReturnType<typeof vi.fn>;

@@ -37,6 +44,8 @@ function createHarness(params?: {

3744

const refreshSessionInfo = params?.refreshSessionInfo ?? vi.fn().mockResolvedValue(undefined);

3845

const applySessionInfoFromPatch = params?.applySessionInfoFromPatch ?? vi.fn();

3946

const setActivityStatus = params?.setActivityStatus ?? (vi.fn() as SetActivityStatusMock);

47+

const openOverlay = vi.fn();

48+

const closeOverlay = vi.fn();

4049

const requestExit = vi.fn();

4150

const runAuthFlow: RunAuthFlow | undefined =

4251

params?.runAuthFlow ??

@@ -59,8 +68,8 @@ function createHarness(params?: {

5968

opts: params?.opts ?? {},

6069

state: state as never,

6170

deliverDefault: false,

62-

openOverlay: vi.fn(),

63-

closeOverlay: vi.fn(),

71+

openOverlay,

72+

closeOverlay,

6473

refreshSessionInfo: refreshSessionInfo as never,

6574

loadHistory,

6675

setSession,

@@ -81,6 +90,8 @@ function createHarness(params?: {

8190

handleCommand,

8291

getGatewayStatus,

8392

sendChat,

93+

openOverlay,

94+

closeOverlay,

8495

patchSession,

8596

resetSession,

8697

setSession,

@@ -115,7 +126,7 @@ describe("tui command handlers", () => {

115126

setActivityStatus,

116127

});

117128118-

const pending = handleCommand("/context");

129+

const pending = handleCommand("/context detail");

119130

await Promise.resolve();

120131121132

expect(setActivityStatus).toHaveBeenCalledWith("sending");

@@ -131,19 +142,73 @@ describe("tui command handlers", () => {

131142

it("forwards unknown slash commands to the gateway", async () => {

132143

const { handleCommand, sendChat, addUser, addSystem, requestRender } = createHarness();

133144134-

await handleCommand("/context");

145+

await handleCommand("/unregistered-command");

135146136147

expect(addSystem).not.toHaveBeenCalled();

137-

expect(addUser).toHaveBeenCalledWith("/context");

148+

expect(addUser).toHaveBeenCalledWith("/unregistered-command");

138149

expect(sendChat).toHaveBeenCalledWith(

139150

expect.objectContaining({

140151

sessionKey: "agent:main:main",

141-

message: "/context",

152+

message: "/unregistered-command",

142153

}),

143154

);

144155

expect(requestRender).toHaveBeenCalled();

145156

});

146157158+

it("opens a context mode selector for /context without sending immediately", async () => {

159+

const { handleCommand, sendChat, openOverlay } = createHarness();

160+161+

await handleCommand("/context");

162+163+

expect(sendChat).not.toHaveBeenCalled();

164+

expect(openOverlay).toHaveBeenCalledTimes(1);

165+

});

166+167+

it("sends the selected context mode through the gateway command path", async () => {

168+

const { handleCommand, sendChat, openOverlay, closeOverlay } = createHarness();

169+170+

await handleCommand("/context");

171+

const selector = openOverlay.mock.calls[0]?.[0] as SelectableOverlay | undefined;

172+

selector?.onSelect?.({ value: "detail", label: "detail" });

173+

await flushAsyncSelect();

174+175+

expect(sendChat).toHaveBeenCalledWith(

176+

expect.objectContaining({

177+

sessionKey: "agent:main:main",

178+

message: "/context detail",

179+

}),

180+

);

181+

expect(closeOverlay).toHaveBeenCalledTimes(1);

182+

});

183+184+

it("forwards /context list directly", async () => {

185+

const { handleCommand, sendChat, openOverlay } = createHarness();

186+187+

await handleCommand("/context list");

188+189+

expect(openOverlay).not.toHaveBeenCalled();

190+

expect(sendChat).toHaveBeenCalledWith(

191+

expect.objectContaining({

192+

sessionKey: "agent:main:main",

193+

message: "/context list",

194+

}),

195+

);

196+

});

197+198+

it("forwards /context help directly", async () => {

199+

const { handleCommand, sendChat, openOverlay } = createHarness();

200+201+

await handleCommand("/context help");

202+203+

expect(openOverlay).not.toHaveBeenCalled();

204+

expect(sendChat).toHaveBeenCalledWith(

205+

expect.objectContaining({

206+

sessionKey: "agent:main:main",

207+

message: "/context help",

208+

}),

209+

);

210+

});

211+147212

it("forwards /status to the shared gateway command path", async () => {

148213

const { handleCommand, sendChat, addUser, addSystem } = createHarness();

149214

@@ -202,7 +267,7 @@ describe("tui command handlers", () => {

202267

it("defers local run binding until gateway events provide a real run id", async () => {

203268

const { handleCommand, noteLocalRunId, state } = createHarness();

204269205-

await handleCommand("/context");

270+

await handleCommand("/context detail");

206271207272

expect(noteLocalRunId).not.toHaveBeenCalled();

208273

expect(state.activeChatRunId).toBeNull();

@@ -261,7 +326,7 @@ describe("tui command handlers", () => {

261326

setActivityStatus,

262327

});

263328264-

await handleCommand("/context");

329+

await handleCommand("/context detail");

265330266331

expect(addSystem).toHaveBeenCalledWith("send failed: Error: gateway down");

267332

expect(setActivityStatus).toHaveBeenLastCalledWith("error");

@@ -288,7 +353,7 @@ describe("tui command handlers", () => {

288353

isConnected: false,

289354

});

290355291-

await handleCommand("/context");

356+

await handleCommand("/context detail");

292357293358

expect(sendChat).not.toHaveBeenCalled();

294359

expect(addUser).not.toHaveBeenCalled();