This commit is contained in:
Timothy Jaeryang Baek
2026-06-06 09:05:29 +01:00
Unverified
parent ddf6772b3a
commit d44ea99882
23 changed files with 1390 additions and 333 deletions
+538
View File
@@ -29,6 +29,7 @@
"@tiptap/extension-highlight": "^3.24.0",
"@tiptap/extension-image": "^3.24.0",
"@tiptap/extension-link": "^3.24.0",
"@tiptap/extension-mention": "^3.24.0",
"@tiptap/extension-placeholder": "^3.24.0",
"@tiptap/extension-subscript": "^3.24.0",
"@tiptap/extension-superscript": "^3.24.0",
@@ -62,6 +63,7 @@
"mermaid": "^11.15.0",
"panzoom": "^9.4.3",
"pdfjs-dist": "^5.5.207",
"shiki": "^4.2.0",
"socket.io-client": "^4.8.3",
"sortablejs": "^1.15.7",
"sql.js": "^1.14.1",
@@ -693,6 +695,106 @@
"integrity": "sha512-UromN0peaE53IaBRe9W7CjrZgXl90fqGpK+mIZbA3qSTeYqg3pqpROBdIPvOG3F5ereDHNwoHBI2e50n1BDr1g==",
"license": "MIT"
},
"node_modules/@shikijs/core": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.2.0.tgz",
"integrity": "sha512-Hc87Ab1Ld/vEbZRCbwx344I5v+4RU8CVToUTRkqXL1+TjbuOp9U5Xa0M23V4GEWHxVn+yO5otb+HkQVm3ptWQQ==",
"license": "MIT",
"dependencies": {
"@shikijs/primitive": "4.2.0",
"@shikijs/types": "4.2.0",
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4",
"hast-util-to-html": "^9.0.5"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/engine-javascript": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.2.0.tgz",
"integrity": "sha512-fjETeq1k5ffyXqRgS6+3hpvqseLalp1kjNfRbXpUgWR8FpZ1CmQfiNHovc5lncYjt/Vg5JK/WJEmLahjwMa0og==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "4.2.0",
"@shikijs/vscode-textmate": "^10.0.2",
"oniguruma-to-es": "^4.3.6"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/engine-oniguruma": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.2.0.tgz",
"integrity": "sha512-hTorK1dffPkpbMUk6Z+828PgRo7d07HbnizoP0hNPFjhxMHctj0Px/qoHeGMYafc6ju+u9iMldN4JbVzNQM++g==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "4.2.0",
"@shikijs/vscode-textmate": "^10.0.2"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/langs": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.2.0.tgz",
"integrity": "sha512-bwrVRlJ0wUhZxAbVdvBbv2TTC9yLsh4C/IO5Ofz0T8MQntgDvyVnkbjw9vi50r1kx7RCIJdnJnjZAwmAsXFLZQ==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "4.2.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/primitive": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.2.0.tgz",
"integrity": "sha512-NOq+DtUkVBJtZMVXL5A0vI0Xk8nvDYaXetFHSJFlOqjDZIVhIPRYFdGkSoElDqNuegikcc3A76SNUa8dTqtAYA==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "4.2.0",
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/themes": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.2.0.tgz",
"integrity": "sha512-RX8IHYeLv8Cu2W6ruc3RxUqWn0IYCqSrMBzi/uRGAmfyDNOnNO5BF/Px7o97n4XTpmFTo5GbRaazuOWj+2ak2w==",
"license": "MIT",
"dependencies": {
"@shikijs/types": "4.2.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/types": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.2.0.tgz",
"integrity": "sha512-VT/MKtlpOhEPZloSH3Pb9WCZEBDoQVMa9jedp5UAwmJOar1DVc9DRODAxmYPW9M93IK4ryuqRejFfmlvlVDemw==",
"license": "MIT",
"dependencies": {
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@shikijs/vscode-textmate": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",
"integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==",
"license": "MIT"
},
"node_modules/@socket.io/component-emitter": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
@@ -1148,6 +1250,21 @@
"@tiptap/extension-list": "3.24.0"
}
},
"node_modules/@tiptap/extension-mention": {
"version": "3.24.0",
"resolved": "https://registry.npmjs.org/@tiptap/extension-mention/-/extension-mention-3.24.0.tgz",
"integrity": "sha512-c68AYrEoHJ4vlBvt5stBUTveKXiNwt5BxaQxgq2R4OXjc3VMoh+XJqo1bBbMNHEJfuGMNpcdfZ2zf09jnBf8/A==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
"@tiptap/core": "3.24.0",
"@tiptap/pm": "3.24.0",
"@tiptap/suggestion": "3.24.0"
}
},
"node_modules/@tiptap/extension-ordered-list": {
"version": "3.24.0",
"resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-3.24.0.tgz",
@@ -1746,6 +1863,15 @@
"@types/unist": "*"
}
},
"node_modules/@types/mdast": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
"integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",
"license": "MIT",
"dependencies": {
"@types/unist": "*"
}
},
"node_modules/@types/sortablejs": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.15.9.tgz",
@@ -1765,6 +1891,12 @@
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
"license": "MIT"
},
"node_modules/@ungap/structured-clone": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.1.tgz",
"integrity": "sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ==",
"license": "ISC"
},
"node_modules/@upsetjs/venn.js": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@upsetjs/venn.js/-/venn.js-2.0.0.tgz",
@@ -1894,6 +2026,16 @@
"integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==",
"license": "MIT"
},
"node_modules/ccount": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
"integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/cfb": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
@@ -1907,6 +2049,26 @@
"node": ">=0.8"
}
},
"node_modules/character-entities-html4": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz",
"integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/chokidar": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
@@ -1956,6 +2118,16 @@
"node": ">=0.8"
}
},
"node_modules/comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
@@ -2742,6 +2914,42 @@
"integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==",
"license": "MIT"
},
"node_modules/hast-util-to-html": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz",
"integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/unist": "^3.0.0",
"ccount": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-whitespace": "^3.0.0",
"html-void-elements": "^3.0.0",
"mdast-util-to-hast": "^13.0.0",
"property-information": "^7.0.0",
"space-separated-tokens": "^2.0.0",
"stringify-entities": "^4.0.0",
"zwitch": "^2.0.4"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-whitespace": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz",
"integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/highlight.js": {
"version": "11.11.1",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz",
@@ -2751,6 +2959,16 @@
"node": ">=12.0.0"
}
},
"node_modules/html-void-elements": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz",
"integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/i18next": {
"version": "26.3.0",
"resolved": "https://registry.npmjs.org/i18next/-/i18next-26.3.0.tgz",
@@ -3070,6 +3288,27 @@
"node": ">= 20"
}
},
"node_modules/mdast-util-to-hast": {
"version": "13.2.1",
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",
"integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/mdast": "^4.0.0",
"@ungap/structured-clone": "^1.0.0",
"devlop": "^1.0.0",
"micromark-util-sanitize-uri": "^2.0.0",
"trim-lines": "^3.0.0",
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mermaid": {
"version": "11.15.0",
"resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.15.0.tgz",
@@ -3136,6 +3375,95 @@
"node": ">= 20"
}
},
"node_modules/micromark-util-character": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz",
"integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT",
"dependencies": {
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0"
}
},
"node_modules/micromark-util-encode": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz",
"integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/micromark-util-sanitize-uri": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz",
"integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT",
"dependencies": {
"micromark-util-character": "^2.0.0",
"micromark-util-encode": "^2.0.0",
"micromark-util-symbol": "^2.0.0"
}
},
"node_modules/micromark-util-symbol": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz",
"integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/micromark-util-types": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz",
"integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"license": "MIT"
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
@@ -3204,6 +3532,23 @@
],
"license": "MIT"
},
"node_modules/oniguruma-parser": {
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz",
"integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==",
"license": "MIT"
},
"node_modules/oniguruma-to-es": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz",
"integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==",
"license": "MIT",
"dependencies": {
"oniguruma-parser": "^0.12.2",
"regex": "^6.1.0",
"regex-recursion": "^6.0.2"
}
},
"node_modules/option": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/option/-/option-0.2.4.tgz",
@@ -3348,6 +3693,16 @@
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"license": "MIT"
},
"node_modules/property-information": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz",
"integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/prosemirror-changeset": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.1.tgz",
@@ -3516,6 +3871,30 @@
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/regex": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",
"integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",
"license": "MIT",
"dependencies": {
"regex-utilities": "^2.3.0"
}
},
"node_modules/regex-recursion": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz",
"integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",
"license": "MIT",
"dependencies": {
"regex-utilities": "^2.3.0"
}
},
"node_modules/regex-utilities": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz",
"integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",
"license": "MIT"
},
"node_modules/robust-predicates": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz",
@@ -3633,6 +4012,25 @@
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
"license": "MIT"
},
"node_modules/shiki": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.2.0.tgz",
"integrity": "sha512-hjNax6o/ylDy9lefQEaSDtzaT3iVNtZ3WmpQnbuQNoG4xvnSKf2kSKbihZVO4JRG1TTMejs7CmNRYlWgAL66pQ==",
"license": "MIT",
"dependencies": {
"@shikijs/core": "4.2.0",
"@shikijs/engine-javascript": "4.2.0",
"@shikijs/engine-oniguruma": "4.2.0",
"@shikijs/langs": "4.2.0",
"@shikijs/themes": "4.2.0",
"@shikijs/types": "4.2.0",
"@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4"
},
"engines": {
"node": ">=20"
}
},
"node_modules/sirv": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz",
@@ -3691,6 +4089,16 @@
"node": ">=0.10.0"
}
},
"node_modules/space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@@ -3724,6 +4132,20 @@
"safe-buffer": "~5.1.0"
}
},
"node_modules/stringify-entities": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",
"integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==",
"license": "MIT",
"dependencies": {
"character-entities-html4": "^2.0.0",
"character-entities-legacy": "^3.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/style-mod": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
@@ -3862,6 +4284,16 @@
"node": ">=6"
}
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
"integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/ts-dedent": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz",
@@ -3891,6 +4323,74 @@
"integrity": "sha512-DXtD3ZtEQzc7M8m4cXotyHR+FAS18C64asBYY5vqZexfYryNNnDc02W4hKg3rdQuqOYas1jkseX0+nZXjTXnvQ==",
"license": "MIT"
},
"node_modules/unist-util-is": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz",
"integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-position": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz",
"integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
"integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz",
"integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.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/unist-util-visit-parents": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz",
"integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -3910,6 +4410,34 @@
"uuid": "dist-node/bin/uuid"
}
},
"node_modules/vfile": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",
"integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile-message": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-message": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",
"integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-stringify-position": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vite": {
"version": "8.0.8",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.0.8.tgz",
@@ -4101,6 +4629,16 @@
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz",
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
"license": "MIT"
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
"integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
}
}
}
+2
View File
@@ -44,6 +44,7 @@
"@tiptap/extension-highlight": "^3.24.0",
"@tiptap/extension-image": "^3.24.0",
"@tiptap/extension-link": "^3.24.0",
"@tiptap/extension-mention": "^3.24.0",
"@tiptap/extension-placeholder": "^3.24.0",
"@tiptap/extension-subscript": "^3.24.0",
"@tiptap/extension-superscript": "^3.24.0",
@@ -77,6 +78,7 @@
"mermaid": "^11.15.0",
"panzoom": "^9.4.3",
"pdfjs-dist": "^5.5.207",
"shiki": "^4.2.0",
"socket.io-client": "^4.8.3",
"sortablejs": "^1.15.7",
"sql.js": "^1.14.1",
+9 -2
View File
@@ -44,12 +44,19 @@
/* Scrollbar - Open WebUI style */
::-webkit-scrollbar-thumb {
background-color: rgba(67, 67, 67, 0.6);
border-color: rgba(0, 0, 0, 1);
--tw-border-opacity: 1;
background-color: rgba(215, 215, 215, 0.6);
border-color: rgba(255, 255, 255, var(--tw-border-opacity));
border-radius: 9999px;
border-width: 1px;
}
/* Dark theme scrollbar styles */
.dark ::-webkit-scrollbar-thumb {
background-color: rgba(67, 67, 67, 0.6);
border-color: rgba(0, 0, 0, var(--tw-border-opacity));
}
::-webkit-scrollbar {
height: 0.45rem;
width: 0.45rem;
+13 -3
View File
@@ -40,8 +40,16 @@ export interface SendMessageResult {
// ── Queries ─────────────────────────────────────────────────
export const getChats = (workspace: string) =>
fetchJSON<{ chats: ChatInfo[] }>(`/api/chats?workspace=${encodeURIComponent(workspace)}`);
export const getChats = (
workspace: string,
limit = 50,
offset = 0,
sortBy: 'title' | 'updated_at' = 'updated_at',
sortDir: 'asc' | 'desc' = 'desc'
) =>
fetchJSON<{ chats: ChatInfo[]; total: number; has_more: boolean }>(
`/api/chats?workspace=${encodeURIComponent(workspace)}&limit=${limit}&offset=${offset}&sort_by=${sortBy}&sort_dir=${sortDir}`
);
export const getChat = (chatId: string) =>
fetchJSON<ChatDetail>(`/api/chats/${chatId}`);
@@ -58,7 +66,8 @@ export const sendMessage = (
chatId?: string,
parentId?: string | null,
params: { tool_approval_mode?: string } = {},
regenerationPrompt?: string
regenerationPrompt?: string,
files?: string[]
) =>
fetchJSON<SendMessageResult>(
'/api/chats',
@@ -69,6 +78,7 @@ export const sendMessage = (
chat_id: chatId,
parent_id: parentId ?? null,
regeneration_prompt: regenerationPrompt,
files: files ?? [],
params
})
);
@@ -350,7 +350,7 @@
data-index={i}
class="flex items-center gap-2 w-full h-7 px-2 rounded-lg text-left transition-colors duration-75
{i === selectedIndex
? 'bg-gray-100 text-gray-900 dark:bg-white/6 dark:text-white'
? 'bg-gray-200/50 text-gray-900 dark:bg-white/6 dark:text-white'
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/4'}"
onclick={() => navigateTo(dir.name)}
ondblclick={(e) => { e.stopPropagation(); const fullPath = currentPath === '/' ? `/${dir.name}` : `${currentPath}/${dir.name}`; addWorkspace(fullPath); goto(`/?workspace=${encodeURIComponent(fullPath)}`); onclose(); }}
@@ -9,6 +9,7 @@
import { systemEvents } from '$lib/stores/systemEvents.svelte';
import { tooltip } from '$lib/tooltip';
import { listDir, downloadArchive, deleteFiles, moveFile, uploadFiles as apiUpload, createEntry } from '$lib/apis/files';
import { fileIconName } from '$lib/utils/fileIcon';
import Icon from './Icon.svelte';
import DropdownMenu from './DropdownMenu.svelte';
import { t } from '$lib/i18n';
@@ -269,30 +270,7 @@
setFileBrowserCwd(path);
}
function fileIconName(entry: FileEntry): string {
if (entry.type === 'directory') return 'folder';
const ext = entry.name.split('.').pop()?.toLowerCase() ?? '';
if (entry.name === 'Dockerfile') return 'docker';
if (entry.name === 'LICENSE' || entry.name === 'LICENSE.md') return 'page-text';
if (entry.name.endsWith('.lock')) return 'lock';
switch (ext) {
case 'md': return 'page-text';
case 'ts': case 'tsx': case 'js': case 'jsx':
case 'py': case 'rs': case 'go': case 'java':
case 'c': case 'cpp': case 'h': case 'hpp':
case 'rb': case 'php': case 'swift': case 'kt':
case 'svelte': case 'vue':
return 'code';
case 'json': case 'yaml': case 'yml': case 'toml':
case 'ini': case 'cfg': case 'conf':
return 'settings';
case 'sh': case 'bash': case 'zsh':
return 'terminal';
case 'css': case 'html': case 'xml':
return 'code';
default: return 'empty-page';
}
}
// fileIconName imported from $lib/utils/fileIcon
function formatSize(bytes: number | null): string {
if (bytes === null || bytes === undefined) return '';
@@ -755,7 +733,7 @@
{#if renamingEntry === entry.path}
<!-- Inline rename -->
<div class="flex items-center gap-2 h-7" style="padding-left: {8 + entry.depth * 16}px; padding-right: 8px;">
<Icon name={fileIconName(entry)} size={14} class="text-gray-400 shrink-0" />
<Icon name={fileIconName(entry.name, entry.type)} size={14} class="text-gray-400 shrink-0" />
<input
type="text"
class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white"
@@ -789,7 +767,7 @@
<span class="w-4 shrink-0"></span>
{/if}
<span class="flex items-center justify-center w-4 shrink-0 {entry.type === 'directory' ? 'text-gray-500 dark:text-gray-400' : 'text-gray-400 dark:text-gray-500'}">
<Icon name={fileIconName(entry)} size={14} strokeWidth={1.4} />
<Icon name={fileIconName(entry.name, entry.type)} size={14} strokeWidth={1.4} />
</span>
{#if entry.type === 'directory'}
<!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -424,12 +424,12 @@
<!-- Tabs (always visible) -->
<button
class="px-2.5 h-6 rounded-md text-[11px] font-medium transition-colors duration-75
{view === 'changes' ? 'bg-gray-100 dark:bg-white/8 text-gray-900 dark:text-white' : 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
{view === 'changes' ? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white' : 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
onclick={() => switchView('changes')}
>Changes{#if totalChanges > 0}<span class="ml-1 text-gray-400 dark:text-gray-500">{totalChanges}</span>{/if}</button>
<button
class="px-2.5 h-6 rounded-md text-[11px] font-medium transition-colors duration-75
{view === 'history' ? 'bg-gray-100 dark:bg-white/8 text-gray-900 dark:text-white' : 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
{view === 'history' ? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white' : 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
onclick={() => switchView('history')}
>{$t('git.history')}</button>
@@ -253,7 +253,7 @@
<button
class="flex items-center gap-1.5 px-2.5 h-7 rounded-lg text-xs font-medium whitespace-nowrap shrink-0 transition-all duration-100
{isActive
? 'bg-gray-200 text-gray-900 dark:bg-white/8 dark:text-white'
? 'bg-gray-200/50 text-gray-900 dark:bg-white/8 dark:text-white'
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
data-tab-id={tab.id}
onclick={() => handleTabClick(tab)}
@@ -271,7 +271,7 @@
{#if !tab.permanent}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<span
class="flex items-center justify-center w-4 h-4 rounded text-gray-400 hover:bg-gray-300 hover:text-gray-700 dark:hover:bg-white/10 dark:hover:text-white"
class="flex items-center justify-center w-4 h-4 rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-white/10 dark:hover:text-white"
onclick={(e) => handleClose(e, tab.id)}
onkeydown={(e) => { if (e.key === 'Enter') handleClose(e, tab.id); }}
role="button"
@@ -305,7 +305,7 @@
bind:this={splitBtnEl}
class="flex items-center justify-center w-7 h-7 rounded-lg transition-colors duration-100 shrink-0
{$splitActive
? 'bg-gray-200 text-gray-900 dark:bg-white/8 dark:text-white'
? 'bg-gray-200/50 text-gray-900 dark:bg-white/8 dark:text-white'
: 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
onclick={() => showSplitMenu = !showSplitMenu}
aria-label="Split Editor"
@@ -182,7 +182,7 @@
data-index={i}
class="flex items-center gap-2 w-full h-7 px-2 rounded-lg text-left transition-colors duration-75
{i === selectedIndex
? 'bg-gray-100 text-gray-900 dark:bg-white/6 dark:text-white'
? 'bg-gray-200/50 text-gray-900 dark:bg-white/6 dark:text-white'
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/4'}"
onclick={() => navigateTo(dir.name)}
onmouseenter={() => { selectedIndex = i; }}
@@ -20,7 +20,7 @@
] as opt}
<button
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg text-xs transition-colors duration-100
{$theme === opt.value ? 'bg-gray-100 dark:bg-white/8 text-gray-900 dark:text-white font-medium' : 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
{$theme === opt.value ? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white font-medium' : 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
onclick={() => setTheme(opt.value)}
>
<Icon name={opt.icon} size={13} />
@@ -48,7 +48,7 @@
] as opt}
<button
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg text-xs transition-colors duration-100
{$streamingBehavior === opt.value ? 'bg-gray-100 dark:bg-white/8 text-gray-900 dark:text-white font-medium' : 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
{$streamingBehavior === opt.value ? 'bg-gray-200/50 dark:bg-white/8 text-gray-900 dark:text-white font-medium' : 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
onclick={() => streamingBehavior.set(opt.value)}
>
{opt.label}
@@ -7,6 +7,7 @@
removeWorkspace,
reorderWorkspaces,
sidebarOpen,
sidebarWidth,
} from '$lib/stores';
import Sortable from 'sortablejs';
import Icon from './Icon.svelte';
@@ -33,6 +34,38 @@
let wsListEl: HTMLDivElement | undefined = $state();
let sortable: Sortable | null = null;
const MIN_WIDTH = 160;
const MAX_WIDTH = 400;
let isResizing = $state(false);
function startResize(e: PointerEvent) {
// Only allow resize on md+ screens
if (typeof window !== 'undefined' && window.innerWidth < 768) return;
e.preventDefault();
isResizing = true;
const startX = e.clientX;
const startWidth = $sidebarWidth;
function onMove(ev: PointerEvent) {
const delta = ev.clientX - startX;
const newWidth = Math.round(Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + delta)));
sidebarWidth.set(newWidth);
}
function onUp() {
isResizing = false;
window.removeEventListener('pointermove', onMove);
window.removeEventListener('pointerup', onUp);
document.body.style.cursor = '';
document.body.style.userSelect = '';
}
window.addEventListener('pointermove', onMove);
window.addEventListener('pointerup', onUp);
document.body.style.cursor = 'col-resize';
document.body.style.userSelect = 'none';
}
// Current workspace path from URL
const currentPath = $derived($page.url.searchParams.get('workspace'));
@@ -113,7 +146,16 @@
{#if $sidebarOpen}
<button class="fixed inset-0 bg-black/50 z-40 cursor-default md:hidden" onclick={closeSidebar} aria-label={$t('sidebar.closeSidebar')}></button>
<aside class="sidebar">
<aside class="sidebar" style="--sw: {$sidebarWidth}px;">
<!-- Resize handle (md+ only) -->
<div
class="resize-handle"
class:active={isResizing}
role="separator"
aria-orientation="vertical"
onpointerdown={startResize}
ondblclick={() => sidebarWidth.set(220)}
></div>
<!-- Logo header with collapse button -->
<div class="flex items-center justify-between h-9 pl-3.5 pr-1.5 shrink-0 border-b border-gray-200 dark:border-white/6">
<a
@@ -151,14 +193,14 @@
href="/?workspace={encodeURIComponent(ws.path)}"
class="group flex items-center gap-1.5 w-full h-7 px-2 rounded-lg text-xs font-medium transition-colors duration-100 no-underline
{ws.path === currentPath
? 'bg-gray-200 text-gray-900 dark:bg-white/8 dark:text-white'
? 'bg-gray-200/50 text-gray-900 dark:bg-white/8 dark:text-white'
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
onclick={(e) => handleWorkspaceClick(e, ws.path)}
>
<Icon name="folder" size={14} />
<span class="flex-1 text-left overflow-hidden text-ellipsis whitespace-nowrap">{ws.name}</span>
<span
class="flex items-center justify-center w-5 h-5 rounded shrink-0 text-gray-400 opacity-0 group-hover:opacity-100 hover:bg-gray-300 dark:hover:bg-white/10 transition-all duration-75"
class="flex items-center justify-center w-5 h-5 rounded shrink-0 text-gray-400 opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-white/10 transition-all duration-75"
role="button"
tabindex="-1"
onclick={(e) => openWsMenu(e, ws.path)}
@@ -261,6 +303,30 @@
.sidebar {
position: relative;
z-index: auto;
width: var(--sw, 220px);
}
}
.resize-handle {
display: none;
}
@media (min-width: 768px) {
.resize-handle {
display: block;
position: absolute;
right: -3px;
top: 0;
bottom: 0;
width: 6px;
cursor: col-resize;
z-index: 10;
transition: background 0.15s;
}
.resize-handle:hover,
.resize-handle.active {
background: rgba(150, 150, 150, 0.12);
}
}
</style>
@@ -1,12 +1,41 @@
<script lang="ts">
import type { ChatInfo } from '$lib/apis/chat';
import DropdownMenu from '../DropdownMenu.svelte';
interface Props {
chats: ChatInfo[];
onopen: (id: string) => void;
ondelete: (id: string) => void;
hasMore?: boolean;
onloadmore?: () => void;
sortBy?: 'title' | 'updated_at';
sortDir?: 'asc' | 'desc';
onsort?: (field: 'title' | 'updated_at') => void;
}
let {
chats,
onopen,
ondelete,
hasMore = false,
onloadmore,
sortBy = 'updated_at',
sortDir = 'desc',
onsort,
}: Props = $props();
let menuChatId = $state<string | null>(null);
let menuAnchor = $state<HTMLElement | null>(null);
function openMenu(e: MouseEvent, chatId: string) {
e.stopPropagation();
menuChatId = chatId;
menuAnchor = e.currentTarget as HTMLElement;
}
function closeMenu() {
menuChatId = null;
menuAnchor = null;
}
let { chats, onopen, ondelete }: Props = $props();
function formatTime(ts: number): string {
const d = new Date(ts);
@@ -20,8 +49,56 @@
}
</script>
{#snippet chevronUp()}
<svg class="w-2 h-2" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 5L5 1L9 5" />
</svg>
{/snippet}
{#snippet chevronDown()}
<svg class="w-2 h-2" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 1L5 5L9 1" />
</svg>
{/snippet}
{#if chats.length > 0}
<div class="w-full mt-4 pt-2">
<!-- Sort header -->
{#if onsort}
<div class="flex items-center text-[10px] font-medium text-gray-400 dark:text-gray-600 mb-1 px-2 select-none">
<button
class="flex-1 flex items-center gap-1 hover:text-gray-600 dark:hover:text-gray-400 transition-colors"
onclick={() => onsort?.('title')}
>
Title
{#if sortBy === 'title'}
{#if sortDir === 'asc'}
{@render chevronUp()}
{:else}
{@render chevronDown()}
{/if}
{:else}
<span class="invisible">{@render chevronUp()}</span>
{/if}
</button>
<button
class="shrink-0 flex items-center gap-1 hover:text-gray-600 dark:hover:text-gray-400 transition-colors"
onclick={() => onsort?.('updated_at')}
>
Updated
{#if sortBy === 'updated_at'}
{#if sortDir === 'asc'}
{@render chevronUp()}
{:else}
{@render chevronDown()}
{/if}
{:else}
<span class="invisible">{@render chevronUp()}</span>
{/if}
</button>
</div>
{/if}
{#each chats as chat (chat.id)}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
@@ -31,21 +108,39 @@
onclick={() => onopen(chat.id)}
onkeydown={(e) => { if (e.key === 'Enter') onopen(chat.id); }}
>
<svg class="w-3.5 h-3.5 shrink-0 text-gray-300 dark:text-gray-700" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
<span class="flex-1 text-xs text-gray-500 dark:text-gray-500 truncate">{chat.title}</span>
<span class="text-[10px] text-gray-300 dark:text-gray-700 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity duration-75">{formatTime(chat.updated_at)}</span>
<span class="text-[10px] text-gray-300 dark:text-gray-700 shrink-0">{formatTime(chat.updated_at)}</span>
<button
class="flex items-center justify-center w-5 h-5 rounded shrink-0 text-gray-300 dark:text-gray-700 opacity-0 group-hover:opacity-100 hover:text-red-400 dark:hover:text-red-400 transition-all duration-75"
onclick={(e) => { e.stopPropagation(); ondelete(chat.id); }}
aria-label="Delete chat"
class="flex items-center justify-center w-5 h-5 rounded shrink-0 text-gray-300 dark:text-gray-700 hover:text-gray-500 dark:hover:text-gray-400 transition-all duration-75"
onclick={(e) => openMenu(e, chat.id)}
aria-label="Chat options"
>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
<svg width="11" height="11" viewBox="0 0 16 16" fill="currentColor">
<circle cx="3" cy="8" r="1.5" />
<circle cx="8" cy="8" r="1.5" />
<circle cx="13" cy="8" r="1.5" />
</svg>
</button>
</div>
{/each}
{#if hasMore && onloadmore}
<button
class="w-full h-7 mt-1 text-[11px] text-gray-400 dark:text-gray-600 hover:text-gray-600 dark:hover:text-gray-400 transition-colors duration-75"
onclick={onloadmore}
>
Show more
</button>
{/if}
</div>
{/if}
{#if menuChatId && menuAnchor}
<DropdownMenu
anchor={menuAnchor}
align="end"
items={[
{ label: 'Delete', icon: 'trash', onclick: () => { if (menuChatId) ondelete(menuChatId); } },
]}
onclose={closeMenu}
/>
{/if}
@@ -1,5 +1,6 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { mount, unmount } from 'svelte';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';
import { Markdown } from '@tiptap/markdown';
@@ -7,6 +8,9 @@
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';
import { all, createLowlight } from 'lowlight';
import { createFileMention, extractMentionedFiles, type FileMentionAttrs } from './FileMention';
import FileSuggestionPopup from './FileSuggestionPopup.svelte';
import { searchFiles } from '$lib/apis/files';
import ModelSelector from './ModelSelector.svelte';
import SendButton from './SendButton.svelte';
import PlusMenu from './PlusMenu.svelte';
@@ -18,6 +22,7 @@
selectedModel: string;
sending: boolean;
streaming?: boolean;
workspace?: string;
placeholder?: string;
queuedMessages?: { id: string; content: string }[];
onsend: () => void;
@@ -31,6 +36,7 @@
selectedModel = $bindable(),
sending,
streaming = false,
workspace = '',
placeholder = 'Message...',
queuedMessages = [],
onsend,
@@ -51,10 +57,128 @@
return _origHighlight(lang, value, opts);
};
// ── @file mention suggestion ────────────────────
let popupEl: HTMLDivElement | null = null;
let popupComponent: Record<string, any> | null = null;
async function fetchSuggestions({ query }: { query: string }): Promise<FileMentionAttrs[]> {
if (!workspace) return [];
try {
const data = await searchFiles(query || '', workspace);
const results = (data as any).results ?? [];
return results.slice(0, 10).map((r: any) => ({
id: r.path,
label: r.name,
type: r.type === 'directory' ? 'directory' : 'file',
}));
} catch {
return [];
}
}
function mountPopup(items: FileMentionAttrs[], selectedIdx: number, onselect: (i: number) => void) {
// Destroy previous instance
if (popupComponent) {
try { unmount(popupComponent); } catch {}
popupComponent = null;
}
if (!popupEl) {
popupEl = document.createElement('div');
document.body.appendChild(popupEl);
}
popupComponent = mount(FileSuggestionPopup, {
target: popupEl,
props: { items, selectedIndex: selectedIdx, onselect },
});
}
function createSuggestionRenderer() {
let selectedIndex = 0;
let currentItems: FileMentionAttrs[] = [];
let command: ((attrs: FileMentionAttrs) => void) | null = null;
function doSelect(index: number) {
const item = currentItems[index];
if (item && command) command(item);
}
function remount() {
mountPopup(currentItems, selectedIndex, doSelect);
}
return {
onStart(props: any) {
command = props.command;
currentItems = props.items;
selectedIndex = 0;
remount();
updatePopupPosition(props.clientRect?.());
},
onUpdate(props: any) {
command = props.command;
currentItems = props.items;
selectedIndex = 0;
remount();
updatePopupPosition(props.clientRect?.());
},
onKeyDown({ event }: { event: KeyboardEvent }) {
if (event.key === 'ArrowDown') {
selectedIndex = (selectedIndex + 1) % Math.max(currentItems.length, 1);
remount();
return true;
}
if (event.key === 'ArrowUp') {
selectedIndex = (selectedIndex - 1 + currentItems.length) % Math.max(currentItems.length, 1);
remount();
return true;
}
if (event.key === 'Enter') {
const item = currentItems[selectedIndex];
if (item && command) command(item);
return true;
}
if (event.key === 'Escape') {
destroyPopup();
return true;
}
return false;
},
onExit() {
destroyPopup();
},
};
}
function updatePopupPosition(rect: DOMRect | null) {
if (!popupEl || !rect) return;
const child = popupEl.firstElementChild as HTMLElement | null;
if (!child) return;
const popupHeight = child.offsetHeight || 200;
child.style.position = 'fixed';
child.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 320))}px`;
child.style.top = `${rect.top - popupHeight - 8}px`;
}
function destroyPopup() {
if (popupComponent) {
try { unmount(popupComponent); } catch {}
popupComponent = null;
}
if (popupEl) {
popupEl.remove();
popupEl = null;
}
}
// ── Editor lifecycle ────────────────────────────
onMount(() => {
if (!editorEl) return;
const fileMention = createFileMention({
items: fetchSuggestions,
render: createSuggestionRenderer,
});
editor = new Editor({
element: editorEl,
extensions: [
@@ -65,6 +189,7 @@
Markdown,
Placeholder.configure({ placeholder }),
CodeBlockLowlight.configure({ lowlight }),
fileMention,
],
content: inputText || '',
contentType: inputText ? 'markdown' : undefined,
@@ -76,6 +201,8 @@
},
handleKeyDown: (view, event) => {
if (event.key === 'Enter' && !event.shiftKey) {
// Don't send while suggestion popup is open — let it confirm selection
if (popupComponent) return false;
const { state } = view;
const head = state.selection.$head;
@@ -103,6 +230,7 @@
});
onDestroy(() => {
destroyPopup();
editor?.destroy();
editor = null;
});
@@ -128,6 +256,12 @@
// TipTap auto-sizes; no-op kept for API compat
}
/** Get file paths from @mentions in the current editor content. */
export function getFiles(): string[] {
if (!editor) return [];
return extractMentionedFiles(editor.getJSON());
}
// Allow sending during streaming (message will be enqueued server-side)
const canSend = $derived(inputText.trim() && selectedModel && !sending);
</script>
@@ -212,15 +212,42 @@
}
}
const CHATS_PAGE_SIZE = 50;
let hasMoreChats = $state(false);
let chatSortBy = $state<'title' | 'updated_at'>('updated_at');
let chatSortDir = $state<'asc' | 'desc'>('desc');
async function loadPreviousChats() {
try {
const data = await getChats(workspace);
const data = await getChats(workspace, CHATS_PAGE_SIZE, 0, chatSortBy, chatSortDir);
previousChats = data.chats || [];
hasMoreChats = data.has_more;
} catch {
previousChats = [];
hasMoreChats = false;
}
}
async function loadMoreChats() {
try {
const data = await getChats(workspace, CHATS_PAGE_SIZE, previousChats.length, chatSortBy, chatSortDir);
previousChats = [...previousChats, ...(data.chats || [])];
hasMoreChats = data.has_more;
} catch {
hasMoreChats = false;
}
}
function handleSort(field: 'title' | 'updated_at') {
if (chatSortBy === field) {
chatSortDir = chatSortDir === 'asc' ? 'desc' : 'asc';
} else {
chatSortBy = field;
chatSortDir = field === 'title' ? 'asc' : 'desc';
}
loadPreviousChats();
}
async function openChat(id: string) {
await loadChat(id);
const chat = previousChats.find((c) => c.id === id);
@@ -400,10 +427,16 @@
// ── Actions ─────────────────────────────────────────────────
async function send() {
const text = inputText.trim();
let text = inputText.trim();
if (!text || !selectedModel) return;
if (sending) return;
sending = true;
const files = chatInputEl?.getFiles() ?? [];
// Transform TipTap mention format to markdown file links
text = text.replace(
/\[@\s+id="([^"]+)"\s+label="([^"]+)"\]/g,
(_: string, id: string, label: string) => `[${label}](file://${id})`
);
inputText = '';
autoScroll = true;
await tick();
@@ -428,7 +461,7 @@
} else {
try {
const mode = get(toolApprovalMode);
const result = await apiSendMessage(text, selectedModel, workspace, chatId, parentId, { tool_approval_mode: mode });
const result = await apiSendMessage(text, selectedModel, workspace, chatId, parentId, { tool_approval_mode: mode }, undefined, files);
if (result.queued) {
// Add directly to allMessages so it appears in queue UI instantly
allMessages = [...allMessages, {
@@ -480,7 +513,7 @@
try {
const mode = get(toolApprovalMode);
const result = await apiSendMessage(text, selectedModel, workspace, chatId ?? undefined, parentId, { tool_approval_mode: mode });
const result = await apiSendMessage(text, selectedModel, workspace, chatId ?? undefined, parentId, { tool_approval_mode: mode }, undefined, files);
await loadChat(result.chat_id);
if (isNew && tabId) {
updateTab(tabId, result.chat_id, text.slice(0, 40) || 'Chat');
@@ -700,8 +733,8 @@
<div class="flex flex-col h-full bg-white dark:bg-black">
{#if isLanding}
<!-- Landing: input + recent chats -->
<div class="flex-1 overflow-y-auto">
<div class="max-w-xl mx-auto px-4 flex flex-col" style="padding-top: max(14vh, 48px);">
<div class="flex-1 overflow-y-auto flex items-center justify-center">
<div class="max-w-xl w-full mx-auto px-4 flex flex-col pb-[5vh]">
<!-- Greeting -->
<div class="mb-8 text-center">
<h1 class="text-lg font-normal text-gray-800 dark:text-gray-200 tracking-tight">
@@ -714,6 +747,7 @@
bind:inputText
bind:selectedModel
{sending}
{workspace}
placeholder="Ask anything about {workspaceName}..."
onsend={send}
{queuedMessages}
@@ -721,7 +755,7 @@
onqueueedit={handleQueueEdit}
onqueuedelete={handleQueueDelete}
/>
<ChatHistory chats={previousChats} onopen={openChat} ondelete={deleteChat} />
<ChatHistory chats={previousChats} onopen={openChat} ondelete={deleteChat} hasMore={hasMoreChats} onloadmore={loadMoreChats} sortBy={chatSortBy} sortDir={chatSortDir} onsort={handleSort} />
</div>
</div>
{:else}
@@ -791,6 +825,7 @@
bind:selectedModel
{sending}
{streaming}
{workspace}
onsend={send}
oncancel={handleCancel}
{queuedMessages}
@@ -0,0 +1,65 @@
/**
* TipTap Mention extension configured for @file mentions.
*
* Wraps @tiptap/extension-mention with file-specific rendering
* and suggestion config wired to the workspace file search API.
*/
import Mention from '@tiptap/extension-mention';
export interface FileMentionAttrs {
id: string; // full file path
label: string; // display name (basename)
type: string; // 'file' | 'directory'
}
/**
* Create the configured Mention extension.
* `suggestionOptions` is passed in from the component that owns
* the lifecycle of the suggestion popup.
*/
export function createFileMention(suggestionOptions: {
items: (props: { query: string }) => Promise<FileMentionAttrs[]> | FileMentionAttrs[];
render: () => {
onStart: (props: any) => void;
onUpdate: (props: any) => void;
onKeyDown: (props: any) => boolean;
onExit: () => void;
};
}) {
return Mention.configure({
HTMLAttributes: {
class: 'bg-blue-500/10 text-blue-400 rounded px-1 py-px text-xs font-mono',
},
renderText({ node }) {
const label = node.attrs.label ?? node.attrs.id;
return `[${label}](file://${node.attrs.id})`;
},
suggestion: {
char: '@',
allowSpaces: false,
...suggestionOptions,
},
});
}
/**
* Extract all file mention paths from a TipTap editor JSON doc.
*/
export function extractMentionedFiles(doc: any): string[] {
const files: string[] = [];
function walk(node: any) {
if (node.type === 'mention' && node.attrs?.id) {
files.push(node.attrs.id);
}
if (node.content) {
for (const child of node.content) {
walk(child);
}
}
}
if (doc) walk(doc);
return [...new Set(files)];
}
@@ -0,0 +1,67 @@
<script lang="ts">
import Icon from '../Icon.svelte';
import { fileIconName } from '$lib/utils/fileIcon';
interface SuggestionItem {
id: string;
label: string;
type: string;
}
interface Props {
items: SuggestionItem[];
selectedIndex: number;
onselect: (index: number) => void;
}
let { items, selectedIndex, onselect }: Props = $props();
let listEl: HTMLDivElement | undefined = $state();
// Scroll selected item into view
$effect(() => {
if (listEl && selectedIndex >= 0) {
const el = listEl.children[selectedIndex] as HTMLElement | undefined;
el?.scrollIntoView({ block: 'nearest' });
}
});
function relativePath(fullPath: string): string {
// Show last 2 path segments as context
const parts = fullPath.split('/');
if (parts.length <= 2) return '';
return parts.slice(-3, -1).join('/');
}
</script>
<div
class="fixed z-[200] w-56 max-h-40 overflow-y-auto rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
>
{#if items.length === 0}
<div class="px-3 py-2 text-xs text-gray-400 dark:text-gray-600">No files found</div>
{:else}
<div class="text-[10px] font-medium text-gray-400 dark:text-gray-600 px-2.5 pt-1.5 pb-0.5">Files</div>
<div bind:this={listEl}>
{#each items as item, i (item.id)}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<button
class="flex items-center gap-2 w-full px-2.5 py-1.5 rounded-lg text-left transition-colors duration-75
{i === selectedIndex
? 'bg-gray-50 dark:bg-white/8 text-gray-900 dark:text-white'
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/4'}"
onmousedown={(e) => { e.preventDefault(); onselect(i); }}
onmouseenter={() => selectedIndex = i}
>
<span class="flex items-center justify-center w-4 shrink-0 {item.type === 'directory' ? 'text-gray-500 dark:text-gray-400' : 'text-gray-400 dark:text-gray-500'}">
<Icon name={fileIconName(item.label, item.type)} size={12} />
</span>
<span class="flex-1 min-w-0 flex items-baseline gap-1.5 overflow-hidden">
<span class="text-xs font-medium truncate text-gray-900 dark:text-gray-200">{item.label}</span>
{#if relativePath(item.id)}
<span class="text-[10px] text-gray-400 dark:text-gray-600 truncate shrink-0">{relativePath(item.id)}</span>
{/if}
</span>
</button>
{/each}
</div>
{/if}
</div>
@@ -1,5 +1,7 @@
<script lang="ts">
import { tick } from 'svelte';
import Icon from '../Icon.svelte';
import { fileIconName } from '$lib/utils/fileIcon';
interface Props {
content: string;
@@ -10,6 +12,29 @@
}
let { content, siblingIndex = 0, siblingTotal = 1, onedit, onnavigate }: Props = $props();
type Segment = { type: 'text'; value: string } | { type: 'file'; label: string; path: string };
// Matches both [label](file://path) and TipTap's [@ id="path" label="name"]
const FILE_LINK_RE = /\[([^\]]+)\]\(file:\/\/([^)]+)\)/g;
const TIPTAP_MENTION_RE = /\[@\s+id="([^"]+)"\s+label="([^"]+)"\]/g;
const parsedContent: Segment[] = $derived.by(() => {
// Normalize TipTap format to markdown links first
const normalized = content.replace(
TIPTAP_MENTION_RE,
(_: string, id: string, label: string) => `[${label}](file://${id})`
);
const segments: Segment[] = [];
let last = 0;
for (const m of normalized.matchAll(FILE_LINK_RE)) {
if (m.index > last) segments.push({ type: 'text', value: normalized.slice(last, m.index) });
segments.push({ type: 'file', label: m[1], path: m[2] });
last = m.index + m[0].length;
}
if (last < normalized.length) segments.push({ type: 'text', value: normalized.slice(last) });
return segments.length ? segments : [{ type: 'text' as const, value: content }];
});
let edit = $state(false);
let editedContent = $state('');
let copied = $state(false);
@@ -99,7 +124,7 @@
<!-- Bubble: right-aligned -->
<div class="flex justify-end">
<div class="max-w-[90%] px-4 py-2 rounded-3xl bg-gray-50 dark:bg-white/[0.06]">
<div class="text-[13px] leading-relaxed text-gray-900 dark:text-gray-200 whitespace-pre-wrap break-words">{content}</div>
<div class="text-[13px] leading-relaxed text-gray-900 dark:text-gray-200 whitespace-pre-wrap break-words">{#each parsedContent as segment}{#if segment.type === 'text'}{segment.value}{:else}<span class="inline-flex items-center gap-0.5 bg-blue-500/10 text-blue-400 rounded px-1.5 py-px mx-0.5 text-xs font-mono align-baseline"><Icon name={fileIconName(segment.label, 'file')} size={11} />{segment.label}</span>{/if}{/each}</div>
</div>
</div>
{#if siblingTotal > 1 || onedit}
@@ -1,287 +1,241 @@
<script lang="ts">
import type { HighlighterCore } from "shiki/core";
interface Props {
language: string;
code: string;
/** Optional diff-style callbacks for chat tool approval */
onapply?: ((code: string) => void) | undefined;
onreject?: (() => void) | undefined;
}
interface Props {
language: string;
code: string;
/** Optional diff-style callbacks for chat tool approval */
onapply?: ((code: string) => void) | undefined;
onreject?: (() => void) | undefined;
}
let { language, code, onapply, onreject }: Props = $props();
let { language, code, onapply, onreject }: Props = $props();
let codeEl: HTMLElement | undefined = $state();
let highlighted = $state(false);
let copied = $state(false);
let codeEl: HTMLElement | undefined = $state();
let copied = $state(false);
// Detect diff blocks
let isDiff = $derived(language === 'diff');
// Detect diff blocks
let isDiff = $derived(language === "diff");
// Parse diff lines for coloring
let diffLines = $derived.by(() => {
if (!isDiff) return [];
return code.split('\n').map(line => ({
text: line,
type: line.startsWith('+') ? 'add' as const
: line.startsWith('-') ? 'del' as const
: line.startsWith('@@') ? 'range' as const
: 'ctx' as const,
}));
});
// Parse diff lines for coloring
let diffLines = $derived.by(() => {
if (!isDiff) return [];
return code.split("\n").map((line) => ({
text: line,
type: line.startsWith("+")
? ("add" as const)
: line.startsWith("-")
? ("del" as const)
: line.startsWith("@@")
? ("range" as const)
: ("ctx" as const),
}));
});
// Cache hljs module
let hljsModule: any = null;
// Lazy-loaded Shiki highlighter singleton
let highlighterPromise: Promise<HighlighterCore> | null = null;
// Highlight non-diff code: reactive so it re-runs on prop changes (streaming)
$effect(() => {
if (isDiff || !codeEl) return;
const currentCode = code;
const currentLang = language;
async function getHighlighter(): Promise<HighlighterCore> {
if (!highlighterPromise) {
highlighterPromise = (async () => {
const { createHighlighterCore } = await import("shiki/core");
const { createOnigurumaEngine } = await import(
"shiki/engine/oniguruma"
);
const hl = await createHighlighterCore({
themes: [
import("shiki/themes/github-light.mjs"),
import("shiki/themes/github-dark.mjs"),
],
langs: [
import("shiki/langs/javascript.mjs"),
import("shiki/langs/typescript.mjs"),
import("shiki/langs/python.mjs"),
import("shiki/langs/bash.mjs"),
import("shiki/langs/shell.mjs"),
import("shiki/langs/json.mjs"),
import("shiki/langs/html.mjs"),
import("shiki/langs/css.mjs"),
import("shiki/langs/markdown.mjs"),
import("shiki/langs/yaml.mjs"),
import("shiki/langs/toml.mjs"),
import("shiki/langs/rust.mjs"),
import("shiki/langs/go.mjs"),
import("shiki/langs/c.mjs"),
import("shiki/langs/cpp.mjs"),
import("shiki/langs/java.mjs"),
import("shiki/langs/sql.mjs"),
import("shiki/langs/svelte.mjs"),
import("shiki/langs/dockerfile.mjs"),
import("shiki/langs/xml.mjs"),
import("shiki/langs/ruby.mjs"),
import("shiki/langs/php.mjs"),
import("shiki/langs/swift.mjs"),
import("shiki/langs/kotlin.mjs"),
import("shiki/langs/lua.mjs"),
import("shiki/langs/tsx.mjs"),
import("shiki/langs/jsx.mjs"),
import("shiki/langs/scss.mjs"),
import("shiki/langs/graphql.mjs"),
import("shiki/langs/makefile.mjs"),
],
engine: createOnigurumaEngine(import("shiki/wasm")),
});
return hl;
})();
}
return highlighterPromise;
}
(async () => {
try {
if (!hljsModule) {
hljsModule = (await import('highlight.js')).default;
}
if (codeEl && currentCode === code) {
if (currentLang && hljsModule.getLanguage(currentLang)) {
codeEl.innerHTML = hljsModule.highlight(currentCode, { language: currentLang }).value;
} else {
codeEl.innerHTML = hljsModule.highlightAuto(currentCode).value;
}
highlighted = true;
}
} catch {
// Fallback: just show plain text
}
})();
});
// Highlight non-diff code: reactive so it re-runs on prop changes (streaming)
$effect(() => {
if (isDiff || !codeEl) return;
const currentCode = code;
const currentLang = language;
function handleCopy() {
navigator.clipboard.writeText(code);
copied = true;
setTimeout(() => { copied = false; }, 2000);
}
(async () => {
try {
const hl = await getHighlighter();
if (!codeEl || currentCode !== code) return;
const lang =
currentLang && hl.getLoadedLanguages().includes(currentLang)
? currentLang
: "text";
const html = hl.codeToHtml(currentCode, {
lang,
themes: { light: "github-light", dark: "github-dark" },
defaultColor: false, // use CSS variables for theme switching
});
// Shiki wraps in <pre style="--shiki-light:...;--shiki-dark:..."><code>...</code></pre>
// We extract the <code> innerHTML but must also transfer the CSS vars
// from <pre> onto our own <code> so base-color vars resolve.
const tmp = document.createElement("div");
tmp.innerHTML = html;
const shikiPre = tmp.querySelector("pre");
const shikiCode = tmp.querySelector("code");
if (shikiCode && codeEl) {
codeEl.innerHTML = shikiCode.innerHTML;
// Copy --shiki-* CSS vars from the discarded <pre> onto our <code>
if (shikiPre) {
const preStyle = shikiPre.getAttribute("style") || "";
const vars =
preStyle.match(/--shiki[\w-]*:[^;]+/g) || [];
vars.forEach((v) => {
const [name, val] = v.split(":");
if (name && val)
codeEl!.style.setProperty(
name.trim(),
val.trim(),
);
});
}
}
} catch {
// Fallback: just show plain text
}
})();
});
function handleCopy() {
navigator.clipboard.writeText(code);
copied = true;
setTimeout(() => {
copied = false;
}, 2000);
}
</script>
<div class="code-block">
<div class="code-header">
<span class="code-lang">{language || 'text'}</span>
<div class="code-actions">
{#if isDiff && onapply}
<button class="code-action apply" onclick={() => onapply?.(code)}>Apply</button>
<button class="code-action reject" onclick={() => onreject?.()}>Reject</button>
{/if}
<button class="code-action copy" onclick={handleCopy}>
{copied ? '✓' : 'Copy'}
</button>
</div>
</div>
<div
class="not-prose rounded-2xl overflow-hidden bg-black/[0.03] dark:bg-white/[0.03] border border-black/[0.06] dark:border-white/[0.06]"
>
<div class="flex items-center justify-between h-[30px] px-2.5">
<span class="text-[11px] font-medium text-gray-500 lowercase"
>{language || "text"}</span
>
<div class="flex items-center gap-1">
{#if isDiff && onapply}
<button
class="text-[11px] px-2 py-0.5 rounded text-green-600 hover:bg-green-600/10 transition-all duration-100"
onclick={() => onapply?.(code)}>Apply</button
>
<button
class="text-[11px] px-2 py-0.5 rounded text-red-600 hover:bg-red-600/10 transition-all duration-100"
onclick={() => onreject?.()}>Reject</button
>
{/if}
<button
class="text-[11px] px-2 py-0.5 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-white/[0.08] transition-all duration-100"
onclick={handleCopy}
>
{copied ? "✓" : "Copy"}
</button>
</div>
</div>
{#if isDiff}
<pre class="code-pre diff"><code>{#each diffLines as line}<span class="diff-line diff-{line.type}">{line.text}
</span>{/each}</code></pre>
{:else}
<pre class="code-pre"><code bind:this={codeEl}>{code}</code></pre>
{/if}
{#if isDiff}
<pre
class="!m-0 !pb-3 !px-4 overflow-x-auto text-[13px] leading-normal !bg-transparent font-mono"><code
>{#each diffLines as line}<span
class="diff-line diff-{line.type}"
>{line.text}
</span>{/each}</code
></pre>
{:else}
<pre
class="!m-0 !pb-3 !px-4 overflow-x-auto text-[13px] leading-normal !bg-transparent text-[#24292e] dark:text-[#e1e4e8] font-mono"><code
class="font-[inherit]"
bind:this={codeEl}>{code}</code
></pre>
{/if}
</div>
<style>
@reference "../../../app.css";
@reference "../../../app.css";
.code-block {
border-radius: 8px;
overflow: hidden;
background: var(--color-gray-100);
border: 1px solid var(--color-gray-200);
}
/* ── Shiki dual-theme: switch via CSS variables ── */
:global(.dark) .code-block {
background: rgba(255, 255, 255, 0.03);
border-color: rgba(255, 255, 255, 0.06);
}
pre :global(span) {
color: var(--shiki-light);
}
.code-header {
display: flex;
align-items: center;
justify-content: space-between;
height: 30px;
padding: 0 10px;
border-bottom: 1px solid var(--color-gray-200);
background: var(--color-gray-50);
}
:global(.dark) pre :global(span) {
color: var(--shiki-dark);
}
:global(.dark) .code-header {
border-bottom-color: rgba(255, 255, 255, 0.06);
background: rgba(255, 255, 255, 0.02);
}
/* ── Diff line coloring ──────────────────────── */
.code-lang {
font-size: 11px;
font-weight: 500;
color: var(--color-gray-500);
text-transform: lowercase;
}
.diff-line {
display: block;
}
.code-actions {
display: flex;
align-items: center;
gap: 4px;
}
.diff-line.diff-add {
background: rgba(22, 163, 74, 0.1);
color: #16a34a;
}
.code-action {
font-size: 11px;
padding: 2px 8px;
border-radius: 4px;
color: var(--color-gray-500);
transition: all 0.1s;
}
:global(.dark) .diff-line.diff-add {
background: rgba(34, 197, 94, 0.1);
color: #4ade80;
}
.code-action:hover {
color: var(--color-gray-700);
background: var(--color-gray-200);
}
.diff-line.diff-del {
background: rgba(220, 38, 38, 0.08);
color: #dc2626;
}
:global(.dark) .code-action:hover {
color: var(--color-gray-300);
background: rgba(255, 255, 255, 0.08);
}
:global(.dark) .diff-line.diff-del {
background: rgba(248, 113, 113, 0.1);
color: #f87171;
}
.code-action.apply {
color: #16a34a;
}
.diff-line.diff-range {
color: #8b5cf6;
}
.code-action.apply:hover {
background: rgba(22, 163, 74, 0.1);
}
.code-action.reject {
color: #dc2626;
}
.code-action.reject:hover {
background: rgba(220, 38, 38, 0.1);
}
.code-pre {
margin: 0;
padding: 12px 16px;
overflow-x: auto;
font-size: 13px;
line-height: 1.5;
font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
.code-pre code {
font-family: inherit;
}
/* ── Diff line coloring ──────────────────────── */
.diff-line {
display: block;
}
.diff-line.diff-add {
background: rgba(22, 163, 74, 0.1);
color: #16a34a;
}
:global(.dark) .diff-line.diff-add {
background: rgba(34, 197, 94, 0.1);
color: #4ade80;
}
.diff-line.diff-del {
background: rgba(220, 38, 38, 0.08);
color: #dc2626;
}
:global(.dark) .diff-line.diff-del {
background: rgba(248, 113, 113, 0.1);
color: #f87171;
}
.diff-line.diff-range {
color: #8b5cf6;
}
:global(.dark) .diff-line.diff-range {
color: #a78bfa;
}
/* ── highlight.js token colors ────────────────── */
.code-pre :global(.hljs-keyword),
.code-pre :global(.hljs-selector-tag),
.code-pre :global(.hljs-built_in) {
color: #d73a49;
}
.code-pre :global(.hljs-string),
.code-pre :global(.hljs-attr) {
color: #032f62;
}
.code-pre :global(.hljs-comment),
.code-pre :global(.hljs-quote) {
color: #6a737d;
font-style: italic;
}
.code-pre :global(.hljs-number),
.code-pre :global(.hljs-literal) {
color: #005cc5;
}
.code-pre :global(.hljs-title),
.code-pre :global(.hljs-section) {
color: #6f42c1;
}
.code-pre :global(.hljs-type),
.code-pre :global(.hljs-name) {
color: #22863a;
}
.code-pre :global(.hljs-meta) {
color: #735c0f;
}
/* Dark mode hljs overrides */
:global(.dark) .code-pre :global(.hljs-keyword),
:global(.dark) .code-pre :global(.hljs-selector-tag),
:global(.dark) .code-pre :global(.hljs-built_in) {
color: #ff7b72;
}
:global(.dark) .code-pre :global(.hljs-string),
:global(.dark) .code-pre :global(.hljs-attr) {
color: #a5d6ff;
}
:global(.dark) .code-pre :global(.hljs-comment),
:global(.dark) .code-pre :global(.hljs-quote) {
color: #8b949e;
}
:global(.dark) .code-pre :global(.hljs-number),
:global(.dark) .code-pre :global(.hljs-literal) {
color: #79c0ff;
}
:global(.dark) .code-pre :global(.hljs-title),
:global(.dark) .code-pre :global(.hljs-section) {
color: #d2a8ff;
}
:global(.dark) .code-pre :global(.hljs-type),
:global(.dark) .code-pre :global(.hljs-name) {
color: #7ee787;
}
:global(.dark) .code-pre :global(.hljs-meta) {
color: #d29922;
}
:global(.dark) .diff-line.diff-range {
color: #a78bfa;
}
</style>
+5
View File
@@ -67,6 +67,7 @@ export type ToolApprovalMode = 'ask' | 'auto' | 'full';
export interface UserPreferences {
theme: Theme;
sidebarOpen: boolean;
sidebarWidth: number;
toolApprovalMode: ToolApprovalMode;
locale: string;
workspaceOrder?: string[]; // ordered paths for sidebar drag-reorder
@@ -114,6 +115,7 @@ export const workspaceList = writable<{ path: string; name: string }[]>([]);
/** Global user preferences. */
export const sidebarOpen = writable(typeof window !== 'undefined' ? window.innerWidth >= 768 : false);
export const sidebarWidth = writable(220);
export const theme = writable<Theme>('dark');
export const toolApprovalMode = writable<ToolApprovalMode>('auto');
/** @deprecated Use toolApprovalMode */
@@ -255,6 +257,7 @@ function persistPreferences(): void {
const prefs: UserPreferences = {
theme: get(theme),
sidebarOpen: get(sidebarOpen),
sidebarWidth: get(sidebarWidth),
toolApprovalMode: get(toolApprovalMode),
locale: i18next.language,
workspaceOrder: get(workspaceOrder),
@@ -270,6 +273,7 @@ function subscribeForPersistence() {
currentWorkspace.subscribe(() => { if (get(stateLoaded)) persistWorkspace(); });
theme.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
sidebarOpen.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
sidebarWidth.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
toolApprovalMode.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
workspaceOrder.subscribe(() => { if (get(stateLoaded)) persistPreferences(); });
i18next.on('languageChanged', () => { if (get(stateLoaded)) persistPreferences(); });
@@ -282,6 +286,7 @@ export async function loadPreferences(): Promise<void> {
const prefs = await getPreferences();
if (prefs.theme) theme.set(prefs.theme as Theme);
if (prefs.sidebarOpen !== undefined) sidebarOpen.set(prefs.sidebarOpen as boolean);
if (prefs.sidebarWidth !== undefined) sidebarWidth.set(prefs.sidebarWidth as number);
// Support new toolApprovalMode and legacy boolean autoApproveTools
if (prefs.toolApprovalMode) {
toolApprovalMode.set(prefs.toolApprovalMode as ToolApprovalMode);
+29
View File
@@ -0,0 +1,29 @@
/**
* Shared file icon name resolver.
* Maps file names/extensions to Icon component names.
*/
export function fileIconName(name: string, type: string = 'file'): string {
if (type === 'directory') return 'folder';
const ext = name.split('.').pop()?.toLowerCase() ?? '';
if (name === 'Dockerfile') return 'docker';
if (name === 'LICENSE' || name === 'LICENSE.md') return 'page-text';
if (name.endsWith('.lock')) return 'lock';
switch (ext) {
case 'md': return 'page-text';
case 'ts': case 'tsx': case 'js': case 'jsx':
case 'py': case 'rs': case 'go': case 'java':
case 'c': case 'cpp': case 'h': case 'hpp':
case 'rb': case 'php': case 'swift': case 'kt':
case 'svelte': case 'vue':
return 'code';
case 'json': case 'yaml': case 'yml': case 'toml':
case 'ini': case 'cfg': case 'conf':
return 'settings';
case 'sh': case 'bash': case 'zsh':
return 'terminal';
case 'css': case 'html': case 'xml':
return 'code';
default: return 'empty-page';
}
}
+16 -5
View File
@@ -60,16 +60,21 @@ def _get_user(request: Request) -> str:
async def list_chats(
request: Request,
workspace: str = Query(..., description="Workspace root path"),
limit: int = Query(50, ge=1, le=200, description="Max chats to return"),
offset: int = Query(0, ge=0, description="Number of chats to skip"),
sort_by: str = Query("updated_at", description="Sort field: 'title' or 'updated_at'"),
sort_dir: str = Query("desc", description="Sort direction: 'asc' or 'desc'"),
):
"""List chats for a workspace by scanning .cptr/chats/ for JSON files.
Returns chat metadata with relative folder paths for sidebar display.
Supports pagination via limit/offset and sorting via sort_by/sort_dir.
"""
user_id = _get_user(request)
chats_dir = Path(workspace) / ".cptr" / "chats"
if not chats_dir.exists():
return {"chats": []}
return {"chats": [], "total": 0, "has_more": False}
# Collect chat IDs and their relative folder paths
chat_entries: list[dict] = []
@@ -81,7 +86,7 @@ async def list_chats(
chat_entries.append({"id": chat_id, "folder": rel_folder})
if not chat_entries:
return {"chats": []}
return {"chats": [], "total": 0, "has_more": False}
# Batch-fetch from DB
chat_ids = [e["id"] for e in chat_entries]
@@ -104,9 +109,13 @@ async def list_chats(
"updated_at": chat.updated_at,
})
# Sort: most recently updated first
result.sort(key=lambda c: c["updated_at"], reverse=True)
return {"chats": result}
# Sort by requested field
sort_field = sort_by if sort_by in ("title", "updated_at") else "updated_at"
reverse = sort_dir != "asc"
result.sort(key=lambda c: (c[sort_field] or ""), reverse=reverse)
total = len(result)
page = result[offset : offset + limit]
return {"chats": page, "total": total, "has_more": offset + limit < total}
# ── Models aggregation ──────────────────────────────────────
# NOTE: Must be declared before /{chat_id} to avoid 'models' being treated as a chat_id.
@@ -354,11 +363,13 @@ async def send_message(body: SendMessageRequest, request: Request):
assistant_parent = body.parent_id
else:
# Normal send: create user message first
user_meta = {"files": body.files} if body.files else None
user_msg = await ChatMessage.create(
chat_id=chat.id,
role="user",
content=body.content,
parent_id=body.parent_id,
meta=user_meta,
created_at=now_ms(),
)
assistant_parent = user_msg.id
+31 -8
View File
@@ -230,31 +230,52 @@ async def search_files(
path: str = Query(..., description="Root path to search"),
limit: int = Query(20, description="Max results"),
):
"""Fuzzy filename search. Walks tree, matches basename case-insensitively."""
"""Fuzzy filename search. Walks tree, matches basename case-insensitively.
Results are ranked: exact match > starts-with > contains.
Within each tier, shorter names rank higher (more specific match).
"""
root = Path(path).resolve()
if not root.exists() or not root.is_dir():
raise HTTPException(status_code=404, detail=f"Path not found: {path}")
query_lower = query.lower()
results: list[SearchResult] = []
# Collect all matches first, then rank
matches: list[tuple[int, int, SearchResult]] = [] # (score, name_len, result)
max_collect = limit * 10 # collect more than needed for ranking
def walk(directory: Path, depth: int = 0):
if depth > 8 or len(results) >= limit:
if depth > 8 or len(matches) >= max_collect:
return
try:
for item in sorted(directory.iterdir(), key=lambda p: p.name.lower()):
if item.name in SEARCH_IGNORE_DIRS or item.name.startswith("."):
continue
if len(results) >= limit:
if len(matches) >= max_collect:
return
if query_lower in item.name.lower():
results.append(SearchResult(
name_lower = item.name.lower()
if query_lower and query_lower in name_lower:
# Score: 0 = exact, 1 = starts-with, 2 = contains
if name_lower == query_lower:
score = 0
elif name_lower.startswith(query_lower):
score = 1
else:
score = 2
matches.append((score, len(item.name), SearchResult(
path=str(item),
name=item.name,
type="directory" if item.is_dir() else "file",
))
)))
elif not query_lower:
# Empty query: return top-level files
matches.append((2, len(item.name), SearchResult(
path=str(item),
name=item.name,
type="directory" if item.is_dir() else "file",
)))
if item.is_dir():
walk(item, depth + 1)
@@ -262,7 +283,9 @@ async def search_files(
pass
walk(root)
return SearchResponse(results=results)
# Sort by score (lower = better), then by name length (shorter = better)
matches.sort(key=lambda m: (m[0], m[1]))
return SearchResponse(results=[m[2] for m in matches[:limit]])
# ── File management ──────────────────────────────────────────────
+13
View File
@@ -305,6 +305,19 @@ async def _load_message_history(chat_id: str, message_id: str) -> list[dict]:
continue
entry: dict = {"role": m.role, "content": m.content or ""}
# Inject @file mention contents into user messages
if m.role == "user":
attached_files = (m.meta or {}).get("files", [])
if attached_files:
file_parts = []
for fpath in attached_files:
try:
text = Path(fpath).read_text(errors="replace")[:50_000]
file_parts.append(f"--- {fpath} ---\n{text}")
except Exception:
file_parts.append(f"--- {fpath} --- (unreadable)")
entry["content"] += "\n\n" + "\n\n".join(file_parts)
# Reconstruct tool calls from output items for the provider
if m.output:
tool_calls = []