mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-22 00:30:19 +02:00
Fix stale workspace command matching
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
4cae308db8
commit
8680f38746
3 files changed
+64
No files matched your search
@@ -53,4 +53,26 @@ describe("workspace command helpers", () => {
|
||||
|
||||
expect(match).toEqual(expect.objectContaining({ id: "runtime-web" }));
|
||||
});
|
||||
|
||||
it("does not match a stale runtime service after the configured command changes", () => {
|
||||
const workspaceRuntime = {
|
||||
commands: [
|
||||
{ id: "web", name: "web", kind: "service", command: "pnpm dev:once --tailscale-auth", cwd: "." },
|
||||
],
|
||||
};
|
||||
const command = findWorkspaceCommandDefinition(workspaceRuntime, "web");
|
||||
expect(command).not.toBeNull();
|
||||
|
||||
const match = matchWorkspaceRuntimeServiceToCommand(command!, [
|
||||
{
|
||||
id: "runtime-web",
|
||||
serviceName: "web",
|
||||
command: "pnpm dev",
|
||||
cwd: "/repo",
|
||||
configIndex: null,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(match).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -166,6 +166,10 @@ export function scoreWorkspaceRuntimeServiceMatch(
|
||||
command: Pick<WorkspaceCommandDefinition, "serviceIndex" | "name" | "command" | "cwd">,
|
||||
runtimeService: Pick<WorkspaceRuntimeService, "configIndex" | "serviceName" | "command" | "cwd">,
|
||||
) {
|
||||
if (command.command && runtimeService.command && runtimeService.command !== command.command) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (command.serviceIndex !== null && runtimeService.configIndex !== null && runtimeService.configIndex !== undefined) {
|
||||
return runtimeService.configIndex === command.serviceIndex ? 100 : -1;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,44 @@ describe("buildWorkspaceRuntimeControlSections", () => {
|
||||
workspaceCommandId: "db-migrate",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps stale runtime services from masking updated inherited commands", () => {
|
||||
const sections = buildWorkspaceRuntimeControlSections({
|
||||
runtimeConfig: {
|
||||
commands: [
|
||||
{ id: "web", name: "web", kind: "service", command: "pnpm dev:once --tailscale-auth" },
|
||||
],
|
||||
},
|
||||
runtimeServices: [
|
||||
createRuntimeService({
|
||||
id: "service-web",
|
||||
serviceName: "web",
|
||||
status: "stopped",
|
||||
command: "pnpm dev",
|
||||
}),
|
||||
],
|
||||
canStartServices: true,
|
||||
canRunJobs: true,
|
||||
});
|
||||
|
||||
expect(sections.services).toEqual([
|
||||
expect.objectContaining({
|
||||
title: "web",
|
||||
statusLabel: "stopped",
|
||||
command: "pnpm dev:once --tailscale-auth",
|
||||
runtimeServiceId: null,
|
||||
}),
|
||||
]);
|
||||
expect(sections.otherServices).toEqual([
|
||||
expect.objectContaining({
|
||||
title: "web",
|
||||
statusLabel: "stopped",
|
||||
command: "pnpm dev",
|
||||
runtimeServiceId: "service-web",
|
||||
disabledReason: "This runtime service no longer matches a configured workspace command.",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildWorkspaceRuntimeControlItems", () => {
|
||||
|
||||
Reference in new issue
Block a user