@lincyaw/workspace 1.0.0-rc.136 → 1.0.0-rc.138

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/workspace",
3
- "version": "1.0.0-rc.136",
3
+ "version": "1.0.0-rc.138",
4
4
  "description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -35,13 +35,13 @@
35
35
  "mime-types": "3.0.2",
36
36
  "playwright-chromium": "1.64.1",
37
37
  "yaml": "^2.9.1",
38
- "@lincyaw/compiler": "1.0.0-rc.136",
39
- "@lincyaw/kernel": "1.0.0-rc.136",
40
- "@lincyaw/server": "1.0.0-rc.136",
41
- "@lincyaw/design": "1.0.0-rc.136"
38
+ "@lincyaw/server": "1.0.0-rc.138",
39
+ "@lincyaw/compiler": "1.0.0-rc.138",
40
+ "@lincyaw/design": "1.0.0-rc.138",
41
+ "@lincyaw/kernel": "1.0.0-rc.138"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/mime-types": "^3.0.1",
45
- "@lincyaw/mcp": "1.0.0-rc.136"
45
+ "@lincyaw/mcp": "1.0.0-rc.138"
46
46
  }
47
47
  }
@@ -2,6 +2,7 @@ import { createHash, randomUUID } from 'node:crypto'
2
2
  import { existsSync } from 'node:fs'
3
3
  import { join } from 'node:path'
4
4
  import { errorMessage, pushStream } from '@lincyaw/kernel'
5
+ import { acquireCandidateLease } from '@lincyaw/kernel/node'
5
6
  import type { DocumentFiles, Logger, Member, ReviewChange, ReviewEnd, ReviewSnapshot, ReviewUpdate } from '@lincyaw/kernel'
6
7
  import { trailers } from '../../domain/commit-message.ts'
7
8
  import type { WorkspaceConfig } from '../config.ts'
@@ -100,7 +101,7 @@ export class AgentSessionReviews {
100
101
  try {
101
102
  const pending = pendingAgentSessionReview(scopeDir)
102
103
  if (pending?.session) {
103
- await this.#serial(() => this.#resume(pending))
104
+ await this.#serial(() => this.#resume(pending), () => pending.workspace ? [pending.workspace.root] : [])
104
105
  continue
105
106
  }
106
107
  await rollBackLeftTaskReview(this.#options, document)
@@ -133,14 +134,14 @@ export class AgentSessionReviews {
133
134
  let workspace = this.#workspaces.get(session)
134
135
  if (!workspace) { workspace = await AgentWorkspace.create(this.#options.config); this.#workspaces.set(session, workspace) }
135
136
  return { root: workspace.root }
136
- })
137
+ }, false)
137
138
  }
138
139
 
139
140
  refreshWorkspace(session: string): Promise<boolean> {
140
141
  return this.#serial(async () => {
141
142
  const workspace = this.#workspaces.get(session)
142
143
  return workspace && this.#open?.session !== session ? workspace.refresh() : false
143
- })
144
+ }, () => this.#workspaces.has(session) ? [this.#workspaces.get(session)!.root] : [])
144
145
  }
145
146
 
146
147
  /** The DSH adapter has adopted and staged any orphaned native review before this is called. */
@@ -166,7 +167,7 @@ export class AgentSessionReviews {
166
167
  const workspace = this.#workspaces.get(session)
167
168
  this.#workspaces.delete(session)
168
169
  workspace?.dispose()
169
- })
170
+ }, () => this.#workspaces.has(session) ? [this.#workspaces.get(session)!.root] : [])
170
171
  }
171
172
 
172
173
  snapshot(): Promise<ReviewSnapshot | undefined> {
@@ -281,7 +282,7 @@ export class AgentSessionReviews {
281
282
  open.running = true
282
283
  this.#rescheduleRollback()
283
284
  return await this.#publish(open)
284
- })
285
+ }, () => this.#workspaces.has(body.session) ? [this.#workspaces.get(body.session)!.root] : [])
285
286
  }
286
287
 
287
288
  step(document: string, body: { session: string, turn?: number, label?: string, tool?: string, end?: boolean }): Promise<ReviewSnapshot | undefined> {
@@ -497,8 +498,19 @@ export class AgentSessionReviews {
497
498
  open.timer.unref?.()
498
499
  }
499
500
 
500
- #serial<T>(work: () => Promise<T>): Promise<T> {
501
- const next = this.#queue.then(work, work)
501
+ #serial<T>(work: () => Promise<T>, roots: false | (() => string[]) = () => this.#open?.workspace ? [this.#open.workspace.root] : []): Promise<T> {
502
+ const guarded = async () => {
503
+ const releases: (() => Promise<void>)[] = []
504
+ try {
505
+ if (roots && process.platform === 'darwin') {
506
+ for (const root of roots().sort()) releases.push(await acquireCandidateLease(root))
507
+ }
508
+ return await work()
509
+ } finally {
510
+ for (const release of releases.reverse()) await release()
511
+ }
512
+ }
513
+ const next = this.#queue.then(guarded, guarded)
502
514
  this.#queue = next.catch(() => undefined)
503
515
  return next
504
516
  }