improve ai alert copilot ux
This commit is contained in:
parent
ebdc4ab8e6
commit
32e965d782
15 changed files with 931 additions and 15 deletions
|
|
@ -10,7 +10,11 @@ import {
|
|||
getDesktopAiModelSelectLabel,
|
||||
getDesktopAiProfileBadgeLabel,
|
||||
getDesktopAiSettingsBridgeNotice,
|
||||
createCopilotTaskCacheKey,
|
||||
getCachedCopilotTaskId,
|
||||
getCopilotTaskSurfaceState,
|
||||
requireDesktopActionCopy,
|
||||
shouldShowCopilotRegenerate,
|
||||
} from "./desktop-ai-panels";
|
||||
|
||||
describe("desktop ai runtime detection", () => {
|
||||
|
|
@ -41,6 +45,7 @@ describe("desktop ai runtime detection", () => {
|
|||
logout: async () => {},
|
||||
updatePreferences: async () => {},
|
||||
runTask: async () => ({ taskId: "task-1" }),
|
||||
cancelTask: async () => {},
|
||||
subscribe: () => () => {},
|
||||
},
|
||||
},
|
||||
|
|
@ -146,3 +151,49 @@ describe("desktop ai settings copy", () => {
|
|||
).toBe("Selected");
|
||||
});
|
||||
});
|
||||
|
||||
describe("desktop ai panel task helpers", () => {
|
||||
it("looks up cached task ids by action kind and context key", () => {
|
||||
const key = createCopilotTaskCacheKey("smart-money-explain", "AAPL:1:event-1");
|
||||
|
||||
expect(key).toBe("smart-money-explain:AAPL:1:event-1");
|
||||
expect(
|
||||
getCachedCopilotTaskId(
|
||||
{ [key]: "task-1" },
|
||||
"smart-money-explain",
|
||||
"AAPL:1:event-1",
|
||||
),
|
||||
).toBe("task-1");
|
||||
});
|
||||
|
||||
it("only shows regenerate once a completed result has output", () => {
|
||||
expect(
|
||||
shouldShowCopilotRegenerate({
|
||||
status: "completed",
|
||||
text: "## Thesis",
|
||||
compiledScreen: null,
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldShowCopilotRegenerate({
|
||||
status: "running",
|
||||
text: "partial",
|
||||
compiledScreen: null,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(shouldShowCopilotRegenerate(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("maps queued, running, failed, and cancelled tasks to result surface states", () => {
|
||||
expect(getCopilotTaskSurfaceState(null)).toBe("empty");
|
||||
expect(getCopilotTaskSurfaceState({ status: "queued", text: "", compiledScreen: null, error: null })).toBe(
|
||||
"running",
|
||||
);
|
||||
expect(getCopilotTaskSurfaceState({ status: "running", text: "", compiledScreen: null, error: null })).toBe(
|
||||
"running",
|
||||
);
|
||||
expect(getCopilotTaskSurfaceState({ status: "cancelled", text: "", compiledScreen: null, error: null })).toBe(
|
||||
"cancelled",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue