Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

feat(studio): sketch/build mode toggle, progress bar, GFM table rendering

FABIOTESS234bdc5e072b
diff --git a/studio/package-lock.json b/studio/package-lock.json
index 314b66b3..145f02b7 100644
--- a/studio/package-lock.json
+++ b/studio/package-lock.json
@@ -19,6 +19,7 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-markdown": "^10.1.0",
+ "remark-gfm": "^4.0.1",
"tailwindcss": "^4.2.1",
"three": "^0.183.2",
"zustand": "^5.0.11"
@@ -2867,6 +2868,18 @@
"node": ">=6"
}
},
+ "node_modules/escape-string-regexp": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
+ "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/estree-util-is-identifier-name": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz",
@@ -3430,6 +3443,32 @@
"@jridgewell/sourcemap-codec": "^1.5.5"
}
},
+ "node_modules/markdown-table": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz",
+ "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
+ "node_modules/mdast-util-find-and-replace": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz",
+ "integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "escape-string-regexp": "^5.0.0",
+ "unist-util-is": "^6.0.0",
+ "unist-util-visit-parents": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/mdast-util-from-markdown": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz",
@@ -3454,6 +3493,107 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/mdast-util-gfm": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz",
+ "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==",
+ "license": "MIT",
+ "dependencies": {
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-gfm-autolink-literal": "^2.0.0",
+ "mdast-util-gfm-footnote": "^2.0.0",
+ "mdast-util-gfm-strikethrough": "^2.0.0",
+ "mdast-util-gfm-table": "^2.0.0",
+ "mdast-util-gfm-task-list-item": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-autolink-literal": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz",
+ "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "ccount": "^2.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-find-and-replace": "^3.0.0",
+ "micromark-util-character": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-footnote": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz",
+ "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.1.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-strikethrough": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz",
+ "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-table": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz",
+ "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "markdown-table": "^3.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-task-list-item": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz",
+ "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/mdast-util-mdx-expression": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz",
@@ -3652,6 +3792,127 @@
"micromark-util-types": "^2.0.0"
}
},
+ "node_modules/micromark-extension-gfm": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz",
+ "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-extension-gfm-autolink-literal": "^2.0.0",
+ "micromark-extension-gfm-footnote": "^2.0.0",
+ "micromark-extension-gfm-strikethrough": "^2.0.0",
+ "micromark-extension-gfm-table": "^2.0.0",
+ "micromark-extension-gfm-tagfilter": "^2.0.0",
+ "micromark-extension-gfm-task-list-item": "^2.0.0",
+ "micromark-util-combine-extensions": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-autolink-literal": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz",
+ "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-sanitize-uri": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-footnote": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz",
+ "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-core-commonmark": "^2.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0",
+ "micromark-util-sanitize-uri": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-strikethrough": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz",
+ "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-classify-character": "^2.0.0",
+ "micromark-util-resolve-all": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-table": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz",
+ "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-tagfilter": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz",
+ "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-task-list-item": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz",
+ "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/micromark-factory-destination": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
@@ -4255,6 +4516,24 @@
"node": ">=0.10.0"
}
},
+ "node_modules/remark-gfm": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",
+ "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-gfm": "^3.0.0",
+ "micromark-extension-gfm": "^3.0.0",
+ "remark-parse": "^11.0.0",
+ "remark-stringify": "^11.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/remark-parse": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz",
@@ -4288,6 +4567,21 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/remark-stringify": {
+ "version": "11.0.0",
+ "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz",
+ "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-to-markdown": "^2.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/robust-predicates": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz",
diff --git a/studio/package.json b/studio/package.json
index 2c343117..8e3d3751 100644
--- a/studio/package.json
+++ b/studio/package.json
@@ -21,6 +21,7 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-markdown": "^10.1.0",
+ "remark-gfm": "^4.0.1",
"tailwindcss": "^4.2.1",
"three": "^0.183.2",
"zustand": "^5.0.11"
diff --git a/studio/src-tauri/sidecars/agent/dist/index.js b/studio/src-tauri/sidecars/agent/dist/index.js
index 699f55f5..8fc774f3 100644
--- a/studio/src-tauri/sidecars/agent/dist/index.js
+++ b/studio/src-tauri/sidecars/agent/dist/index.js
@@ -250,8 +250,10 @@ Report the final ontology statistics.`,
},
];
send({ type: 'text', content: `**Building maximum-depth ontology: ${domain}** (${steps.length} steps)\n` });
+ send({ type: 'progress', step: 0, total: steps.length, label: 'Starting build...' });
for (let i = 0; i < steps.length; i++) {
const step = steps[i];
+ send({ type: 'progress', step: i + 1, total: steps.length, label: step.label });
send({ type: 'text', content: `\n---\n**${step.label}**` });
try {
await runTurn(step.prompt);
@@ -260,6 +262,7 @@ Report the final ontology statistics.`,
send({ type: 'text', content: `Step failed: ${e}. Continuing...` });
}
}
+ send({ type: 'progress', step: steps.length, total: steps.length, label: 'Build complete' });
send({ type: 'text', content: `\n---\n**Build complete.** The graph should now be visible in the tree view.` });
}
// --- Quick sketch: 3-step lightweight build ---
@@ -293,8 +296,10 @@ Call onto_stats after. Do NOT save yet.`,
},
];
send({ type: 'text', content: `**Sketching ontology: ${domain}** (3 steps)\n` });
+ send({ type: 'progress', step: 0, total: steps.length, label: 'Starting sketch...' });
for (let i = 0; i < steps.length; i++) {
const step = steps[i];
+ send({ type: 'progress', step: i + 1, total: steps.length, label: step.label });
send({ type: 'text', content: `\n---\n**${step.label}**` });
try {
await runTurn(step.prompt);
@@ -303,21 +308,22 @@ Call onto_stats after. Do NOT save yet.`,
send({ type: 'text', content: `Step failed: ${e}. Continuing...` });
}
}
+ send({ type: 'progress', step: steps.length, total: steps.length, label: 'Sketch complete' });
send({ type: 'text', content: `\n---\n**Sketch complete.** Use /expand to deepen any branch.` });
}
// --- Handle a chat message ---
-async function handleMessage(userMessage) {
+async function handleMessage(userMessage, mode = 'sketch') {
try {
- if (isSketchRequest(userMessage)) {
+ const isBuildLike = isBuildRequest(userMessage) || isSketchRequest(userMessage);
+ if (isBuildLike) {
const domain = extractDomain(userMessage);
sessionId = undefined;
- await handleSketch(domain);
- send({ type: 'done', mutated: true });
- }
- else if (isBuildRequest(userMessage)) {
- const domain = extractDomain(userMessage);
- sessionId = undefined;
- await handleBuild(domain);
+ if (mode === 'sketch') {
+ await handleSketch(domain);
+ }
+ else {
+ await handleBuild(domain);
+ }
send({ type: 'done', mutated: true });
}
else {
@@ -342,7 +348,7 @@ async function main() {
try {
const msg = JSON.parse(line);
if (msg.type === 'chat') {
- await handleMessage(msg.message);
+ await handleMessage(msg.message, msg.mode || 'sketch');
}
else if (msg.type === 'reset') {
sessionId = undefined;
diff --git a/studio/src-tauri/sidecars/agent/index.ts b/studio/src-tauri/sidecars/agent/index.ts
index 287282a2..63fd92a9 100644
--- a/studio/src-tauri/sidecars/agent/index.ts
+++ b/studio/src-tauri/sidecars/agent/index.ts
@@ -270,9 +270,11 @@ Report the final ontology statistics.`,
];
send({ type: 'text', content: `**Building maximum-depth ontology: ${domain}** (${steps.length} steps)\n` });
+ send({ type: 'progress', step: 0, total: steps.length, label: 'Starting build...' });
for (let i = 0; i < steps.length; i++) {
const step = steps[i];
+ send({ type: 'progress', step: i + 1, total: steps.length, label: step.label });
send({ type: 'text', content: `\n---\n**${step.label}**` });
try {
await runTurn(step.prompt);
@@ -281,6 +283,7 @@ Report the final ontology statistics.`,
}
}
+ send({ type: 'progress', step: steps.length, total: steps.length, label: 'Build complete' });
send({ type: 'text', content: `\n---\n**Build complete.** The graph should now be visible in the tree view.` });
}
@@ -318,9 +321,11 @@ Call onto_stats after. Do NOT save yet.`,
];
send({ type: 'text', content: `**Sketching ontology: ${domain}** (3 steps)\n` });
+ send({ type: 'progress', step: 0, total: steps.length, label: 'Starting sketch...' });
for (let i = 0; i < steps.length; i++) {
const step = steps[i];
+ send({ type: 'progress', step: i + 1, total: steps.length, label: step.label });
send({ type: 'text', content: `\n---\n**${step.label}**` });
try {
await runTurn(step.prompt);
@@ -329,22 +334,23 @@ Call onto_stats after. Do NOT save yet.`,
}
}
+ send({ type: 'progress', step: steps.length, total: steps.length, label: 'Sketch complete' });
send({ type: 'text', content: `\n---\n**Sketch complete.** Use /expand to deepen any branch.` });
}
// --- Handle a chat message ---
-async function handleMessage(userMessage: string): Promise<void> {
+async function handleMessage(userMessage: string, mode: 'sketch' | 'build' = 'sketch'): Promise<void> {
try {
- if (isSketchRequest(userMessage)) {
+ const isBuildLike = isBuildRequest(userMessage) || isSketchRequest(userMessage);
+ if (isBuildLike) {
const domain = extractDomain(userMessage);
sessionId = undefined;
- await handleSketch(domain);
- send({ type: 'done', mutated: true });
- } else if (isBuildRequest(userMessage)) {
- const domain = extractDomain(userMessage);
- sessionId = undefined;
- await handleBuild(domain);
+ if (mode === 'sketch') {
+ await handleSketch(domain);
+ } else {
+ await handleBuild(domain);
+ }
send({ type: 'done', mutated: true });
} else {
const mutated = await runTurn(userMessage);
@@ -370,7 +376,7 @@ async function main(): Promise<void> {
try {
const msg = JSON.parse(line);
if (msg.type === 'chat') {
- await handleMessage(msg.message);
+ await handleMessage(msg.message, msg.mode || 'sketch');
} else if (msg.type === 'reset') {
sessionId = undefined;
send({ type: 'reset_done' });
diff --git a/studio/src-tauri/src/chat.rs b/studio/src-tauri/src/chat.rs
index f522b85a..8cc3bb35 100644
--- a/studio/src-tauri/src/chat.rs
+++ b/studio/src-tauri/src/chat.rs
@@ -49,12 +49,12 @@ pub fn spawn_agent_sidecar(app: &tauri::AppHandle) -> Result<(), String> {
}
#[tauri::command]
-pub fn send_chat_message(message: String, state: tauri::State<ChatState>) -> Result<(), String> {
+pub fn send_chat_message(message: String, mode: String, state: tauri::State<ChatState>) -> Result<(), String> {
let mut guard = state.process.lock().map_err(|e| format!("Lock error: {e}"))?;
let child = guard.as_mut().ok_or("Agent sidecar not running")?;
let stdin = child.stdin.as_mut().ok_or("No stdin")?;
- let payload = serde_json::json!({ "type": "chat", "message": message });
+ let payload = serde_json::json!({ "type": "chat", "message": message, "mode": mode });
writeln!(stdin, "{}", payload).map_err(|e| format!("Write failed: {e}"))?;
stdin.flush().map_err(|e| format!("Flush failed: {e}"))?;
diff --git a/studio/src/components/ChatPanel.tsx b/studio/src/components/ChatPanel.tsx
index 5ec4ea72..11f81a31 100644
--- a/studio/src/components/ChatPanel.tsx
+++ b/studio/src/components/ChatPanel.tsx
@@ -1,6 +1,7 @@
import { useState, useRef, useEffect, useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
-import { useChat, ChatMessage } from '../hooks/useChat';
+import remarkGfm from 'remark-gfm';
+import { useChat, ChatMessage, BuildMode } from '../hooks/useChat';
const SLASH_COMMANDS = [
{ cmd: '/build', description: 'Deep build (IES-level)', prompt: 'Build an ontology about ' },
@@ -24,7 +25,7 @@ const STARTER_CHIPS = [
];
export function ChatPanel() {
- const { messages, isTyping, sendMessage, reset } = useChat();
+ const { messages, isTyping, sendMessage, reset, mode, setMode, progress } = useChat();
const [input, setInput] = useState('');
const [showSlash, setShowSlash] = useState(false);
const scrollRef = useRef<HTMLDivElement>(null);
@@ -56,10 +57,26 @@ export function ChatPanel() {
<div className="flex items-center justify-between px-3 py-2 border-b"
style={{ borderColor: 'var(--border)' }}>
<span className="text-sm font-medium" style={{ color: 'var(--text-primary)' }}>Chat</span>
- <button onClick={reset} className="text-xs px-2 py-0.5 rounded"
- style={{ color: 'var(--text-secondary)', background: 'var(--bg-panel)' }}>
- Reset
- </button>
+ <div className="flex items-center gap-2">
+ <div className="flex items-center rounded-full text-xs"
+ style={{ background: 'var(--bg-panel)', border: '1px solid var(--border)' }}>
+ {(['sketch', 'build'] as BuildMode[]).map((m) => (
+ <button key={m}
+ onClick={() => setMode(m)}
+ className="px-2.5 py-0.5 rounded-full capitalize transition-colors"
+ style={{
+ background: mode === m ? 'var(--accent)' : 'transparent',
+ color: mode === m ? 'var(--bg-primary)' : 'var(--text-secondary)',
+ }}>
+ {m}
+ </button>
+ ))}
+ </div>
+ <button onClick={reset} className="text-xs px-2 py-0.5 rounded"
+ style={{ color: 'var(--text-secondary)', background: 'var(--bg-panel)' }}>
+ Reset
+ </button>
+ </div>
</div>
<div ref={scrollRef} className="flex-1 overflow-y-auto p-3 space-y-3">
@@ -85,7 +102,20 @@ export function ChatPanel() {
<MessageBubble key={msg.id} message={msg} />
))}
- {isTyping && (
+ {progress && (
+ <div className="px-3 py-2 space-y-1">
+ <div className="flex justify-between text-xs" style={{ color: 'var(--text-secondary)' }}>
+ <span>{progress.label}</span>
+ <span>{Math.round((progress.step / progress.total) * 100)}%</span>
+ </div>
+ <div className="w-full h-1.5 rounded-full overflow-hidden" style={{ background: 'var(--bg-panel)' }}>
+ <div className="h-full rounded-full transition-all duration-500"
+ style={{ width: `${(progress.step / progress.total) * 100}%`, background: 'var(--accent)' }} />
+ </div>
+ </div>
+ )}
+
+ {isTyping && !progress && (
<div className="flex gap-1 px-3 py-2" style={{ color: 'var(--text-secondary)' }}>
<span className="animate-pulse">.</span>
<span className="animate-pulse" style={{ animationDelay: '0.2s' }}>.</span>
@@ -145,7 +175,7 @@ function MessageBubble({ message }: { message: ChatMessage }) {
{isUser || isSystem
? <div className="whitespace-pre-wrap">{message.content}</div>
: <div className="prose prose-sm max-w-none markdown-body">
- <ReactMarkdown>{message.content}</ReactMarkdown>
+ <ReactMarkdown remarkPlugins={[remarkGfm]}>{message.content}</ReactMarkdown>
</div>
}
{message.toolCalls && message.toolCalls.length > 0 && (
diff --git a/studio/src/hooks/useChat.ts b/studio/src/hooks/useChat.ts
index 363ddddb..371300c2 100644
--- a/studio/src/hooks/useChat.ts
+++ b/studio/src/hooks/useChat.ts
@@ -20,9 +20,20 @@ export interface ChatMessage {
timestamp: Date;
}
+export type BuildMode = 'sketch' | 'build';
+
+export interface Progress {
+ step: number;
+ total: number;
+ label: string;
+}
+
interface ChatStore {
messages: ChatMessage[];
isTyping: boolean;
+ mode: BuildMode;
+ progress: Progress | null;
+ setMode: (mode: BuildMode) => void;
sendMessage: (text: string) => Promise<void>;
reset: () => Promise<void>;
}
@@ -37,6 +48,9 @@ export const useChat = create<ChatStore>((set) => ({
timestamp: new Date(),
}],
isTyping: false,
+ mode: 'sketch' as BuildMode,
+ progress: null,
+ setMode: (mode: BuildMode) => set({ mode }),
sendMessage: async (text: string) => {
const userMsg: ChatMessage = {
@@ -47,7 +61,8 @@ export const useChat = create<ChatStore>((set) => ({
};
set(s => ({ messages: [...s.messages, userMsg], isTyping: true }));
try {
- await invoke('send_chat_message', { message: text });
+ const { mode } = useChat.getState();
+ await invoke('send_chat_message', { message: text, mode });
} catch (e) {
set(s => ({
messages: [...s.messages, {
@@ -143,9 +158,13 @@ listen<string>('agent-message', (event) => {
if (isMutation(data.tool || '')) triggerGraphRefresh(300);
}
+ if (data.type === 'progress') {
+ useChat.setState({ progress: { step: data.step, total: data.total, label: data.label } });
+ }
+
if (data.type === 'done') {
currentAssistantMsg = null;
- useChat.setState({ isTyping: false });
+ useChat.setState({ isTyping: false, progress: null });
if (data.mutated) {
// Persist to file, then refresh graph
mcp.saveGraphToFile().then(() => triggerGraphRefresh(300));