Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(client): resume completed shells and deduplicate repeated links #21627

Closedjuliusmarmingewants to merge 1 commit intossh-relay-remote-14/interface fromssh-relay-remote-14/shell-transportopened View on GitHub

Showing 9 changed files with 19 additions and 0 deletions (loading 8).

x
0 of 9 viewed, 9 left
19 additions and 0 deletionsapps/server/src/orchestration-v2/ShellStream.tsModified
View file
@@ -13,6 +13,7 @@
OrchestrationV2ThreadShell as ThreadShellSchema,
} from "@t3tools/contracts";
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
+import { stableStringify } from "@t3tools/shared/relaySigning";
import * as Clock from "effect/Clock";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
@@ -33,6 +34,24 @@
};
​
+export function deduplicateShellPullRequests(
+ snapshot: OrchestrationV2ShellSnapshot,
+): OrchestrationV2ShellSnapshot {
+ const firstRowByLinks = new Map<string, number>();
+ const threads = snapshot.threads.map((thread, index) => {
+ if (thread.pullRequests === undefined || thread.pullRequests.length === 0) return thread;
+ const key = stableStringify(thread.pullRequests);
+ const reference = firstRowByLinks.get(key);
+ if (reference === undefined) {
+ firstRowByLinks.set(key, index);
+ return thread;
+ }
+ const { pullRequests: _links, ...row } = thread;
+ return { ...row, pullRequestReference: reference };
+ });
+ return { ...snapshot, threads };
+}