Multiplayer agent harness for work.
Preview Markdown, tables and text attachments in app (#2010)
Regan Bell2859da0cb174
diff --git a/plugins/web-ui/package-lock.json b/plugins/web-ui/package-lock.jsonindex 549d76ad9..4da8cedd8 100644--- a/plugins/web-ui/package-lock.json+++ b/plugins/web-ui/package-lock.json@@ -8,10 +8,16 @@"name": "qm-web-ui-plugin","version": "0.1.0","dependencies": {+ "@codemirror/language": "6.12.4",+ "@codemirror/language-data": "6.5.2",+ "@codemirror/search": "6.7.2",+ "@codemirror/state": "6.7.6",+ "@codemirror/view": "6.43.13","@date-fns/tz": "^1.5.0","@earendil-works/pi-agent-core": "0.77.0","@earendil-works/pi-ai": "0.77.0","@earendil-works/pi-web-ui": "0.75.3",+ "@lezer/highlight": "1.2.4","@mariozechner/mini-lit": "^0.2.0","@sentry/browser": "10.75.0","@sentry/node": "10.75.0",@@ -27,11 +33,13 @@"marked": "^18.0.5","mermaid": "^12.0.0","morphdom": "2.7.8",+ "papaparse": "5.7.0","posthog-js": "1.433.10"},"devDependencies": {"@types/jsdom": "^28.0.3","@types/node": "^24.0.0",+ "@types/papaparse": "5.5.2","jsdom": "^29.1.1","katex": "^0.16.47","typescript": "^5.8.2",@@ -655,6 +663,406 @@"integrity": "sha512-4mudFAQ6H+MqBTfqLmU7G1ZwRzCLfJEooL/fsF6rCX5eePMbGhoy5n4g+G4vlh2muDcsCTJtL+uKbOzWxs5LHA==","license": "Apache-2.0"},+ "node_modules/@codemirror/autocomplete": {+ "version": "6.20.3",+ "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz",+ "integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.17.0",+ "@lezer/common": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-angular": {+ "version": "0.1.4",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-angular/-/lang-angular-0.1.4.tgz",+ "integrity": "sha512-oap+gsltb/fzdlTQWD6BFF4bSLKcDnlxDsLdePiJpCVNKWXSTAbiiQeYI3UmES+BLAdkmIC1WjyztC1pi/bX4g==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/lang-javascript": "^6.1.2",+ "@codemirror/language": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.3.3"+ }+ },+ "node_modules/@codemirror/lang-cpp": {+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-cpp/-/lang-cpp-6.0.3.tgz",+ "integrity": "sha512-URM26M3vunFFn9/sm6rzqrBzDgfWuDixp85uTY49wKudToc2jTHUrKIGGKs+QWND+YLofNNZpxcNGRynFJfvgA==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@lezer/cpp": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-css": {+ "version": "6.3.1",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",+ "integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.0.2",+ "@lezer/css": "^1.1.7"+ }+ },+ "node_modules/@codemirror/lang-go": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-go/-/lang-go-6.0.1.tgz",+ "integrity": "sha512-7fNvbyNylvqCphW9HD6WFnRpcDjr+KXX/FgqXy5H5ZS0eC5edDljukm/yNgYkwTsgp2busdod50AOTIy6Jikfg==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.6.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.0.0",+ "@lezer/go": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-html": {+ "version": "6.4.12",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.12.tgz",+ "integrity": "sha512-pw2ReWKUqSkbvh76RAT4NYxiogRu+PWkR2ukAwO9uOgrm8uipkzjtKKtNpyeAQwHOqxEeSvAXZ6vr3AfyB9y/w==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/lang-css": "^6.0.0",+ "@codemirror/lang-javascript": "^6.0.0",+ "@codemirror/language": "^6.4.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.17.0",+ "@lezer/common": "^1.0.0",+ "@lezer/css": "^1.1.0",+ "@lezer/html": "^1.3.12"+ }+ },+ "node_modules/@codemirror/lang-java": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-java/-/lang-java-6.0.2.tgz",+ "integrity": "sha512-m5Nt1mQ/cznJY7tMfQTJchmrjdjQ71IDs+55d1GAa8DGaB8JXWsVCkVT284C3RTASaY43YknrK2X3hPO/J3MOQ==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@lezer/java": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-javascript": {+ "version": "6.2.5",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz",+ "integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.6.0",+ "@codemirror/lint": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.17.0",+ "@lezer/common": "^1.0.0",+ "@lezer/javascript": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-javascript/node_modules/@lezer/javascript": {+ "version": "1.5.5",+ "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.5.tgz",+ "integrity": "sha512-sWg4yX1J6XW67AaAynVt0iwF0M5c+np36TEu+P2ifAJ8haRYvHnWDV28r1jdwnJehWCwXECutAUy56K4RBZIyg==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.1.3",+ "@lezer/lr": "^1.3.0"+ }+ },+ "node_modules/@codemirror/lang-jinja": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-jinja/-/lang-jinja-6.0.1.tgz",+ "integrity": "sha512-P5kyHLObzjtbGj16h+hyvZTxJhSjBEeSx4wMjbnAf3b0uwTy2+F0zGjMZL4PQOm/mh2eGZ5xUDVZXgwP783Nsw==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.2.0",+ "@lezer/lr": "^1.4.0"+ }+ },+ "node_modules/@codemirror/lang-json": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz",+ "integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@lezer/json": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-less": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-less/-/lang-less-6.0.2.tgz",+ "integrity": "sha512-EYdQTG22V+KUUk8Qq582g7FMnCZeEHsyuOJisHRft/mQ+ZSZ2w51NupvDUHiqtsOy7It5cHLPGfHQLpMh9bqpQ==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-css": "^6.2.0",+ "@codemirror/language": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-markdown": {+ "version": "6.5.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.2.tgz",+ "integrity": "sha512-AwBOdkWYuA//WcM0xO5PfHPUcmz/O2i5o0Nsg1U69SII/loCJlFI1Romd9xp2HYb1kYJRGZotyqRghuHH5n8Kw==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.7.1",+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/language": "^6.3.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.0.0",+ "@lezer/common": "^1.2.1",+ "@lezer/markdown": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-php": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-php/-/lang-php-6.0.2.tgz",+ "integrity": "sha512-ZKy2v1n8Fc8oEXj0Th0PUMXzQJ0AIR6TaZU+PbDHExFwdu+guzOA4jmCHS1Nz4vbFezwD7LyBdDnddSJeScMCA==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.0.0",+ "@lezer/php": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-python": {+ "version": "6.2.1",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-python/-/lang-python-6.2.1.tgz",+ "integrity": "sha512-IRjC8RUBhn9mGR9ywecNhB51yePWCGgvHfY1lWN/Mrp3cKuHr0isDKia+9HnvhiWNnMpbGhWrkhuWOc09exRyw==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.3.2",+ "@codemirror/language": "^6.8.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.2.1",+ "@lezer/python": "^1.1.4"+ }+ },+ "node_modules/@codemirror/lang-rust": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.2.tgz",+ "integrity": "sha512-EZaGjCUegtiU7kSMvOfEZpaCReowEf3yNidYu7+vfuGTm9ow4mthAparY5hisJqOHmJowVH3Upu+eJlUji6qqA==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@lezer/rust": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-sass": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-sass/-/lang-sass-6.0.2.tgz",+ "integrity": "sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-css": "^6.2.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.0.2",+ "@lezer/sass": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-sql": {+ "version": "6.10.0",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.10.0.tgz",+ "integrity": "sha512-6ayPkEd/yRw0XKBx5uAiToSgGECo/GY2NoJIHXIIQh1EVwLuKoU8BP/qK0qH5NLXAbtJRLuT73hx7P9X34iO4w==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-vue": {+ "version": "0.1.3",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-vue/-/lang-vue-0.1.3.tgz",+ "integrity": "sha512-QSKdtYTDRhEHCfo5zOShzxCmqKJvgGrZwDQSdbvCRJ5pRLWBS7pD/8e/tH44aVQT6FKm0t6RVNoSUWHOI5vNug==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/lang-javascript": "^6.1.2",+ "@codemirror/language": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.3.1"+ }+ },+ "node_modules/@codemirror/lang-wast": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-wast/-/lang-wast-6.0.2.tgz",+ "integrity": "sha512-Imi2KTpVGm7TKuUkqyJ5NRmeFWF7aMpNiwHnLQe0x9kmrxElndyH0K6H/gXtWwY6UshMRAhpENsgfpSwsgmC6Q==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-xml": {+ "version": "6.1.0",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.1.0.tgz",+ "integrity": "sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.4.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.0.0",+ "@lezer/common": "^1.0.0",+ "@lezer/xml": "^1.0.0"+ }+ },+ "node_modules/@codemirror/lang-yaml": {+ "version": "6.1.3",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-yaml/-/lang-yaml-6.1.3.tgz",+ "integrity": "sha512-AZ8DJBuXGVHybpBQhmZtgew5//4hv3tdkXnr3vDmOUMJRuB6vn/uuwtmTOTlqEaQFg3hQSVeA90NmvIQyUV6FQ==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.2.0",+ "@lezer/lr": "^1.0.0",+ "@lezer/yaml": "^1.0.0"+ }+ },+ "node_modules/@codemirror/language": {+ "version": "6.12.4",+ "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz",+ "integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.23.0",+ "@lezer/common": "^1.5.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0",+ "style-mod": "^4.0.0"+ }+ },+ "node_modules/@codemirror/language-data": {+ "version": "6.5.2",+ "resolved": "https://registry.npmjs.org/@codemirror/language-data/-/language-data-6.5.2.tgz",+ "integrity": "sha512-CPkWBKrNS8stYbEU5kwBwTf3JB1kghlbh4FSAwzGW2TEscdeHHH4FGysREW86Mqnj3Qn09s0/6Ea/TutmoTobg==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/lang-angular": "^0.1.0",+ "@codemirror/lang-cpp": "^6.0.0",+ "@codemirror/lang-css": "^6.0.0",+ "@codemirror/lang-go": "^6.0.0",+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/lang-java": "^6.0.0",+ "@codemirror/lang-javascript": "^6.0.0",+ "@codemirror/lang-jinja": "^6.0.0",+ "@codemirror/lang-json": "^6.0.0",+ "@codemirror/lang-less": "^6.0.0",+ "@codemirror/lang-liquid": "^6.0.0",+ "@codemirror/lang-markdown": "^6.0.0",+ "@codemirror/lang-php": "^6.0.0",+ "@codemirror/lang-python": "^6.0.0",+ "@codemirror/lang-rust": "^6.0.0",+ "@codemirror/lang-sass": "^6.0.0",+ "@codemirror/lang-sql": "^6.0.0",+ "@codemirror/lang-vue": "^0.1.1",+ "@codemirror/lang-wast": "^6.0.0",+ "@codemirror/lang-xml": "^6.0.0",+ "@codemirror/lang-yaml": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/legacy-modes": "^6.4.0"+ }+ },+ "node_modules/@codemirror/language-data/node_modules/@codemirror/lang-liquid": {+ "version": "6.3.2",+ "resolved": "https://registry.npmjs.org/@codemirror/lang-liquid/-/lang-liquid-6.3.2.tgz",+ "integrity": "sha512-6PDVU3ZnfeYyz1at1E/ttorErZvZFXXt1OPhtfe1EZJ2V2iDFa0CwPqPgG5F7NXN0yONGoBogKmFAafKTqlwIw==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/autocomplete": "^6.0.0",+ "@codemirror/lang-html": "^6.0.0",+ "@codemirror/language": "^6.0.0",+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.0.0",+ "@lezer/common": "^1.0.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.3.1"+ }+ },+ "node_modules/@codemirror/legacy-modes": {+ "version": "6.5.4",+ "resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.4.tgz",+ "integrity": "sha512-/cZr6qZyl08iYNLGsJ862CXXNI51LryRFRE40ejgoIjXZz0C1rGkD3/Ek5jM/8w1ceRjqtt4qx/KLMh4zBTgew==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/language": "^6.0.0"+ }+ },+ "node_modules/@codemirror/lint": {+ "version": "6.9.7",+ "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",+ "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.42.0",+ "crelt": "^1.0.5"+ }+ },+ "node_modules/@codemirror/search": {+ "version": "6.7.2",+ "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.2.tgz",+ "integrity": "sha512-gUYkYhT2+n/+VGZ+8EzE5WFkYZUZYm1VOKDudIsNqh42uRVQJ0a6Yss9sdKT3MeOYfuL1N6AZA57oza0Oyr0LA==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/state": "^6.0.0",+ "@codemirror/view": "^6.37.0",+ "crelt": "^1.0.5"+ }+ },+ "node_modules/@codemirror/state": {+ "version": "6.7.6",+ "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz",+ "integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==",+ "license": "MIT",+ "dependencies": {+ "@marijn/find-cluster-break": "^1.0.0"+ }+ },+ "node_modules/@codemirror/view": {+ "version": "6.43.13",+ "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.13.tgz",+ "integrity": "sha512-sihaFrUzAsYBQsL9J2t69y8nfMQGwcYmggAZsk+kjPbjYZMyuf2hU8tUNTZ+P+isb6XRr8JE22TZlJxBoVdH1A==",+ "license": "MIT",+ "dependencies": {+ "@codemirror/state": "^6.7.0",+ "crelt": "^1.0.6",+ "style-mod": "^4.1.0",+ "w3c-keyname": "^2.2.4"+ }+ },"node_modules/@csstools/color-helpers": {"version": "6.1.0","resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.0.tgz",@@ -1390,6 +1798,172 @@"import-meta-resolve": "^4.2.0"}},+ "node_modules/@lezer/common": {+ "version": "1.5.3",+ "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.3.tgz",+ "integrity": "sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==",+ "license": "MIT"+ },+ "node_modules/@lezer/cpp": {+ "version": "1.1.6",+ "resolved": "https://registry.npmjs.org/@lezer/cpp/-/cpp-1.1.6.tgz",+ "integrity": "sha512-vh9gWWJOXFVY8HBHK3Twzq8MgwG2iN4GSyzBP9sCGTe37P15x2R14VaBQk0VA0ezTRN1KHYBBsHhvpGZ2Xy/pA==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/css": {+ "version": "1.3.8",+ "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.8.tgz",+ "integrity": "sha512-EJn1zcL9qoDptief6ipWKZKLiOpXkxSe0+t8CH9oiMVcZlq7NBWrjCqnc/41EIjeo/ITj1gFFiATdTkaJDL+Og==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.3.0"+ }+ },+ "node_modules/@lezer/go": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/@lezer/go/-/go-1.0.1.tgz",+ "integrity": "sha512-xToRsYxwsgJNHTgNdStpcvmbVuKxTapV0dM0wey1geMMRc9aggoVyKgzYp41D2/vVOx+Ii4hmE206kvxIXBVXQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.3.0"+ }+ },+ "node_modules/@lezer/highlight": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.4.tgz",+ "integrity": "sha512-4UeRVFO0lsBaM7GA32zOqbmqNPme9jedo8Ey+5c5656MU3MLitMLIA8aCZTYjUMEpEsuSeXEm78Uea6Iq3bvSg==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.3.0"+ }+ },+ "node_modules/@lezer/html": {+ "version": "1.3.13",+ "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",+ "integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/java": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/@lezer/java/-/java-1.1.4.tgz",+ "integrity": "sha512-gQylJ2xHV2xXsVqtnAcJrcROvLZJaQiC0tR//+q0k961BxqvyYttusPkJ8d9T1fPDJKHJW2etUH8XbIn9jhVUg==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/json": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz",+ "integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/lr": {+ "version": "1.4.10",+ "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz",+ "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.0.0"+ }+ },+ "node_modules/@lezer/markdown": {+ "version": "1.7.2",+ "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.7.2.tgz",+ "integrity": "sha512-iTkYvoVcKt3WkeL7qUDyXHONZEwLio4wj8KTNi2dnjQEXBZKMV63BpQrPqfsM+OkvuRbiSTAcycYAsQzLhRNoQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.5.0",+ "@lezer/highlight": "^1.0.0"+ }+ },+ "node_modules/@lezer/php": {+ "version": "1.0.6",+ "resolved": "https://registry.npmjs.org/@lezer/php/-/php-1.0.6.tgz",+ "integrity": "sha512-QJ2xNXPmsm/Z3IpThq8fnJrEIVpxhsIoj6GZBW0JYEd/l9zxpJZW216X4fzqQY4vgpdGIumypvI4uQjd4tnYtw==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.1.0"+ }+ },+ "node_modules/@lezer/python": {+ "version": "1.1.19",+ "resolved": "https://registry.npmjs.org/@lezer/python/-/python-1.1.19.tgz",+ "integrity": "sha512-MhQIURHRytsNzP/YXnqpYKW6la6voAH3kyplTOOiCdjyFY6cWWGFVmYVdHIPrElqSDf4iCDktQCockB9FxuhzQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/rust": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.3.tgz",+ "integrity": "sha512-XxErOjZzQ7yJt1agUT4fu9qQvESZ3acgoxpPaPTPOiUx+duCjaVAtZGFIgphkHxlN05djdVAIOy/wItShMEjqQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/sass": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/@lezer/sass/-/sass-1.1.0.tgz",+ "integrity": "sha512-3mMGdCTUZ/84ArHOuXWQr37pnf7f+Nw9ycPUeKX+wu19b7pSMcZGLbaXwvD2APMBDOGxPmpK/O6S1v1EvLoqgQ==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/xml": {+ "version": "1.0.6",+ "resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.6.tgz",+ "integrity": "sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.0.0"+ }+ },+ "node_modules/@lezer/yaml": {+ "version": "1.0.4",+ "resolved": "https://registry.npmjs.org/@lezer/yaml/-/yaml-1.0.4.tgz",+ "integrity": "sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==",+ "license": "MIT",+ "dependencies": {+ "@lezer/common": "^1.2.0",+ "@lezer/highlight": "^1.0.0",+ "@lezer/lr": "^1.4.0"+ }+ },"node_modules/@lit-labs/ssr-dom-shim": {"version": "1.6.0","resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.6.0.tgz",@@ -1427,6 +2001,12 @@"zod-to-json-schema": "^3.22.5"}},+ "node_modules/@marijn/find-cluster-break": {+ "version": "1.0.4",+ "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.4.tgz",+ "integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==",+ "license": "MIT"+ },"node_modules/@mariozechner/mini-lit": {"version": "0.2.1","resolved": "https://registry.npmjs.org/@mariozechner/mini-lit/-/mini-lit-0.2.1.tgz",@@ -2975,6 +3555,16 @@"undici-types": "~7.16.0"}},+ "node_modules/@types/papaparse": {+ "version": "5.5.2",+ "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.5.2.tgz",+ "integrity": "sha512-gFnFp/JMzLHCwRf7tQHrNnfhN4eYBVYYI897CGX4MY1tzY9l2aLkVyx2IlKZ/SAqDbB3I1AOZW5gTMGGsqWliA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/node": "*"+ }+ },"node_modules/@types/retry": {"version": "0.12.0","resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz",@@ -3207,6 +3797,12 @@"layout-base": "^1.0.0"}},+ "node_modules/crelt": {+ "version": "1.0.7",+ "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",+ "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",+ "license": "MIT"+ },"node_modules/css-tree": {"version": "3.2.1","resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz",@@ -4650,6 +5246,12 @@"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==","license": "(MIT AND Zlib)"},+ "node_modules/papaparse": {+ "version": "5.7.0",+ "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.7.0.tgz",+ "integrity": "sha512-qBGxg/7Q3Kl9Wfhrz2Z74UnvnHTXLNG6jmKJFeBvP2+y4lV7So+7SR62+Zd47JvdrCkX+nDcnr0ObPzek/+6RA==",+ "license": "MIT"+ },"node_modules/parse5": {"version": "8.0.1","resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz",@@ -5065,6 +5667,12 @@],"license": "MIT"},+ "node_modules/style-mod": {+ "version": "4.1.4",+ "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.4.tgz",+ "integrity": "sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==",+ "license": "MIT"+ },"node_modules/stylis": {"version": "4.4.0","resolved": "https://registry.npmjs.org/stylis/-/stylis-4.4.0.tgz",@@ -5359,6 +5967,12 @@}}},+ "node_modules/w3c-keyname": {+ "version": "2.2.8",+ "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",+ "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",+ "license": "MIT"+ },"node_modules/w3c-xmlserializer": {"version": "5.0.0","resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",diff --git a/plugins/web-ui/package.json b/plugins/web-ui/package.jsonindex 1ace10dbf..2273440f6 100644--- a/plugins/web-ui/package.json+++ b/plugins/web-ui/package.json@@ -16,10 +16,16 @@"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.test.json --noEmit"},"dependencies": {+ "@codemirror/language": "6.12.4",+ "@codemirror/language-data": "6.5.2",+ "@codemirror/search": "6.7.2",+ "@codemirror/state": "6.7.6",+ "@codemirror/view": "6.43.13","@date-fns/tz": "^1.5.0","@earendil-works/pi-agent-core": "0.77.0","@earendil-works/pi-ai": "0.77.0","@earendil-works/pi-web-ui": "0.75.3",+ "@lezer/highlight": "1.2.4","@mariozechner/mini-lit": "^0.2.0","@sentry/browser": "10.75.0","@sentry/node": "10.75.0",@@ -35,11 +41,13 @@"marked": "^18.0.5","mermaid": "^12.0.0","morphdom": "2.7.8",+ "papaparse": "5.7.0","posthog-js": "1.433.10"},"devDependencies": {"@types/jsdom": "^28.0.3","@types/node": "^24.0.0",+ "@types/papaparse": "5.5.2","jsdom": "^29.1.1","katex": "^0.16.47","typescript": "^5.8.2",@@ -51,6 +59,9 @@},"@mariozechner/mini-lit": {"marked": "^18.0.5"- }+ },+ "@codemirror/lang-liquid": "6.3.2",+ "@lezer/highlight": "1.2.4",+ "@lezer/javascript": "1.5.5"}}diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.tsindex 9793e57a1..4f8210323 100644--- a/plugins/web-ui/src/chat.ts+++ b/plugins/web-ui/src/chat.ts@@ -3202,8 +3202,8 @@ export function createChatSurface(redrawTranscript();}- function fileChip(name: string, size?: number, href?: string): TemplateResult {- return chipBadge(Paperclip, name, size, href);+ function fileChip(name: string, size?: number, href?: string, mimetype?: string): TemplateResult {+ return chipBadge(Paperclip, name, size, href, false, mimetype);}function inlineHtmlName(name?: string, mimeType?: string): boolean {@@ -3339,7 +3339,7 @@ export function createChatSurface(}if (src) return inlineHtmlFrame(a.fileName, src, a.size, artifactHref);}- return fileChip(a.fileName, a.size, artifactHref ?? localContentUrl(a));+ return fileChip(a.fileName, a.size, artifactHref ?? localContentUrl(a), a.mimeType);}function deliveredFileBadge(file: DeliveredFile): TemplateResult {@@ -3352,7 +3352,7 @@ export function createChatSurface(/></a>`;}if (inlineHtmlName(file.name, file.mimetype)) return inlineHtmlFrame(file.name, href, file.sizeBytes, href);- return fileChip(file.name, file.sizeBytes, href);+ return fileChip(file.name, file.sizeBytes, href, file.mimetype);}function scrollToBottom(): void {diff --git a/plugins/web-ui/src/contexts.ts b/plugins/web-ui/src/contexts.tsindex 1f4cc8f5a..122b8bdac 100644--- a/plugins/web-ui/src/contexts.ts+++ b/plugins/web-ui/src/contexts.ts@@ -1,3 +1,4 @@+import { previewFile } from "./file-open.ts";import { peopleResults, type DirectoryMatch } from "./people-results";import { html, nothing, render, type TemplateResult } from "lit";import {@@ -901,6 +902,7 @@ function fileRow(f: ScopeFile): TemplateResult {? html`<aclass="context-resource-link"href=${fileContentUrl(f.id, f.name)}+ @click=${(event: MouseEvent) => previewFile(event, f.name, fileContentUrl(f.id, f.name), f.mimetype)}target="_blank"rel="noreferrer">Open</adiff --git a/plugins/web-ui/src/file-editor.ts b/plugins/web-ui/src/file-editor.tsnew file mode 100644index 000000000..74afe4cd8--- /dev/null+++ b/plugins/web-ui/src/file-editor.ts@@ -0,0 +1,56 @@+import { EditorState } from "@codemirror/state";+import { EditorView, lineNumbers, highlightSpecialChars, keymap } from "@codemirror/view";+import { HighlightStyle, foldGutter, LanguageDescription, syntaxHighlighting } from "@codemirror/language";+import { tags } from "@lezer/highlight";+import { languages } from "@codemirror/language-data";+import { search, searchKeymap } from "@codemirror/search";++export async function mountFileEditor(+ parent: HTMLElement,+ text: string,+ name: string,+ mime: string,+): Promise<() => void> {+ const language =+ LanguageDescription.matchFilename(languages, name) ??+ languages.find((entry) => entry.alias.includes(mime.replace(/^application\/(?:x-)?/, "")));+ const support = await language?.load().catch(() => undefined);+ if (!parent.isConnected) return () => {};+ const view = new EditorView({+ parent,+ state: EditorState.create({+ doc: text,+ extensions: [+ EditorState.readOnly.of(true),+ EditorView.editable.of(false),+ EditorView.contentAttributes.of({ "aria-label": `${name} contents`, tabindex: "0" }),+ lineNumbers(),+ highlightSpecialChars(),+ foldGutter(),+ syntaxHighlighting(+ HighlightStyle.define([+ { tag: [tags.keyword, tags.typeName], color: "var(--ultrafast-accent)" },+ { tag: [tags.string, tags.regexp], color: "var(--success)" },+ { tag: [tags.number, tags.bool, tags.atom], color: "var(--warning)" },+ { tag: [tags.propertyName, tags.function(tags.variableName)], color: "var(--markdown-link)" },+ { tag: tags.comment, color: "var(--muted-foreground)" },+ ]),+ ),+ search(),+ keymap.of(searchKeymap),+ EditorView.theme({+ "&": { height: "100%", color: "var(--foreground)", backgroundColor: "var(--background)" },+ ".cm-scroller": { overflow: "auto", fontFamily: "var(--font-mono)", fontSize: "var(--font-13)" },+ ".cm-gutters": {+ backgroundColor: "var(--muted)",+ color: "var(--muted-foreground)",+ borderColor: "var(--border)",+ },+ ".cm-panels": { backgroundColor: "var(--background)", color: "var(--foreground)" },+ }),+ ...(support ? [support] : []),+ ],+ }),+ });+ return () => view.destroy();+}diff --git a/plugins/web-ui/src/file-open.ts b/plugins/web-ui/src/file-open.tsnew file mode 100644index 000000000..38e2810bb--- /dev/null+++ b/plugins/web-ui/src/file-open.ts@@ -0,0 +1,25 @@+export function filePreviewKind(name: string, mimetype = ""): "markdown" | "csv" | "tsv" | "text" | null {+ const mime = mimetype.split(";", 1)[0].trim().toLowerCase();+ if (/\.(md|markdown)$/i.test(name) || mime === "text/markdown") return "markdown";+ if (/\.tsv$/i.test(name) || mime === "text/tab-separated-values") return "tsv";+ if (/\.csv$/i.test(name) || mime === "text/csv") return "csv";+ if (+ /\.(txt|text|log|json|jsonl|yaml|yml|toml|ini|cfg|conf|xml|html?|css|scss|less|js|jsx|mjs|cjs|ts|tsx|py|rb|go|rs|java|c|h|cpp|hpp|cs|swift|kt|sh|bash|zsh|sql|graphql|gql|vue|svelte|r|lua|php|pl|ex|exs|erl|clj|diff|patch)$/i.test(+ name,+ ) ||+ /^(Dockerfile|Makefile|\.gitignore|\.env)$/i.test(name) ||+ mime.startsWith("text/") ||+ /^application\/(json|[^/]+\+json|yaml|x-yaml|toml|xml|[^/]+\+xml|javascript|x-sh)$/.test(mime)+ )+ return "text";+ return null;+}++export function previewFile(event: MouseEvent, name: string, href: string, mimetype?: string): void {+ const kind = filePreviewKind(name, mimetype);+ if (!kind || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;+ event.preventDefault();+ void import("./file-viewer.ts")+ .then(({ openFileViewer }) => openFileViewer(name, href, kind, mimetype))+ .catch(() => window.open(href, "_blank", "noopener,noreferrer"));+}diff --git a/plugins/web-ui/src/file-viewer.ts b/plugins/web-ui/src/file-viewer.tsnew file mode 100644index 000000000..2b7ec64f3--- /dev/null+++ b/plugins/web-ui/src/file-viewer.ts@@ -0,0 +1,132 @@+import { html, nothing, render } from "lit";+import { X } from "lucide";+import { webFetch } from "./core-bridge";+import { icon } from "./ui";+import { markdown } from "./message-markdown";+import { installMarkdownSanitizer } from "./markdown-sanitize";+import { errMessage } from "../../chassis/src/errors";+import type { filePreviewKind } from "./file-open";++const PREVIEW_LIMIT = 2 * 1024 * 1024;++export function openFileViewer(+ name: string,+ href: string,+ kind: NonNullable<ReturnType<typeof filePreviewKind>>,+ mimetype = "",+): void {+ const opener = document.activeElement as HTMLElement | null;+ const dialog = document.createElement("dialog");+ dialog.className = "project-dialog file-viewer";+ dialog.setAttribute("aria-label", name);+ const request = new AbortController();+ const content = document.createElement("div");+ content.className = "file-viewer-content";+ let destroyEditor: (() => void) | undefined;+ let text: string | null = null;+ let notice = "";+ let error = "";+ let copied = false;+ const close = () => dialog.close();+ dialog.addEventListener("close", () => {+ request.abort();+ destroyEditor?.();+ render(nothing, content);+ render(nothing, dialog);+ dialog.remove();+ if (opener?.isConnected) opener.focus();+ });+ dialog.addEventListener("click", (event) => {+ if (event.target !== dialog) return;+ const rect = dialog.getBoundingClientRect();+ if (+ event.clientX < rect.left ||+ event.clientX > rect.right ||+ event.clientY < rect.top ||+ event.clientY > rect.bottom+ )+ close();+ });+ const copy = async () => {+ try {+ await navigator.clipboard.writeText(text ?? "");+ copied = true;+ } catch {+ error = "Couldn't copy. Select the text to copy it manually.";+ }+ if (!request.signal.aborted) draw();+ };+ const draw = () =>+ render(+ html` <header class="file-viewer-head">+ <strong dir="auto">${name}</strong+ ><button class="icon-btn" aria-label="Close preview" @click=${close}>${icon(X, 18)}</button>+ </header>+ <div class="file-viewer-toolbar">+ <a class="btn" href=${href} download=${name}>Download</a+ ><button class="btn" ?disabled=${text === null} @click=${copy}>${copied ? "Copied" : "Copy"}</button>+ </div>+ ${notice ? html`<p class="file-viewer-notice muted" role="status">${notice}</p>` : nothing}+ ${error ? html`<p class="file-viewer-notice" role="alert">${error}</p>` : nothing} ${content}`,+ dialog,+ );+ installMarkdownSanitizer();+ document.body.append(dialog);+ render(html`<p class="muted">Loading…</p>`, content);+ draw();+ dialog.showModal();+ void (async () => {+ try {+ const response = await webFetch(href, { signal: request.signal });+ if (!response.ok) throw new Error(`Couldn't load this file (${response.status}).`);+ const blob = await response.blob();+ text = await blob.text();+ if (request.signal.aborted) return;+ if (blob.size > PREVIEW_LIMIT) {+ notice = "Files over 2 MB are shown as plain text.";+ render(html`<pre class="file-viewer-text">${text}</pre>`, content);+ } else if (kind === "markdown") {+ render(markdown(text), content);+ } else if (kind === "csv" || kind === "tsv") {+ const { default: Papa } = await import("papaparse");+ if (request.signal.aborted) return;+ const result = Papa.parse<string[]>(text, {+ delimiter: kind === "tsv" ? "\t" : ",",+ preview: 1001,+ skipEmptyLines: true,+ });+ if (result.meta.truncated || result.data.length > 1000 || result.data.some((row) => row.length > 100))+ notice = "Preview limited to 1,000 rows and 100 columns. Download for the full file.";+ if (result.errors.length)+ notice = [notice, "This file contains CSV formatting errors. Some cells may not display as intended."]+ .filter(Boolean)+ .join(" ");+ render(+ html`<table class="file-viewer-table">+ <tbody>+ ${result.data.slice(0, 1000).map(+ (row) =>+ html`<tr>+ ${row.slice(0, 100).map((cell) => html`<td>${cell}</td>`)}+ </tr>`,+ )}+ </tbody>+ </table>`,+ content,+ );+ } else {+ const { mountFileEditor } = await import("./file-editor");+ if (request.signal.aborted) return;+ render(nothing, content);+ content.classList.add("file-viewer-editor");+ destroyEditor = await mountFileEditor(content, text, name, mimetype.split(";", 1)[0]);+ if (request.signal.aborted) destroyEditor();+ }+ } catch (err) {+ if (request.signal.aborted) return;+ error = errMessage(err, "Couldn't load this file.");+ render(text === null ? nothing : html`<pre class="file-viewer-text">${text}</pre>`, content);+ }+ if (!request.signal.aborted) draw();+ })();+}diff --git a/plugins/web-ui/src/files.ts b/plugins/web-ui/src/files.tsindex 17853e92e..8bf117de8 100644--- a/plugins/web-ui/src/files.ts+++ b/plugins/web-ui/src/files.ts@@ -1,3 +1,4 @@+import { previewFile } from "./file-open.ts";import { html, nothing, render } from "lit";import {File,@@ -240,7 +241,14 @@ function fileRow(f: FileRow) {>`;return f.openable- ? html`<a class="list-row file-row" href=${contentUrl} target="_blank" rel="noreferrer">${content}</a>`+ ? html`<a+ class="list-row file-row"+ href=${contentUrl}+ target="_blank"+ rel="noreferrer"+ @click=${(event: MouseEvent) => previewFile(event, f.name, contentUrl, f.mimetype)}+ >${content}</a+ >`: html`<article class="list-row file-row">${content}</article>`;}diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.cssindex 2557f572f..418ea2bf4 100644--- a/plugins/web-ui/src/shell.css+++ b/plugins/web-ui/src/shell.css@@ -13224,3 +13224,58 @@ body.app-edit-embed .custom-chat-shell.app-edit-chat > .chat-bottom-dock {.loop-triage-none {color: var(--muted-foreground);}++.project-dialog.file-viewer {+ width: min(960px, calc(100vw - 32px));+ height: min(800px, calc(100dvh - 48px));+ padding: 0;+ overflow: hidden;+}+.file-viewer[open] {+ display: flex;+ flex-direction: column;+}+.file-viewer-head,+.file-viewer-toolbar {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 12px 20px;+ border-bottom: 1px solid var(--border);+}+.file-viewer-head strong {+ flex: 1;+ min-width: 0;+ overflow-wrap: anywhere;+}+.file-viewer-toolbar {+ flex-wrap: wrap;+}+.file-viewer-content {+ flex: 1;+ min-height: 0;+ overflow: auto;+ padding: 20px;+}+.file-viewer-content.file-viewer-editor {+ padding: 0;+}+.file-viewer-notice {+ margin: 8px 20px;+}+.file-viewer-text {+ white-space: pre-wrap;+ overflow-wrap: anywhere;+ font-family: var(--font-mono);+ font-size: var(--font-13);+}+.file-viewer-table {+ border-collapse: collapse;+ font-size: var(--font-13);+}+.file-viewer-table td {+ border: 1px solid var(--border);+ padding: 6px 10px;+ white-space: pre-wrap;+ min-width: 80px;+}diff --git a/plugins/web-ui/src/ui.ts b/plugins/web-ui/src/ui.tsindex 9a75aef8a..f9a381e98 100644--- a/plugins/web-ui/src/ui.ts+++ b/plugins/web-ui/src/ui.ts@@ -1,3 +1,4 @@+import { previewFile } from "./file-open.ts";import { unsafeSVG } from "lit/directives/unsafe-svg.js";import { html, nothing, type TemplateResult } from "lit";import { live } from "lit/directives/live.js";@@ -525,13 +526,20 @@ export function chipBadge(size?: number,href?: string,download = false,+ mimetype?: string,): TemplateResult {const inner = html`${icon(glyph, 14)}<span dir="auto">${name}</span>${typeof size === "number" ? html`<small>${formatBytes(size)}</small>` : nothing}`;if (!href) return html`<span class="file-chip">${inner}</span>`;if (download) return html`<a class="file-chip" href=${href} download=${name}>${inner}</a>`;return html`<span class="file-chip-group"- ><a class="file-chip" href=${href} target="_blank" rel="noreferrer">${inner}</a+ ><a+ class="file-chip"+ href=${href}+ target="_blank"+ rel="noreferrer"+ @click=${(event: MouseEvent) => previewFile(event, name, href, mimetype)}+ >${inner}</a><a class="file-chip-download" href=${href} download=${name} title="Download ${name}" aria-label="Download ${name}">${icon(Download, 14)}</a></spandiff --git a/plugins/web-ui/test/file-open.test.ts b/plugins/web-ui/test/file-open.test.tsnew file mode 100644index 000000000..55090f27c--- /dev/null+++ b/plugins/web-ui/test/file-open.test.ts@@ -0,0 +1,25 @@+import assert from "node:assert/strict";+import test from "node:test";+import { filePreviewKind, previewFile } from "../src/file-open.ts";++test("text previews recognize extensions and MIME types without intercepting binary files", () => {+ for (const name of ["notes.md", "notes.MARKDOWN"]) assert.equal(filePreviewKind(name), "markdown");+ assert.equal(filePreviewKind("data.JSON"), "text");+ assert.equal(filePreviewKind("download", "text/markdown; charset=utf-8"), "markdown");+ assert.equal(filePreviewKind("download", "Application/JSON"), "text");+ for (const name of ["data.json", "config.yaml", "config.toml", "notes.txt", "app.ts", "server.log"])+ assert.equal(filePreviewKind(name), "text");+ assert.equal(filePreviewKind("export.csv"), "csv");+ assert.equal(filePreviewKind("export.tsv"), "tsv");+ for (const name of ["report.pdf", "image.png", "archive.zip"]) assert.equal(filePreviewKind(name), null);+ assert.equal(filePreviewKind("data", "text/plain"), "text");+});++test("modified clicks and unsupported files retain the native link behavior", () => {+ const base = { button: 0, preventDefault: () => assert.fail("should remain a native link") };+ for (const modifier of ["ctrlKey", "metaKey", "altKey", "shiftKey"]) {+ previewFile({ ...base, [modifier]: true } as unknown as MouseEvent, "notes.md", "/file");+ }+ previewFile({ ...base, button: 1 } as unknown as MouseEvent, "data.json", "/file");+ previewFile(base as unknown as MouseEvent, "report.pdf", "/file");+});diff --git a/plugins/web-ui/test/file-viewer.test.ts b/plugins/web-ui/test/file-viewer.test.tsnew file mode 100644index 000000000..739302616--- /dev/null+++ b/plugins/web-ui/test/file-viewer.test.ts@@ -0,0 +1,48 @@+import assert from "node:assert/strict";+import { test } from "node:test";+import { createInboxFixture, until } from "./inbox-composer-fixture.ts";++test("file preview escapes CSV cells, preserves truncation warnings, copies raw text and restores focus", async () => {+ const { dom, vite, host, close } = await createInboxFixture();+ try {+ const text = `${Array.from({ length: 101 }, (_, i) => `column${i}`).join(",")}\n"<script>bad()</script>","quoted, comma"\n"unterminated`;+ globalThis.fetch = async () => new Response(text);+ let copied = "";+ Object.defineProperty(navigator, "clipboard", {+ value: {+ writeText: async (value: string) => {+ copied = value;+ },+ },+ });+ dom.window.HTMLDialogElement.prototype.showModal = function () {+ this.open = true;+ };+ dom.window.HTMLDialogElement.prototype.close = function () {+ this.open = false;+ this.dispatchEvent(new dom.window.Event("close"));+ };+ const opener = document.createElement("button");+ host.append(opener);+ opener.focus();+ const { openFileViewer } = await vite.ssrLoadModule("/src/file-viewer.ts");+ openFileViewer("export.csv", "/api/files/export/content", "csv");+ await until(() => Boolean(document.querySelector(".file-viewer-table")));+ const dialog = document.querySelector("dialog")!;+ assert.match(dialog.textContent!, /limited to 1,000 rows and 100 columns/);+ assert.match(dialog.textContent!, /CSV formatting errors/);+ assert.equal(dialog.querySelector("tr")!.children.length, 100);+ assert.equal(dialog.querySelectorAll("script").length, 0);+ assert.match(dialog.textContent!, /<script>bad\(\)<\/script>/);+ assert.match(dialog.textContent!, /quoted, comma/);+ assert.equal(dialog.querySelector("a")!.download, "export.csv");+ assert.doesNotMatch(dialog.textContent!, /Open raw|Source/);+ [...dialog.querySelectorAll("button")].find((button) => button.textContent === "Copy")!.click();+ await until(() => copied === text);+ dialog.querySelector<HTMLButtonElement>('[aria-label="Close preview"]')!.click();+ assert.equal(document.querySelector("dialog"), null);+ assert.equal(document.activeElement, opener);+ } finally {+ await close();+ }+});diff --git a/plugins/web-ui/test/files-source.test.ts b/plugins/web-ui/test/files-source.test.tsindex e2d89e215..cd80560f9 100644--- a/plugins/web-ui/test/files-source.test.ts+++ b/plugins/web-ui/test/files-source.test.ts@@ -20,7 +20,7 @@ test("Files uses compact rows that open directly", () => {const start = source.indexOf("function fileRow(");const end = source.indexOf("\nfunction rowsFromPage", start);const row = source.slice(start, end);- assert.match(row, /<a class="list-row file-row" href=\$\{contentUrl\} target="_blank"/);+ assert.match(row, /<a\s+class="list-row file-row"\s+href=\$\{contentUrl\}\s+target="_blank"/);assert.doesNotMatch(row, /file-row-type|\$\{f\.mimetype\}|class="badge"|\$\{f\.kind\}|>Open</);assert.doesNotMatch(row, /scopeChip|fileScope\(f\)/);assert.match(row, /formatBytes\(f\.sizeBytes\)/);