feat: add structured agent tools and improve workspace chat UX
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const { test } = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const vm = require('node:vm')
|
||||
const ts = require('typescript')
|
||||
const api = {}
|
||||
vm.runInNewContext(ts.transpileModule(fs.readFileSync(require.resolve('../src/renderer/src/features/workspace/WorkspaceEditorPane.tsx'), 'utf8'), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.ReactJSX, esModuleInterop: true } }).outputText, {
|
||||
exports: api,
|
||||
require: id => id === '../../i18n' ? { t: value => value, useLocaleRender() {} }
|
||||
: id === '@monaco-editor/react' ? { __esModule: true, default: 'Editor', DiffEditor: 'DiffEditor' }
|
||||
: id === 'lucide-react' ? {} : require(id)
|
||||
})
|
||||
const props = { dark: true, textDim: '', editorPaneRef: { current: null }, currentActiveEditorFile: 'config/control.yaml', activeFileIsImage: false, editorLanguage: 'yaml', editorValue: 'steering: ackermann', fontSize: 12, tabSize: 4, minimapEnabled: false, exampleActive: false, beforeMount() {}, onMount() {}, onChange() {} }
|
||||
for (const locked of [false, true]) {
|
||||
test(`the source editor is read-only only while an agent file batch is applying (locked=${locked})`, () => {
|
||||
const tree = api.default({ ...props, editingLocked: locked })
|
||||
assert.equal(tree.props.children.type, 'Editor')
|
||||
assert.equal(tree.props.children.props.options.readOnly, locked)
|
||||
})
|
||||
}
|
||||
test('agent diff previews remain read-only and set tab width through text models', () => {
|
||||
const tree = api.default({ ...props, diffPreview: { id: 'diff', originalContent: 'old', modifiedContent: 'new' } })
|
||||
const diff = tree.props.children
|
||||
assert.equal(diff.type, 'DiffEditor')
|
||||
assert.equal(diff.props.options.readOnly, true)
|
||||
assert.equal('tabSize' in diff.props.options, false)
|
||||
const updates = []
|
||||
const editor = { getModel: () => ({ updateOptions: options => updates.push(options.tabSize) }) }
|
||||
diff.props.onMount({ getOriginalEditor: () => editor, getModifiedEditor: () => editor })
|
||||
assert.deepEqual(updates, [4, 4])
|
||||
})
|
||||
Reference in New Issue
Block a user