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

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
小众软件
小众软件
V
V2EX
月光博客
月光博客
腾讯CDC
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
D
Docker
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI

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
feat(agents): add current-session steer command · opencla...
steipete · 2026-05-04 · via Recent Commits to openclaw:main

@@ -0,0 +1,129 @@

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+

import type { OpenClawConfig } from "../../config/types.openclaw.js";

3+

import { buildCommandTestParams } from "./commands.test-harness.js";

4+5+

const steerRuntimeMocks = vi.hoisted(() => ({

6+

isEmbeddedPiRunActive: vi.fn(),

7+

queueEmbeddedPiMessage: vi.fn(),

8+

resolveActiveEmbeddedRunSessionId: vi.fn(),

9+

}));

10+11+

vi.mock("./commands-steer.runtime.js", () => steerRuntimeMocks);

12+13+

const { handleSteerCommand } = await import("./commands-steer.js");

14+15+

const baseCfg = {

16+

commands: { text: true },

17+

session: { mainKey: "main", scope: "per-sender" },

18+

} as OpenClawConfig;

19+20+

function buildParams(commandBody: string) {

21+

return buildCommandTestParams(commandBody, baseCfg);

22+

}

23+24+

describe("handleSteerCommand", () => {

25+

beforeEach(() => {

26+

steerRuntimeMocks.isEmbeddedPiRunActive.mockReset().mockReturnValue(false);

27+

steerRuntimeMocks.queueEmbeddedPiMessage.mockReset().mockReturnValue(true);

28+

steerRuntimeMocks.resolveActiveEmbeddedRunSessionId.mockReset().mockReturnValue(undefined);

29+

});

30+31+

it("queues steering for the active current text-command session", async () => {

32+

steerRuntimeMocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("session-active");

33+34+

const result = await handleSteerCommand(buildParams("/steer keep going"), true);

35+36+

expect(result).toEqual({

37+

shouldContinue: false,

38+

reply: { text: "steered current session." },

39+

});

40+

expect(steerRuntimeMocks.resolveActiveEmbeddedRunSessionId).toHaveBeenCalledWith(

41+

"agent:main:main",

42+

);

43+

expect(steerRuntimeMocks.queueEmbeddedPiMessage).toHaveBeenCalledWith(

44+

"session-active",

45+

"keep going",

46+

{

47+

steeringMode: "all",

48+

debounceMs: 0,

49+

},

50+

);

51+

});

52+53+

it("prefers the native command target session key over the slash-command session", async () => {

54+

steerRuntimeMocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("session-target");

55+56+

const params = buildParams("/steer check the target");

57+

params.ctx.CommandSource = "native";

58+

params.ctx.CommandTargetSessionKey = "agent:main:discord:direct:target";

59+

params.sessionKey = "agent:main:discord:slash:user";

60+61+

await handleSteerCommand(params, true);

62+63+

expect(steerRuntimeMocks.resolveActiveEmbeddedRunSessionId).toHaveBeenCalledWith(

64+

"agent:main:discord:direct:target",

65+

);

66+

expect(steerRuntimeMocks.queueEmbeddedPiMessage).toHaveBeenCalledWith(

67+

"session-target",

68+

"check the target",

69+

{

70+

steeringMode: "all",

71+

debounceMs: 0,

72+

},

73+

);

74+

});

75+76+

it("falls back to the stored session id when it is still active", async () => {

77+

steerRuntimeMocks.isEmbeddedPiRunActive.mockReturnValue(true);

78+79+

const params = buildParams("/tell continue from state");

80+

params.sessionEntry = { sessionId: "stored-session-id", updatedAt: Date.now() };

81+82+

await handleSteerCommand(params, true);

83+84+

expect(steerRuntimeMocks.resolveActiveEmbeddedRunSessionId).toHaveBeenCalledWith(

85+

"agent:main:main",

86+

);

87+

expect(steerRuntimeMocks.isEmbeddedPiRunActive).toHaveBeenCalledWith("stored-session-id");

88+

expect(steerRuntimeMocks.queueEmbeddedPiMessage).toHaveBeenCalledWith(

89+

"stored-session-id",

90+

"continue from state",

91+

{

92+

steeringMode: "all",

93+

debounceMs: 0,

94+

},

95+

);

96+

});

97+98+

it("returns usage for an empty steer command", async () => {

99+

const result = await handleSteerCommand(buildParams("/steer"), true);

100+101+

expect(result).toEqual({

102+

shouldContinue: false,

103+

reply: { text: "Usage: /steer <message>" },

104+

});

105+

expect(steerRuntimeMocks.queueEmbeddedPiMessage).not.toHaveBeenCalled();

106+

});

107+108+

it("does not start a new run when no current session run is active", async () => {

109+

const result = await handleSteerCommand(buildParams("/steer keep going"), true);

110+111+

expect(result).toEqual({

112+

shouldContinue: false,

113+

reply: { text: "⚠️ No active run to steer in this session." },

114+

});

115+

expect(steerRuntimeMocks.queueEmbeddedPiMessage).not.toHaveBeenCalled();

116+

});

117+118+

it("reports when the active run rejects steering injection", async () => {

119+

steerRuntimeMocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("session-active");

120+

steerRuntimeMocks.queueEmbeddedPiMessage.mockReturnValue(false);

121+122+

const result = await handleSteerCommand(buildParams("/steer keep going"), true);

123+124+

expect(result).toEqual({

125+

shouldContinue: false,

126+

reply: { text: "⚠️ Current run is active but not accepting steering right now." },

127+

});

128+

});

129+

});