@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 +14 -0
- package/index.client.ts +33 -10
- package/package.json +10 -4
- package/server/fresh-worktrees.ts +37 -42
- package/server/workspace-freshness.ts +1 -1
- package/shared/workspace-freshness.ts +5 -1
- package/CHANGELOG.md +0 -43
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
|
+

|
|
18
|
+
|
|
19
|
+
### Installed plugin
|
|
20
|
+
|
|
21
|
+

|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
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.
|
|
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": "
|
|
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
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
?
|
|
92
|
-
:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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({
|
|
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))
|