pi-edit-fence 1.0.1 → 1.0.2
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/extensions/edit-fence.ts +5 -1
- package/package.json +1 -1
package/extensions/edit-fence.ts
CHANGED
|
@@ -269,11 +269,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
269
269
|
return undefined;
|
|
270
270
|
}
|
|
271
271
|
if (result.kind === "block") {
|
|
272
|
+
// How long until the lock auto-expires if the owner stays idle from now.
|
|
273
|
+
// Contention shortens the lease, so this is the worst-case wait before retry succeeds.
|
|
274
|
+
const lease = result.owner.contendedAt != null ? CONTENDED_LEASE_MS : LEASE_MS;
|
|
275
|
+
const remainingSec = Math.max(0, Math.ceil((result.owner.ts + lease - Date.now()) / 1000));
|
|
272
276
|
return {
|
|
273
277
|
block: true,
|
|
274
278
|
reason:
|
|
275
279
|
`path-fence: ${SCOPE === "file" ? "file" : "area"} "${key}" is locked by another active pi session (${result.owner.session}, pid ${result.owner.pid}). ` +
|
|
276
|
-
`Work on other files, or wait and retry this edit
|
|
280
|
+
`Work on other files, or wait and retry this edit. The lock releases when the other session is done, and auto-expires in ~${remainingSec}s if it goes idle now (each edit it makes resets that timer).`,
|
|
277
281
|
};
|
|
278
282
|
}
|
|
279
283
|
if (result.kind === "warn" && ctx.hasUI) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-edit-fence",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Stop concurrent pi sessions from clobbering each other's edits. Per-file locks, auto-claim on edit, retry-later, lease expiry, crash recovery. No git worktrees.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|