@omercnet/paseo-fresh-worktrees 1.2.0 → 1.2.1-next.129.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.
package/README.md CHANGED
@@ -6,6 +6,20 @@ branch-off workspace.
6
6
  The plugin runs the refresh inside the Paseo daemon and adds a workspace-header indicator when an
7
7
  active worktree falls behind the source checkout's remote base.
8
8
 
9
+ ## Screenshots
10
+
11
+ The repository, remote, branch, and workspace are disposable local fixtures. Both PNGs come from
12
+ an isolated Paseo test daemon at 2× pixel density. Browser DevTools rewrites local paths and host
13
+ labels and verifies that no private organization names remain before capture.
14
+
15
+ ### Behind indicator
16
+
17
+ ![Fresh Worktrees behind indicator](https://raw.githubusercontent.com/omercnet/paseo-plugins/main/fresh-worktrees/docs/images/fresh-worktrees-behind.png)
18
+
19
+ ### Installed plugin
20
+
21
+ ![Fresh Worktrees plugin settings](https://raw.githubusercontent.com/omercnet/paseo-plugins/main/fresh-worktrees/docs/images/fresh-worktrees-settings.png)
22
+
9
23
  ## Behavior
10
24
 
11
25
  Before Paseo creates a branch-off worktree, the plugin:
package/index.client.ts CHANGED
@@ -13,15 +13,28 @@ interface WorkspaceEntry {
13
13
  workspaceDirectory: string | null;
14
14
  }
15
15
 
16
+ interface ReleasableSubscription {
17
+ release(): Promise<void>;
18
+ }
19
+
16
20
  export default function contribute(client: PluginClientContext) {
17
21
  const buttons = new Map<string, PluginButtonRegistration>();
18
22
  const checks = new Map<string, Promise<void>>();
19
- const workspaceLocations = new Map<
20
- string,
21
- { projectId: string; workspaceDirectory: string }
22
- >();
23
+ const workspaceLocations = new Map<string, { projectId: string; workspaceDirectory: string }>();
23
24
  const projectRoots = new Map<string, string>();
24
25
  let stopped = false;
26
+ let workspaceSubscription: ReleasableSubscription | undefined;
27
+ let releaseSubscriptionPromise: Promise<void> | undefined;
28
+ let initializationFailed = false;
29
+
30
+ function releaseWorkspaceSubscription(): Promise<void> {
31
+ if (releaseSubscriptionPromise) return releaseSubscriptionPromise;
32
+ const subscription = workspaceSubscription;
33
+ workspaceSubscription = undefined;
34
+ if (!subscription) return Promise.resolve();
35
+ releaseSubscriptionPromise = subscription.release();
36
+ return releaseSubscriptionPromise;
37
+ }
25
38
 
26
39
  function removeIndicator(workspaceId: string) {
27
40
  buttons.get(workspaceId)?.remove();
@@ -129,17 +142,26 @@ export default function contribute(client: PluginClientContext) {
129
142
  }
130
143
  });
131
144
 
132
- void Promise.all([
133
- client.paseo.projects.list(),
134
- client.paseo.workspaces.list({ subscribe: { subscriptionId: "fresh-worktrees-status" } }),
135
- ])
145
+ const workspaceList = client.paseo.workspaces.list({ subscribe: {} }).then(async (result) => {
146
+ workspaceSubscription = result.subscription;
147
+ if (stopped || initializationFailed) await releaseWorkspaceSubscription();
148
+ return result;
149
+ });
150
+
151
+ void Promise.all([client.paseo.projects.list(), workspaceList])
136
152
  .then(([{ projects }, { entries }]) => {
137
153
  if (stopped) return;
138
154
  for (const project of projects) projectRoots.set(project.projectId, project.projectRootPath);
139
155
  for (const workspace of entries) trackWorkspace(workspace);
140
156
  })
141
- .catch((error) => {
142
- console.warn("[fresh-worktrees] Could not list workspaces", error);
157
+ .catch(async (error) => {
158
+ initializationFailed = true;
159
+ try {
160
+ await releaseWorkspaceSubscription();
161
+ } catch (releaseError) {
162
+ console.warn("[fresh-worktrees] Could not release workspace observation", releaseError);
163
+ }
164
+ if (!stopped) console.warn("[fresh-worktrees] Could not list workspaces", error);
143
165
  });
144
166
 
145
167
  const interval = setInterval(() => {
@@ -158,5 +180,6 @@ export default function contribute(client: PluginClientContext) {
158
180
  buttons.clear();
159
181
  workspaceLocations.clear();
160
182
  projectRoots.clear();
183
+ return releaseWorkspaceSubscription();
161
184
  };
162
185
  }
package/package.json CHANGED
@@ -23,7 +23,6 @@
23
23
  "coding-agents"
24
24
  ],
25
25
  "files": [
26
- "CHANGELOG.md",
27
26
  "LICENSE",
28
27
  "README.md",
29
28
  "index.client.ts",
@@ -32,21 +31,28 @@
32
31
  "shared",
33
32
  "paseo-plugin.json"
34
33
  ],
35
- "version": "1.2.0",
34
+ "version": "1.2.1-next.129.1",
36
35
  "type": "module",
37
36
  "packageManager": "npm@11.19.1",
38
37
  "engines": {
39
38
  "node": ">=24"
40
39
  },
41
40
  "scripts": {
42
- "test": "vitest run",
43
- "typecheck": "tsc --noEmit"
41
+ "test": "run-s test:ci:*",
42
+ "typecheck": "tsc --noEmit",
43
+ "check": "biome check --error-on-warnings .",
44
+ "check:write": "biome check --write .",
45
+ "test:ci:unit": "vitest run",
46
+ "build": "node ../.github/scripts/build-plugin.mjs"
44
47
  },
45
48
  "devDependencies": {
49
+ "@biomejs/biome": "^2.5.14",
46
50
  "@getpaseo/client": "0.9.0-beta.1",
47
51
  "@getpaseo/plugin": "0.9.0-beta.1",
52
+ "@getpaseo/server": "0.9.0-beta.1",
48
53
  "@types/node": "^24.5.2",
49
54
  "@types/react": "~19.2.0",
55
+ "npm-run-all2": "^9.0.3",
50
56
  "react": "19.1.0",
51
57
  "typescript": "^7.0.0",
52
58
  "vitest": "^5.0.0",
@@ -42,7 +42,6 @@ export interface RefreshDependencies {
42
42
  const execFileAsync = promisify(execFile);
43
43
  const GIT_TIMEOUT_MS = 10_000;
44
44
 
45
-
46
45
  export async function executeGit(
47
46
  cwd: string,
48
47
  args: readonly string[],
@@ -79,41 +78,43 @@ export function createRepositoryRefreshCoordinator(
79
78
  if (existingRefresh) return existingRefresh;
80
79
 
81
80
  const previousRefresh = repositoryTails.get(cwd) ?? Promise.resolve();
82
- const refresh = previousRefresh.catch(() => {}).then(async (): Promise<RepositoryRefreshResult> => {
83
- await runGit(cwd, ["fetch", "--prune", "--quiet", remote], signal);
84
- if (!localBranch) return { kind: "unchanged" };
85
-
86
- const matchingRemoteBranch = `${remote}/${localBranch}`;
87
- const freshBase =
88
- upstream && (await remoteRefExists(runGit, cwd, upstream, signal))
89
- ? upstream
90
- : (await remoteRefExists(runGit, cwd, matchingRemoteBranch, signal))
91
- ? matchingRemoteBranch
92
- : null;
93
- if (!freshBase) return { kind: "unchanged" };
94
-
95
- const currentBranch = await optionalGit(
96
- runGit,
97
- cwd,
98
- ["symbolic-ref", "--quiet", "--short", "HEAD"],
99
- signal,
100
- );
101
- if (currentBranch !== localBranch) {
102
- throw new Error(
103
- `Cannot refresh local branch ${localBranch} in ${cwd}: the source checkout is on ${currentBranch ?? "a detached HEAD"}`,
81
+ const refresh = previousRefresh
82
+ .catch(() => {})
83
+ .then(async (): Promise<RepositoryRefreshResult> => {
84
+ await runGit(cwd, ["fetch", "--prune", "--quiet", remote], signal);
85
+ if (!localBranch) return { kind: "unchanged" };
86
+
87
+ const matchingRemoteBranch = `${remote}/${localBranch}`;
88
+ const freshBase =
89
+ upstream && (await remoteRefExists(runGit, cwd, upstream, signal))
90
+ ? upstream
91
+ : (await remoteRefExists(runGit, cwd, matchingRemoteBranch, signal))
92
+ ? matchingRemoteBranch
93
+ : null;
94
+ if (!freshBase) return { kind: "unchanged" };
95
+
96
+ const currentBranch = await optionalGit(
97
+ runGit,
98
+ cwd,
99
+ ["symbolic-ref", "--quiet", "--short", "HEAD"],
100
+ signal,
104
101
  );
105
- }
106
-
107
- const status = await runGit(
108
- cwd,
109
- ["status", "--porcelain", "--untracked-files=normal"],
110
- signal,
111
- );
112
- if (status) return { kind: "dirty" };
102
+ if (currentBranch !== localBranch) {
103
+ throw new Error(
104
+ `Cannot refresh local branch ${localBranch} in ${cwd}: the source checkout is on ${currentBranch ?? "a detached HEAD"}`,
105
+ );
106
+ }
107
+
108
+ const status = await runGit(
109
+ cwd,
110
+ ["status", "--porcelain", "--untracked-files=normal"],
111
+ signal,
112
+ );
113
+ if (status) return { kind: "dirty" };
113
114
 
114
- await runGit(cwd, ["merge", "--ff-only", "--quiet", freshBase], signal);
115
- return { kind: "updated", freshBase };
116
- });
115
+ await runGit(cwd, ["merge", "--ff-only", "--quiet", freshBase], signal);
116
+ return { kind: "updated", freshBase };
117
+ });
117
118
  const tail = refresh.then(
118
119
  () => {},
119
120
  () => {},
@@ -186,8 +187,7 @@ async function remoteRefExists(
186
187
  ): Promise<boolean> {
187
188
  const fullRef = ref.startsWith("refs/remotes/") ? ref : `refs/remotes/${ref}`;
188
189
  return (
189
- (await optionalGit(runGit, cwd, ["show-ref", "--verify", "--quiet", fullRef], signal)) !==
190
- null
190
+ (await optionalGit(runGit, cwd, ["show-ref", "--verify", "--quiet", fullRef], signal)) !== null
191
191
  );
192
192
  }
193
193
 
@@ -242,12 +242,7 @@ export async function refreshWorkspaceRequest(
242
242
  dependencies.signal,
243
243
  );
244
244
  if (currentBranch) {
245
- localBranch = await localBranchDetails(
246
- runGit,
247
- cwd,
248
- currentBranch,
249
- dependencies.signal,
250
- );
245
+ localBranch = await localBranchDetails(runGit, cwd, currentBranch, dependencies.signal);
251
246
  }
252
247
  }
253
248
 
@@ -1,7 +1,7 @@
1
1
  import type { RpcOutput } from "@getpaseo/plugin";
2
+ import type { workspaceFreshness } from "../shared/workspace-freshness";
2
3
  import type { GitRunner, RepositoryRefresh } from "./fresh-worktrees";
3
4
  import { executeGit } from "./fresh-worktrees";
4
- import { workspaceFreshness } from "../shared/workspace-freshness";
5
5
 
6
6
  export interface WorkspaceFreshnessDependencies {
7
7
  signal: AbortSignal;
@@ -8,7 +8,11 @@ export const workspaceFreshness = defineRpc({
8
8
  workspaceDirectory: z.string().min(1),
9
9
  }),
10
10
  output: z.discriminatedUnion("kind", [
11
- z.object({ kind: z.literal("behind"), remoteRef: z.string(), behindBy: z.number().int().positive() }),
11
+ z.object({
12
+ kind: z.literal("behind"),
13
+ remoteRef: z.string(),
14
+ behindBy: z.number().int().positive(),
15
+ }),
12
16
  z.object({ kind: z.literal("current"), remoteRef: z.string() }),
13
17
  z.object({ kind: z.literal("unavailable") }),
14
18
  ]),
package/CHANGELOG.md DELETED
@@ -1,43 +0,0 @@
1
- # Changelog
2
-
3
- ## Unreleased
4
-
5
- ### Changed
6
-
7
- * Fast-forward the clean, checked-out local base branch before creating a branch-off worktree.
8
- * Warn and skip the local branch update when the source checkout is dirty instead of blocking workspace creation.
9
- * Show a workspace-header indicator when a worktree is behind the source branch's remote-tracking ref.
10
-
11
- ## [1.2.0](https://github.com/omercnet/paseo-plugins/compare/fresh-worktrees-v1.1.1...fresh-worktrees-v1.2.0) (2026-09-18)
12
-
13
-
14
- ### Features
15
-
16
- * **release:** publish plugins to npm ([#80](https://github.com/omercnet/paseo-plugins/issues/80)) ([3c93048](https://github.com/omercnet/paseo-plugins/commit/3c93048cfefda97d8c2bc1631e3428fb64bdad09))
17
-
18
-
19
- ### Bug Fixes
20
-
21
- * **fresh-worktrees:** prepare for Paseo 0.9 ([#84](https://github.com/omercnet/paseo-plugins/issues/84)) ([17e45c2](https://github.com/omercnet/paseo-plugins/commit/17e45c2b3687949340339bcc0146563be6e9c631))
22
-
23
- ## [1.1.1](https://github.com/omercnet/paseo-plugins/compare/fresh-worktrees-v1.1.0...fresh-worktrees-v1.1.1) (2026-09-13)
24
-
25
-
26
- ### Bug Fixes
27
-
28
- * **fresh-worktrees:** prevent freshness RPC storms ([#28](https://github.com/omercnet/paseo-plugins/issues/28)) ([6244ebe](https://github.com/omercnet/paseo-plugins/commit/6244ebec4dee63694fa16a376877453510d9364f))
29
-
30
- ## [1.1.0](https://github.com/omercnet/paseo-plugins/compare/fresh-worktrees-v1.0.0...fresh-worktrees-v1.1.0) (2026-09-10)
31
-
32
-
33
- ### Features
34
-
35
- * **fresh-worktrees:** keep local base branch current ([#9](https://github.com/omercnet/paseo-plugins/issues/9)) ([2ebd062](https://github.com/omercnet/paseo-plugins/commit/2ebd0620d4356103c2a162b503103090b7289add))
36
-
37
- ## 1.0.0 (2026-09-10)
38
-
39
-
40
- ### Bug Fixes
41
-
42
- * upgrade plugins to Paseo 0.8.0 ([c6b4e40](https://github.com/omercnet/paseo-plugins/commit/c6b4e4081fc9527de0ca6183a3903ff5ec4f93c4))
43
- * upgrade plugins to Paseo 0.8.0 ([d7ad454](https://github.com/omercnet/paseo-plugins/commit/d7ad4540d2e1875bdf4a4d21f76ded25cac2f3dc))