Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"test:voice-cdp": "node scripts/voice-cdp.mjs",
"test:remote-diagnostics": "bun test scripts/remote-workspace-diagnostics.test.ts",
"test:open-target": "bun test scripts/open-target.test.ts",
"test:desktop-cloud-sync": "bun test scripts/desktop-cloud-sync.test.ts",
"test:artifact-spreadsheet": "bun test scripts/artifact-spreadsheet.test.ts",
"test:dev-log": "bun scripts/dev-log.ts",
"test:session-error-recovery": "bun scripts/session-error-recovery.ts",
Expand Down
164 changes: 0 additions & 164 deletions apps/app/scripts/desktop-cloud-sync.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions apps/app/scripts/extension-items.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/app/scripts/remote-workspace-diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function client(overrides: Partial<iPolloWorkServerClient> = {}): iPolloWorkServ
}),
capabilities: async () => ({
skills: { read: true, write: true, source: "ipollowork" },
plugins: { read: true, write: true },
mcp: { read: true, write: true },
commands: { read: true, write: true },
config: { read: true, write: true },
Expand Down
96 changes: 1 addition & 95 deletions apps/app/src/app/cloud/desktop-cloud-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,7 @@ import {
createDenClient,
readDenSettings,
} from "../lib/den";
import type {
iPolloWorkDesktopCloudSyncChange,
iPolloWorkDesktopCloudSyncResult,
iPolloWorkDesktopCloudSyncState,
iPolloWorkServerClient,
} from "../lib/ipollowork-server";

export type PendingCloudPluginChange = "modified" | "removed";

type InstalledCloudPluginLike = {
updatedAt: string | null;
files: Array<{ configObjectId: string; updatedAt: string | null }>;
};

function isRecord(value: unknown): value is Record<string, unknown> {
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
}

function readSyncChange(value: unknown): iPolloWorkDesktopCloudSyncChange | null {
if (!isRecord(value)) return null;
const id = typeof value.id === "string" ? value.id.trim() : "";
const kind = value.kind === "new" || value.kind === "modified" || value.kind === "removed" ? value.kind : null;
const resourceKind = value.resourceKind === "llmProvider" ||
value.resourceKind === "marketplace" ||
value.resourceKind === "plugin" ||
value.resourceKind === "configItem"
? value.resourceKind
: null;
if (!id || !kind || !resourceKind) return null;
return {
id,
kind,
resourceKind,
marketplaceId: typeof value.marketplaceId === "string" ? value.marketplaceId : undefined,
pluginId: typeof value.pluginId === "string" ? value.pluginId : undefined,
previousLastUpdatedAt: typeof value.previousLastUpdatedAt === "string" ? value.previousLastUpdatedAt : null,
nextLastUpdatedAt: typeof value.nextLastUpdatedAt === "string" ? value.nextLastUpdatedAt : null,
queuedAt: typeof value.queuedAt === "number" && Number.isFinite(value.queuedAt) ? value.queuedAt : 0,
};
}

/** Read all pending changes from a persisted desktop-cloud-sync state (GET response). */
export function readPendingCloudSyncChanges(state: iPolloWorkDesktopCloudSyncState): iPolloWorkDesktopCloudSyncChange[] {
return Object.values(state.entries).flatMap((entry) => {
if (!isRecord(entry) || !Array.isArray(entry.pendingChanges)) return [];
return entry.pendingChanges.flatMap((change) => {
const parsed = readSyncChange(change);
return parsed ? [parsed] : [];
});
});
}

/**
* Derive a map of installed cloud plugin id -> pending change.
* "modified" means an update is available; "removed" means the plugin was
* removed upstream. Stale changes (already applied locally or for plugins
* no longer installed) are filtered out.
*/
export function derivePendingCloudPluginChanges(input: {
changes: iPolloWorkDesktopCloudSyncChange[];
installedPlugins: Record<string, InstalledCloudPluginLike>;
}): Record<string, PendingCloudPluginChange> {
const pending: Record<string, PendingCloudPluginChange> = {};
const markModified = (pluginId: string) => {
if (pending[pluginId] !== "removed") pending[pluginId] = "modified";
};

for (const change of input.changes) {
if (change.resourceKind === "plugin") {
const installed = input.installedPlugins[change.id];
if (!installed) continue;
if (change.kind === "removed") {
pending[change.id] = "removed";
} else if (installed.updatedAt !== change.nextLastUpdatedAt) {
markModified(change.id);
}
continue;
}

if (change.resourceKind !== "configItem") continue;
const pluginId = change.pluginId?.trim() ?? "";
const installed = pluginId ? input.installedPlugins[pluginId] : undefined;
if (!installed) continue;
const file = installed.files.find((entry) => entry.configObjectId === change.id) ?? null;
if (change.kind === "removed") {
if (file) markModified(pluginId);
} else if (change.kind === "new") {
if (!file) markModified(pluginId);
} else if (file && file.updatedAt !== change.nextLastUpdatedAt) {
markModified(pluginId);
}
}

return pending;
}
import type { iPolloWorkDesktopCloudSyncResult, iPolloWorkServerClient } from "../lib/ipollowork-server";

let desktopCloudSyncQueue: Promise<void> = Promise.resolve();

Expand Down
Loading
Loading