mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 08:02:33 +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>
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
const assert = require('node:assert/strict')
|
|
const { existsSync, writeFileSync } = require('node:fs')
|
|
const path = require('node:path')
|
|
const { loadSources, readText, sha256, versions } = require('./sources.cjs')
|
|
|
|
const observations = []
|
|
const published = loadSources({ graph: 'main', variant: 'fixed' })
|
|
const virtualRead = (filename) => published.sources.get(filename) ?? readText(filename)
|
|
const virtualExists = (filename) => {
|
|
const relative = path.relative(published.root, filename).split(path.sep).join('/')
|
|
return Object.hasOwn(versions.sources, relative)
|
|
? published.sources.has(filename)
|
|
: existsSync(filename)
|
|
}
|
|
for (const graph of ['worktree', 'main']) {
|
|
for (const variant of ['before', 'fixed']) {
|
|
const normal = loadSources({ graph, variant })
|
|
const crlf = loadSources({
|
|
graph,
|
|
variant,
|
|
read: (filename) => readText(filename).replaceAll('\n', '\r\n')
|
|
})
|
|
const fromPublication = loadSources({
|
|
graph,
|
|
variant,
|
|
read: virtualRead,
|
|
exists: virtualExists
|
|
})
|
|
assert.deepEqual(crlf.hashes, normal.hashes)
|
|
assert.deepEqual(fromPublication.hashes, normal.hashes)
|
|
observations.push({
|
|
graph,
|
|
variant,
|
|
sources: normal.sources.size,
|
|
canonicalLfMatches: true,
|
|
simulatedMainCheckoutMatches: true,
|
|
graphSha256: sha256(JSON.stringify(normal.hashes))
|
|
})
|
|
}
|
|
}
|
|
const setup = path.join(published.root, 'src/renderer/src/lib/monaco-setup.ts')
|
|
assert.ok(published.sources.get(setup).includes('registerShellMarkdownAliases(monaco)'))
|
|
assert.throws(
|
|
() =>
|
|
loadSources({
|
|
read: (filename) =>
|
|
filename === setup ? `${readText(filename)}\n// drift\n` : readText(filename)
|
|
}),
|
|
/Fixed source drift/
|
|
)
|
|
writeFileSync(
|
|
process.env.ORCA_CLOSED_MODEL_LOADER_OUTPUT ?? path.join(__dirname, 'loader-results.json'),
|
|
`${JSON.stringify({ observations, mainMarkdownAliasesPreserved: true, driftRejected: true }, null, 2)}\n`
|
|
)
|