@lincyaw/workspace 1.0.0-rc.150 → 1.0.0-rc.151

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.150",
3
+ "version": "1.0.0-rc.151",
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": {
@@ -38,13 +38,13 @@
38
38
  "mime-types": "3.0.2",
39
39
  "playwright-chromium": "1.64.1",
40
40
  "yaml": "^2.9.1",
41
- "@lincyaw/compiler": "1.0.0-rc.150",
42
- "@lincyaw/design": "1.0.0-rc.150",
43
- "@lincyaw/kernel": "1.0.0-rc.150",
44
- "@lincyaw/server": "1.0.0-rc.150"
41
+ "@lincyaw/compiler": "1.0.0-rc.151",
42
+ "@lincyaw/design": "1.0.0-rc.151",
43
+ "@lincyaw/kernel": "1.0.0-rc.151",
44
+ "@lincyaw/server": "1.0.0-rc.151"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/mime-types": "^3.0.1",
48
- "@lincyaw/mcp": "1.0.0-rc.150"
48
+ "@lincyaw/mcp": "1.0.0-rc.151"
49
49
  }
50
50
  }
@@ -515,21 +515,30 @@ export class Revisions implements RevisionService {
515
515
  }
516
516
 
517
517
  async #owners(files: { id: string, path: string }[]): Promise<(string | undefined)[]> {
518
- const maxTreeBytes = 4 << 20, queries = new Set<string>()
518
+ const maxTreeBytes = 4 << 20, maxBatchItems = 8192, queries = new Set<string>()
519
+ const directories = new Map<string, string | undefined>()
519
520
  const candidates = files.map(({ id, path }) => {
520
521
  const parts = path.split('/'), found: { directory: string, query: string }[] = []
521
522
  for (let i = parts.length - 1; i >= 0; i--) {
522
523
  const directory = parts.slice(0, i).join('/')
523
- if (!isDocumentDir(this.#files.config, directory)) continue
524
- const topPath = relative(this.#git.top, resolve(this.#files.config.root, directory)).split(sep).join('/')
524
+ if (!directories.has(directory)) directories.set(directory, isDocumentDir(this.#files.config, directory)
525
+ ? relative(this.#git.top, resolve(this.#files.config.root, directory)).split(sep).join('/') : undefined)
526
+ const topPath = directories.get(directory)
527
+ if (topPath === undefined) continue
525
528
  const query = topPath ? `${id}:${topPath}` : `${id}^{tree}`
526
529
  found.push({ directory, query }); queries.add(query)
527
530
  }
528
531
  return found
529
532
  })
530
533
  const trees = new Map<string, { oid: string, bytes: number }>(), objects = new Map<string, number>(), all = [...queries]
531
- for (let offset = 0; offset < all.length; offset += 512) {
532
- const batch = all.slice(offset, offset + 512)
534
+ for (let offset = 0; offset < all.length;) {
535
+ const batch: string[] = []; let bytes = 0
536
+ while (offset < all.length && batch.length < maxBatchItems) {
537
+ // Missing-object replies echo the query; successful headers fit within 100 bytes.
538
+ const query = all[offset]!, size = Math.max(Buffer.byteLength(query) + 16, 100)
539
+ if (batch.length && bytes + size > maxTreeBytes) break
540
+ batch.push(query); bytes += size; offset++
541
+ }
533
542
  const result = await this.#git.run(['cat-file', '--batch-check=%(objectname) %(objecttype) %(objectsize)', '-Z'], {}, Buffer.from(batch.join('\0') + '\0'))
534
543
  if (result.code !== 0) throw new RequestError(500, 'history-tree-read-failed')
535
544
  const lines = result.stdout.toString('utf8').split('\0'); lines.pop()
@@ -545,7 +554,11 @@ export class Revisions implements RevisionService {
545
554
  const regular = new Map<string, boolean>(), pending = [...objects]
546
555
  for (let offset = 0; offset < pending.length;) {
547
556
  const batch: [string, number][] = []; let bytes = 0
548
- while (offset < pending.length && batch.length < 512 && (!batch.length || bytes + pending[offset]![1] <= maxTreeBytes)) { const item = pending[offset++]!; batch.push(item); bytes += item[1] }
557
+ while (offset < pending.length && batch.length < maxBatchItems) {
558
+ const item = pending[offset]!, size = item[1] + item[0].length + String(item[1]).length + 8
559
+ if (batch.length && bytes + size > maxTreeBytes) break
560
+ batch.push(item); bytes += size; offset++
561
+ }
549
562
  const result = await this.#git.run(['cat-file', '--batch', '-Z'], {}, Buffer.from(batch.map(([oid]) => oid).join('\0') + '\0'))
550
563
  if (result.code !== 0) throw new RequestError(500, 'history-tree-read-failed')
551
564
  let cursor = 0