mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix: treat Skill Workshop slash drafts as revisions
This commit is contained in:
@@ -2240,6 +2240,54 @@ describe("handleSendChat", () => {
|
||||
expect(userMessage.content).toEqual([{ type: "text", text: "Make the support files 5" }]);
|
||||
});
|
||||
|
||||
it("treats slash-like Skill Workshop revision drafts as revision instructions", async () => {
|
||||
const sent = createDeferred<unknown>();
|
||||
const request = vi.fn((method: string) => {
|
||||
if (method === "skills.proposals.requestRevision") {
|
||||
return sent.promise;
|
||||
}
|
||||
throw new Error(`Unexpected request: ${method}`);
|
||||
});
|
||||
const host = makeHost({
|
||||
client: { request } as unknown as ChatHost["client"],
|
||||
});
|
||||
|
||||
const send = handleSendChat(host, "/reset examples", {
|
||||
restoreDraft: true,
|
||||
skillWorkshopRevision: {
|
||||
proposalId: "support-file-sampler-20260531-68207b7b7f",
|
||||
},
|
||||
});
|
||||
await Promise.resolve();
|
||||
|
||||
const payload = findRequestPayload(
|
||||
request as unknown as MockCallSource,
|
||||
"skills.proposals.requestRevision",
|
||||
"revision slash payload",
|
||||
);
|
||||
expect(payload).toMatchObject({
|
||||
proposalId: "support-file-sampler-20260531-68207b7b7f",
|
||||
instructions: "/reset examples",
|
||||
sessionKey: "agent:main",
|
||||
});
|
||||
expect(payload).not.toHaveProperty("message");
|
||||
expect(host.chatQueue[0]).toMatchObject({
|
||||
refreshSessions: false,
|
||||
text: "/reset examples",
|
||||
skillWorkshopRevision: {
|
||||
proposalId: "support-file-sampler-20260531-68207b7b7f",
|
||||
},
|
||||
});
|
||||
|
||||
sent.resolve({ runId: host.chatQueue[0]?.sendRunId, status: "started" });
|
||||
await send;
|
||||
|
||||
expect(host.chatMessages[0]).toMatchObject({
|
||||
role: "user",
|
||||
content: [{ type: "text", text: "/reset examples" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps ACK-completed sends idle when sessions.list returns a stale active row", async () => {
|
||||
const request = vi.fn(async (method: string, params?: unknown) => {
|
||||
if (method === "chat.send") {
|
||||
|
||||
@@ -1688,6 +1688,7 @@ export async function handleSendChat(
|
||||
const attachments = host.chatAttachments ?? [];
|
||||
const attachmentsToSend = messageOverride == null ? snapshotChatAttachments(attachments) : [];
|
||||
const hasAttachments = attachmentsToSend.length > 0;
|
||||
const isSkillWorkshopRevisionSend = Boolean(opts?.skillWorkshopRevision);
|
||||
|
||||
if (!message && !hasAttachments) {
|
||||
return;
|
||||
@@ -1697,7 +1698,7 @@ export async function handleSendChat(
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChatStopCommand(message)) {
|
||||
if (!isSkillWorkshopRevisionSend && isChatStopCommand(message)) {
|
||||
if (messageOverride == null) {
|
||||
recordNonTranscriptInputHistory(host, message);
|
||||
}
|
||||
@@ -1705,7 +1706,7 @@ export async function handleSendChat(
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBtwCommand(message)) {
|
||||
if (!isSkillWorkshopRevisionSend && isBtwCommand(message)) {
|
||||
const submitKey = chatSubmitKey(host, "btw", message, attachmentsToSend);
|
||||
await withChatSubmitGuard(host, submitKey, async () => {
|
||||
const modelSwitchReady = waitForPendingChatModelSwitch(host, submittedSessionKey);
|
||||
@@ -1732,7 +1733,7 @@ export async function handleSendChat(
|
||||
}
|
||||
|
||||
// Intercept local slash commands (/status, /model, /compact, etc.)
|
||||
const parsed = parseSlashCommand(message);
|
||||
const parsed = isSkillWorkshopRevisionSend ? null : parseSlashCommand(message);
|
||||
if (parsed?.command.executeLocal) {
|
||||
if (isChatBusy(host) && shouldQueueLocalSlashCommand(parsed.command.key)) {
|
||||
if (messageOverride == null) {
|
||||
@@ -1761,7 +1762,7 @@ export async function handleSendChat(
|
||||
return;
|
||||
}
|
||||
|
||||
const refreshSessions = isChatResetCommand(message);
|
||||
const refreshSessions = !isSkillWorkshopRevisionSend && isChatResetCommand(message);
|
||||
const submitKey = chatSubmitKey(
|
||||
host,
|
||||
"message",
|
||||
|
||||
Reference in New Issue
Block a user