feat(app): Add WebStorm editor target (#220)
* Add WebStorm editor target * Fix rebase type errors and add TODO date tag - Await listAvailableEditorTargets() which became async on main - Wrap sendAgentMessage callback to match Promise<void> return type - Add TODO(2026-07) date to legacy editor target ids comment --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
co-authored by
Mohamed Boudra
parent
f4b487df78
commit
0f0bfb551c
@@ -66,7 +66,7 @@ function makeAgent(input: {
|
||||
};
|
||||
}
|
||||
|
||||
function createSessionForWorkspaceTests(): {
|
||||
function createSessionForWorkspaceTests(options: { appVersion?: string | null } = {}): {
|
||||
session: Session;
|
||||
emitted: Array<{ type: string; payload: unknown }>;
|
||||
projects: Map<number, ReturnType<typeof createPersistedProjectRecord>>;
|
||||
@@ -91,6 +91,7 @@ function createSessionForWorkspaceTests(): {
|
||||
|
||||
const session = new Session({
|
||||
clientId: "test-client",
|
||||
appVersion: options.appVersion ?? null,
|
||||
onMessage: (message) => emitted.push(message as any),
|
||||
logger: logger as any,
|
||||
downloadTokenStore: {} as any,
|
||||
@@ -100,6 +101,9 @@ function createSessionForWorkspaceTests(): {
|
||||
subscribe: () => () => {},
|
||||
listAgents: () => [],
|
||||
getAgent: () => null,
|
||||
archiveAgent: async () => ({ archivedAt: new Date().toISOString() }),
|
||||
clearAgentAttention: async () => {},
|
||||
notifyAgentState: () => {},
|
||||
} as any,
|
||||
agentStorage: {
|
||||
list: async () => [],
|
||||
@@ -1266,19 +1270,51 @@ describe("workspace aggregation", () => {
|
||||
});
|
||||
|
||||
test("list_available_editors_request returns available targets", async () => {
|
||||
const { session, emitted } = createSessionForWorkspaceTests();
|
||||
const { session, emitted } = createSessionForWorkspaceTests({ appVersion: "0.1.50" });
|
||||
const sessionAny = session as any;
|
||||
|
||||
sessionAny.getAvailableEditorTargets = async () => [
|
||||
{ id: "cursor", label: "Cursor" },
|
||||
{ id: "finder", label: "Finder" },
|
||||
];
|
||||
sessionAny.getAvailableEditorTargets = async () =>
|
||||
sessionAny.filterEditorsForClient([
|
||||
{ id: "cursor", label: "Cursor" },
|
||||
{ id: "webstorm", label: "WebStorm" },
|
||||
{ id: "finder", label: "Finder" },
|
||||
{ id: "unknown-editor", label: "Unknown Editor" },
|
||||
]);
|
||||
|
||||
await sessionAny.handleMessage({
|
||||
type: "list_available_editors_request",
|
||||
requestId: "req-editors",
|
||||
});
|
||||
|
||||
const response = emitted.find(
|
||||
(message) => message.type === "list_available_editors_response",
|
||||
) as any;
|
||||
expect(response?.payload.error).toBeNull();
|
||||
expect(response?.payload.editors).toEqual([
|
||||
{ id: "cursor", label: "Cursor" },
|
||||
{ id: "webstorm", label: "WebStorm" },
|
||||
{ id: "finder", label: "Finder" },
|
||||
{ id: "unknown-editor", label: "Unknown Editor" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("list_available_editors_request filters unsupported ids for legacy clients", async () => {
|
||||
const { session, emitted } = createSessionForWorkspaceTests({ appVersion: "0.1.49" });
|
||||
const sessionAny = session as any;
|
||||
|
||||
sessionAny.getAvailableEditorTargets = async () =>
|
||||
sessionAny.filterEditorsForClient([
|
||||
{ id: "cursor", label: "Cursor" },
|
||||
{ id: "webstorm", label: "WebStorm" },
|
||||
{ id: "unknown-editor", label: "Unknown Editor" },
|
||||
{ id: "finder", label: "Finder" },
|
||||
]);
|
||||
|
||||
await sessionAny.handleMessage({
|
||||
type: "list_available_editors_request",
|
||||
requestId: "req-editors-legacy",
|
||||
});
|
||||
|
||||
const response = emitted.find(
|
||||
(message) => message.type === "list_available_editors_response",
|
||||
) as any;
|
||||
|
||||
Reference in New Issue
Block a user