mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 16:02:43 +00:00
* fix: retire closed editor models from the app shell * test(editor): use checked Monaco attachment calls * Preserve bounded editor view caches when retiring closed models * docs(editor): describe batched model retirement * fix(editor): preserve cleanup work across registry replacement * fix(editor): build editor model URIs with the file scheme Monaco keys its model registry by `uri.toString()`, and both `@monaco-editor/react` (via the `path` prop) and the closed-tab disposal path built that key with `Uri.parse`. On Windows a raw path such as `C:\repo\a.ts` parses as scheme `c`, which fails the scheme gate in `modelService._schemaShouldMaintainUndoRedoElements`, so closed-file undo history was dropped for every file at any size — not only the large files the tradeoff note covers. Add `toEditorModelUri`, the one filesystem-path -> model-key function, built on `Uri.file` so the result always carries the `file:` scheme and re-parses to itself. Route model creation, disposal lookup and the still-open ownership comparison through it so all three agree; a divergence there would dispose a model an open editor is still editing. --------- Co-authored-by: m4air <m4air@Mac.localdomain> Co-authored-by: Neil <neil@stably.ai>
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import { createRequire } from 'node:module'
|
|
import { dirname, relative, resolve, sep } from 'node:path'
|
|
import base from '../../../config/vitest.config.ts'
|
|
const require = createRequire(import.meta.url)
|
|
const { loadSources } = require(resolve('docs/audits/closed-editor-model-lifetime/sources.cjs'))
|
|
|
|
const loaded = loadSources()
|
|
export default {
|
|
...base,
|
|
plugins: [
|
|
{
|
|
name: 'closed-model-source-fence',
|
|
enforce: 'pre',
|
|
resolveId(source, importer) {
|
|
const target = source.startsWith('@/')
|
|
? resolve(loaded.root, 'src/renderer/src', source.slice(2))
|
|
: source.startsWith('.') && importer
|
|
? resolve(dirname(importer), source)
|
|
: source.startsWith(loaded.root)
|
|
? source
|
|
: null
|
|
if (!target) {
|
|
return null
|
|
}
|
|
for (const extension of ['', '.ts', '.tsx', '.json']) {
|
|
const candidate = `${target}${extension}`
|
|
if (loaded.sources.has(candidate)) {
|
|
return candidate
|
|
}
|
|
}
|
|
return null
|
|
},
|
|
load(id) {
|
|
const name = resolve(id.split('?')[0])
|
|
const local = relative(loaded.root, name)
|
|
if (local.startsWith(`src${sep}`) || local.startsWith(`config${sep}`)) {
|
|
if (!loaded.sources.has(name)) {
|
|
throw new Error(`Unfenced repository source: ${name}`)
|
|
}
|
|
return loaded.sources.get(name)
|
|
}
|
|
return null
|
|
}
|
|
}
|
|
],
|
|
test: {
|
|
...base.test,
|
|
environment: 'happy-dom',
|
|
maxWorkers: 1,
|
|
include: ['docs/audits/closed-editor-model-lifetime/lifecycle.test.mjs']
|
|
}
|
|
}
|