@getpaseo/server 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,6 +94,17 @@ const MODELS = [
94
94
  intervalMs: 5,
95
95
  },
96
96
  },
97
+ {
98
+ provider: MOCK_LOAD_TEST_PROVIDER_ID,
99
+ id: "e2e-fast-stream",
100
+ label: "E2E fast stream",
101
+ description: "Short deterministic stream for browser tests.",
102
+ isSelectable: false,
103
+ metadata: {
104
+ durationMs: 2000,
105
+ intervalMs: 20,
106
+ },
107
+ },
97
108
  ];
98
109
  function shouldEmitPlanApprovalPrompt(prompt) {
99
110
  return /emit\s+(?:a\s+)?synthetic\s+plan\s+approval/i.test(promptToText(prompt));
@@ -1,5 +1,7 @@
1
1
  import { resolve } from "node:path";
2
+ import { LRUCache } from "lru-cache";
2
3
  import { archiveIfSafe } from "./archive-if-safe.js";
4
+ const OPEN_PULL_REQUEST_LATCH_MAX = 1024;
3
5
  const defaultDependencies = {
4
6
  archiveIfSafe,
5
7
  resolvePath: resolve,
@@ -7,14 +9,29 @@ const defaultDependencies = {
7
9
  export function setupAutoArchiveOnMerge(options, deps = defaultDependencies) {
8
10
  const log = options.logger.child({ module: "auto-archive-on-merge" });
9
11
  const inFlightCwds = new Set();
12
+ const openPullRequestUrlsByCwd = new LRUCache({
13
+ max: OPEN_PULL_REQUEST_LATCH_MAX,
14
+ });
10
15
  return options.workspaceGitService.onSnapshotUpdated((snapshot) => {
11
- if (!snapshot.forge.pullRequest?.isMerged) {
16
+ const snapshotCwd = deps.resolvePath(snapshot.cwd);
17
+ if (options.daemonConfigStore.get().autoArchiveAfterMerge !== true) {
18
+ openPullRequestUrlsByCwd.delete(snapshotCwd);
12
19
  return;
13
20
  }
14
- if (options.daemonConfigStore.get().autoArchiveAfterMerge !== true) {
21
+ const pullRequest = snapshot.forge.pullRequest;
22
+ if (!pullRequest?.isMerged) {
23
+ if (pullRequest?.state.toLowerCase() === "open") {
24
+ openPullRequestUrlsByCwd.set(snapshotCwd, pullRequest.url);
25
+ }
26
+ else {
27
+ openPullRequestUrlsByCwd.delete(snapshotCwd);
28
+ }
29
+ return;
30
+ }
31
+ if (openPullRequestUrlsByCwd.get(snapshotCwd) !== pullRequest.url) {
32
+ openPullRequestUrlsByCwd.delete(snapshotCwd);
15
33
  return;
16
34
  }
17
- const snapshotCwd = deps.resolvePath(snapshot.cwd);
18
35
  if (inFlightCwds.has(snapshotCwd)) {
19
36
  return;
20
37
  }
@@ -30,7 +47,13 @@ export function setupAutoArchiveOnMerge(options, deps = defaultDependencies) {
30
47
  log.warn({ err: error, cwd: snapshot.cwd }, "Failed to read snapshot for auto-archive; skipping");
31
48
  return;
32
49
  }
33
- if (!freshSnapshot?.forge.pullRequest?.isMerged) {
50
+ const freshPullRequest = freshSnapshot?.forge.pullRequest;
51
+ if (!freshPullRequest?.isMerged ||
52
+ freshPullRequest.url !== pullRequest.url ||
53
+ openPullRequestUrlsByCwd.get(snapshotCwd) !== pullRequest.url) {
54
+ if (openPullRequestUrlsByCwd.get(snapshotCwd) === pullRequest.url) {
55
+ openPullRequestUrlsByCwd.delete(snapshotCwd);
56
+ }
34
57
  return;
35
58
  }
36
59
  const attachedWorkspaces = (await options.listActiveWorkspaces()).filter((workspace) => deps.resolvePath(workspace.cwd) === snapshotCwd);
@@ -1218,11 +1218,6 @@ function buildInitialPullRequestLookupTarget(input) {
1218
1218
  if (!input.currentBranch) {
1219
1219
  return null;
1220
1220
  }
1221
- // Paseo worktree metadata owns PR identity. A checkout drift must not fall
1222
- // through to branch config and silently retarget the workspace.
1223
- if (input.metadata) {
1224
- return buildPullRequestLookupTargetFromMetadata(input.metadata, input.currentBranch);
1225
- }
1226
1221
  const hasConfiguredBranchTarget = Boolean(input.branchRemoteName && parseBranchMergeHeadRef(input.branchMergeRef));
1227
1222
  if (hasConfiguredBranchTarget) {
1228
1223
  return buildPullRequestLookupTargetFromBranchConfig({
@@ -1234,15 +1229,14 @@ function buildInitialPullRequestLookupTarget(input) {
1234
1229
  resolvedBaseRef: input.resolvedBaseRef,
1235
1230
  });
1236
1231
  }
1237
- return (buildPullRequestLookupTargetFromMetadata(input.metadata, input.currentBranch) ??
1238
- buildPullRequestLookupTargetFromBranchConfig({
1239
- currentBranch: input.currentBranch,
1240
- branchRemoteName: input.branchRemoteName,
1241
- branchMergeRef: input.branchMergeRef,
1242
- branchRemoteUrl: input.branchRemoteUrl,
1243
- originRemoteUrl: input.originRemoteUrl,
1244
- resolvedBaseRef: input.resolvedBaseRef,
1245
- }));
1232
+ return buildPullRequestLookupTargetFromBranchConfig({
1233
+ currentBranch: input.currentBranch,
1234
+ branchRemoteName: input.branchRemoteName,
1235
+ branchMergeRef: input.branchMergeRef,
1236
+ branchRemoteUrl: input.branchRemoteUrl,
1237
+ originRemoteUrl: input.originRemoteUrl,
1238
+ resolvedBaseRef: input.resolvedBaseRef,
1239
+ });
1246
1240
  }
1247
1241
  async function resolvePullRequestLookupTargetFromPushConfig(cwd, currentBranch, knownOriginRemoteUrl, knownResolvedBaseRef, context) {
1248
1242
  const pushRemoteName = await getGitConfigValue(cwd, `branch.${currentBranch}.pushRemote`, context);
@@ -1266,12 +1260,14 @@ async function resolvePullRequestLookupTargetFromPushConfig(cwd, currentBranch,
1266
1260
  }
1267
1261
  async function resolveFactsPullRequestLookupTarget(input) {
1268
1262
  const { cwd, inspected, metadata, context } = input;
1269
- if (inspected.paseoWorktree.isPaseoOwnedWorktree) {
1270
- return buildPullRequestLookupTargetFromMetadata(metadata, inspected.currentBranch ?? "");
1263
+ const metadataTarget = inspected.currentBranch
1264
+ ? buildPullRequestLookupTargetFromMetadata(metadata, inspected.currentBranch)
1265
+ : null;
1266
+ if (metadataTarget) {
1267
+ return metadataTarget;
1271
1268
  }
1272
1269
  let target = buildInitialPullRequestLookupTarget({
1273
1270
  currentBranch: inspected.currentBranch,
1274
- metadata,
1275
1271
  branchRemoteName: input.branchRemoteName,
1276
1272
  branchMergeRef: input.branchMergeRef,
1277
1273
  branchRemoteUrl: input.branchRemoteUrl,