mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-04 16:13:34 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b47557f40 | ||
|
|
13ea7c192e | ||
|
|
0d6bee2025 | ||
|
|
fba950aeb5 | ||
|
|
a047f913b4 | ||
|
|
44805ce481 | ||
|
|
a8eec32842 | ||
|
|
5d075e02ab |
No files matched your search
+1
-1
@@ -284,7 +284,7 @@ export function useNewProviderOAuth() {
|
||||
redirectUri: window.location.origin + '/oauth/newprovider',
|
||||
usePKCE: false, // Set to true if provider supports PKCE
|
||||
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
||||
const userUrl = proxyUrl(corsProxy, 'https://api.provider.com/user');
|
||||
const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.provider.com/user' });
|
||||
const userResponse = await fetch(userUrl, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
||||
Generated
+363
-21
@@ -20,6 +20,7 @@
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"@nostrify/nostrify": "^0.48.2",
|
||||
"@nostrify/react": "^0.2.20",
|
||||
"@opensecret/react": "^1.5.4",
|
||||
"@radix-ui/react-accordion": "^1.2.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||
@@ -2812,9 +2813,9 @@
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/sdk": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.25.1.tgz",
|
||||
"integrity": "sha512-yO28oVFFC7EBoiKdAn+VqRm+plcfv4v0xp6osG/VsCB0NlPZWi87ajbCZZ8f/RvOFLEu7//rSRmuZZ7lMoe3gQ==",
|
||||
"version": "1.25.2",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.25.2.tgz",
|
||||
"integrity": "sha512-LZFeo4F9M5qOhC/Uc1aQSrBHxMrvxett+9KLHt7OhcExtoiRN9DKgbZffMP/nxjutWDQpfMDfP3nkHI4X9ijww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@hono/node-server": "^1.19.7",
|
||||
@@ -3020,6 +3021,173 @@
|
||||
"resolved": "https://registry.npmjs.org/@nostrify/types/-/types-0.36.8.tgz",
|
||||
"integrity": "sha512-tmpz5pkU8oXu7+V1qxvAzuoo8s5x4Gvo7h+JRm+JAW6x/2VZ8aQoA54yhn89qZ9agciMJhVdhqCm1PlK55w17A=="
|
||||
},
|
||||
"node_modules/@opensecret/react": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@opensecret/react/-/react-1.5.4.tgz",
|
||||
"integrity": "sha512-nIrb1NfKIJ1G8IK+b8OnjXvPgc/C3GkLVbZVF9HCh6WBDV2yimg8B7Eo6Pqu5mUtiFrQslFL9UbeDj4Py0mbGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/x509": "^1.12.2",
|
||||
"@stablelib/base64": "^2.0.0",
|
||||
"@stablelib/chacha20poly1305": "^2.0.0",
|
||||
"@stablelib/random": "^2.0.0",
|
||||
"cbor2": "^1.7.0",
|
||||
"tweetnacl": "^1.0.3",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-cms": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.6.0.tgz",
|
||||
"integrity": "sha512-2uZqP+ggSncESeUF/9Su8rWqGclEfEiz1SyU02WX5fUONFfkjzS2Z/F1Li0ofSmf4JqYXIOdCAZqIXAIBAT1OA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"@peculiar/asn1-x509-attr": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-csr": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.6.0.tgz",
|
||||
"integrity": "sha512-BeWIu5VpTIhfRysfEp73SGbwjjoLL/JWXhJ/9mo4vXnz3tRGm+NGm3KNcRzQ9VMVqwYS2RHlolz21svzRXIHPQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-ecc": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.6.0.tgz",
|
||||
"integrity": "sha512-FF3LMGq6SfAOwUG2sKpPXblibn6XnEIKa+SryvUl5Pik+WR9rmRA3OCiwz8R3lVXnYnyRkSZsSLdml8H3UiOcw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pfx": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.6.0.tgz",
|
||||
"integrity": "sha512-rtUvtf+tyKGgokHHmZzeUojRZJYPxoD/jaN1+VAB4kKR7tXrnDCA/RAWXAIhMJJC+7W27IIRGe9djvxKgsldCQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.6.0",
|
||||
"@peculiar/asn1-pkcs8": "^2.6.0",
|
||||
"@peculiar/asn1-rsa": "^2.6.0",
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pkcs8": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.6.0.tgz",
|
||||
"integrity": "sha512-KyQ4D8G/NrS7Fw3XCJrngxmjwO/3htnA0lL9gDICvEQ+GJ+EPFqldcJQTwPIdvx98Tua+WjkdKHSC0/Km7T+lA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pkcs9": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.6.0.tgz",
|
||||
"integrity": "sha512-b78OQ6OciW0aqZxdzliXGYHASeCvvw5caqidbpQRYW2mBtXIX2WhofNXTEe7NyxTb0P6J62kAAWLwn0HuMF1Fw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.6.0",
|
||||
"@peculiar/asn1-pfx": "^2.6.0",
|
||||
"@peculiar/asn1-pkcs8": "^2.6.0",
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"@peculiar/asn1-x509-attr": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-rsa": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.6.0.tgz",
|
||||
"integrity": "sha512-Nu4C19tsrTsCp9fDrH+sdcOKoVfdfoQQ7S3VqjJU6vedR7tY3RLkQ5oguOIB3zFW33USDUuYZnPEQYySlgha4w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-schema": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.6.0.tgz",
|
||||
"integrity": "sha512-xNLYLBFTBKkCzEZIw842BxytQQATQv+lDTCEMZ8C196iJcJJMBUZxrhSTxLaohMyKK8QlzRNTRkUmanucnDSqg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asn1js": "^3.0.6",
|
||||
"pvtsutils": "^1.3.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-x509": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.6.0.tgz",
|
||||
"integrity": "sha512-uzYbPEpoQiBoTq0/+jZtpM6Gq6zADBx+JNFP3yqRgziWBxQ/Dt/HcuvRfm9zJTPdRcBqPNdaRHTVwpyiq6iNMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"pvtsutils": "^1.3.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-x509-attr": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.6.0.tgz",
|
||||
"integrity": "sha512-MuIAXFX3/dc8gmoZBkwJWxUWOSvG4MMDntXhrOZpJVMkYX+MYc/rUAU2uJOved9iJEoiUx7//3D8oG83a78UJA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"asn1js": "^3.0.6",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/x509": {
|
||||
"version": "1.14.3",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.3.tgz",
|
||||
"integrity": "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.6.0",
|
||||
"@peculiar/asn1-csr": "^2.6.0",
|
||||
"@peculiar/asn1-ecc": "^2.6.0",
|
||||
"@peculiar/asn1-pkcs9": "^2.6.0",
|
||||
"@peculiar/asn1-rsa": "^2.6.0",
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"pvtsutils": "^1.3.6",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"tslib": "^2.8.1",
|
||||
"tsyringe": "^4.10.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
@@ -4385,9 +4553,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@remix-run/router": {
|
||||
"version": "1.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.0.tgz",
|
||||
"integrity": "sha512-O3rHJzAQKamUz1fvE0Qaw0xSFqsA/yafi2iqeE0pvdFtCO1viYx8QL6f3Ln/aCCTLxs68SLf0KPM9eSeM8yBnA==",
|
||||
"version": "1.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.2.tgz",
|
||||
"integrity": "sha512-Ic6m2U/rMjTkhERIa/0ZtXJP17QUi2CbWE7cqx4J58M8aA3QTfW+2UlQ4psvTX9IO1RfNVhK3pcpdjej7L+t2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
@@ -4488,6 +4656,7 @@
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4501,6 +4670,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4514,6 +4684,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4527,6 +4698,7 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4540,6 +4712,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4553,6 +4726,7 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4566,6 +4740,7 @@
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4579,6 +4754,7 @@
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4592,6 +4768,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4605,6 +4782,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4618,6 +4796,7 @@
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4631,6 +4810,7 @@
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4644,6 +4824,7 @@
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4657,6 +4838,7 @@
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4670,6 +4852,7 @@
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4683,6 +4866,7 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4696,6 +4880,7 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4709,6 +4894,7 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4722,6 +4908,7 @@
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -4735,6 +4922,7 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -5015,6 +5203,89 @@
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/aead": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-2.0.0.tgz",
|
||||
"integrity": "sha512-U/RMANRxbT/ahIpYsPSiFwDFNjADHdnCFfmo09MO1ai2XmerPAOPtMl0qmX7XVvygnACC6ijKDyHBoT2rGyElg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@stablelib/base64": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-2.0.1.tgz",
|
||||
"integrity": "sha512-P2z89A7N1ETt6RxgpVdDT2xlg8cnm3n6td0lY9gyK7EiWK3wdq388yFX/hLknkCC0we05OZAD1rfxlQJUbl5VQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@stablelib/binary": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-2.0.1.tgz",
|
||||
"integrity": "sha512-U9iAO8lXgEDONsA0zPPSgcf3HUBNAqHiJmSHgZz62OvC3Hi2Bhc5kTnQ3S1/L+sthDTHtCMhcEiklmIly6uQ3w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stablelib/int": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/chacha": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-2.0.1.tgz",
|
||||
"integrity": "sha512-lS1FqtNqofxe2vLkRsLli2m3x/XanUyAYRphLhdHumKeIsLbjbCXdCq3Pf/eWiO7G3QlSG5ViqnoVjktzfLWMg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stablelib/binary": "^2.0.1",
|
||||
"@stablelib/wipe": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/chacha20poly1305": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/chacha20poly1305/-/chacha20poly1305-2.0.1.tgz",
|
||||
"integrity": "sha512-kOoBsXbDPVRlelzXl+5WViycgM19lD7lF3Bc3KWI+DzId0Stc2HlxAfSc+Xpn3RgqSCl1ZNTXr33LegqBhBBaw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stablelib/aead": "^2.0.0",
|
||||
"@stablelib/binary": "^2.0.1",
|
||||
"@stablelib/chacha": "^2.0.1",
|
||||
"@stablelib/constant-time": "^2.0.1",
|
||||
"@stablelib/poly1305": "^2.0.1",
|
||||
"@stablelib/wipe": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/constant-time": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/constant-time/-/constant-time-2.0.1.tgz",
|
||||
"integrity": "sha512-0NWPogffRm+UWBH0+iM5otZmNrVe5OHFIvyoNIVankMAYOQzMwcdVALOVPrB5Ho0dST+Oc3H8/hPh65Z8R/uew==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@stablelib/int": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/int/-/int-2.0.1.tgz",
|
||||
"integrity": "sha512-Ht63fQp3wz/F8U4AlXEPb7hfJOIILs8Lq55jgtD7KueWtyjhVuzcsGLSTAWtZs3XJDZYdF1WcSKn+kBtbzupww==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@stablelib/poly1305": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-2.0.1.tgz",
|
||||
"integrity": "sha512-D8xfZcL/5zeVARJ9I2fZOUCnZvsJx8G4JDQvD+ecsnaCildPtqZDwqqjtOc4cfHAdScrMjOzUVsssjXUTBw3YQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stablelib/constant-time": "^2.0.1",
|
||||
"@stablelib/wipe": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/random": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/random/-/random-2.0.1.tgz",
|
||||
"integrity": "sha512-W6GAtXEEs7r+dSbuBsvoFmlyL3gLxle41tQkjKu17dDWtDdjhVUbtRfRCQcCUeczwkgjQxMPopgwYEvxXtHXGw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stablelib/binary": "^2.0.1",
|
||||
"@stablelib/wipe": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@stablelib/wipe": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-2.0.1.tgz",
|
||||
"integrity": "sha512-1eU2K9EgOcV4qc9jcP6G72xxZxEm5PfeI5H55l08W95b4oRJaqhmlWRc4xZAm6IVSKhVNxMi66V67hCzzuMTAg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@std/encoding": {
|
||||
"name": "@jsr/std__encoding",
|
||||
"version": "1.0.10",
|
||||
@@ -6297,6 +6568,20 @@
|
||||
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/asn1js": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.7.tgz",
|
||||
"integrity": "sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"pvtsutils": "^1.3.6",
|
||||
"pvutils": "^1.1.3",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/assertion-error": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||
@@ -6762,6 +7047,15 @@
|
||||
],
|
||||
"license": "CC-BY-4.0"
|
||||
},
|
||||
"node_modules/cbor2": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/cbor2/-/cbor2-1.12.0.tgz",
|
||||
"integrity": "sha512-3Cco8XQhi27DogSp9Ri6LYNZLi/TBY/JVnDe+mj06NkBjW/ZYOtekaEU4wZ4xcRMNrFkDv8KNtOAqHyDfz3lYg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.7"
|
||||
}
|
||||
},
|
||||
"node_modules/ccount": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
|
||||
@@ -9180,9 +9474,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/hono": {
|
||||
"version": "4.11.1",
|
||||
"resolved": "https://registry.npmjs.org/hono/-/hono-4.11.1.tgz",
|
||||
"integrity": "sha512-KsFcH0xxHes0J4zaQgWbYwmz3UPOOskdqZmItstUG93+Wk1ePBLkLGwbP9zlmh1BFUiL8Qp+Xfu9P7feJWpGNg==",
|
||||
"version": "4.11.4",
|
||||
"resolved": "https://registry.npmjs.org/hono/-/hono-4.11.4.tgz",
|
||||
"integrity": "sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
@@ -12510,6 +12804,24 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pvtsutils": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",
|
||||
"integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pvutils": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.5.tgz",
|
||||
"integrity": "sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
|
||||
@@ -12528,9 +12840,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
|
||||
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
@@ -12796,12 +13108,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "6.30.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.0.tgz",
|
||||
"integrity": "sha512-D3X8FyH9nBcTSHGdEKurK7r8OYE1kKFn3d/CF+CoxbSHkxU7o37+Uh7eAHRXr6k2tSExXYO++07PeXJtA/dEhQ==",
|
||||
"version": "6.30.3",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.3.tgz",
|
||||
"integrity": "sha512-XRnlbKMTmktBkjCLE8/XcZFlnHvr2Ltdr1eJX4idL55/9BbORzyZEaIkBFDhFGCEWBBItsVrDxwx3gnisMitdw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@remix-run/router": "1.23.0"
|
||||
"@remix-run/router": "1.23.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
@@ -12811,13 +13123,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "6.30.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.0.tgz",
|
||||
"integrity": "sha512-x30B78HV5tFk8ex0ITwzC9TTZMua4jGyA9IUlH1JLQYQTFyxr/ZxwOJq7evg1JX1qGVUcvhsmQSKdPncQrjTgA==",
|
||||
"version": "6.30.3",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.3.tgz",
|
||||
"integrity": "sha512-pxPcv1AczD4vso7G4Z3TKcvlxK7g7TNt3/FNGMhfqyntocvYKj+GCatfigGDjbLozC4baguJ0ReCigoDJXb0ag==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@remix-run/router": "1.23.0",
|
||||
"react-router": "6.30.0"
|
||||
"@remix-run/router": "1.23.2",
|
||||
"react-router": "6.30.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
@@ -12961,6 +13273,12 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/reflect-metadata": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",
|
||||
"integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/reflect.getprototypeof": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
|
||||
@@ -14678,6 +14996,24 @@
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/tsyringe": {
|
||||
"version": "4.10.0",
|
||||
"resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.10.0.tgz",
|
||||
"integrity": "sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tsyringe/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/turndown": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.1.tgz",
|
||||
@@ -14687,6 +15023,12 @@
|
||||
"@mixmark-io/domino": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tweetnacl": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
|
||||
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"@nostrify/nostrify": "^0.48.2",
|
||||
"@nostrify/react": "^0.2.20",
|
||||
"@opensecret/react": "^1.5.4",
|
||||
"@radix-ui/react-accordion": "^1.2.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||
|
||||
@@ -1041,12 +1041,31 @@ export function AIProviderConfigDialog({
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="provider-auth">{t('authentication')}</Label>
|
||||
<Select
|
||||
value={localProvider.nostr ? 'nostr' : 'api-key'}
|
||||
onValueChange={(value: 'api-key' | 'nostr') => setLocalProvider({
|
||||
...localProvider,
|
||||
nostr: value === 'nostr' || undefined,
|
||||
apiKey: value === 'nostr' ? undefined : localProvider.apiKey
|
||||
})}
|
||||
value={localProvider.nostr ? 'nostr' : localProvider.openSecret ? 'opensecret' : 'api-key'}
|
||||
onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
|
||||
if (value === 'nostr') {
|
||||
setLocalProvider({
|
||||
...localProvider,
|
||||
nostr: true,
|
||||
openSecret: undefined,
|
||||
apiKey: undefined
|
||||
});
|
||||
} else if (value === 'opensecret') {
|
||||
setLocalProvider({
|
||||
...localProvider,
|
||||
nostr: undefined,
|
||||
openSecret: localProvider.openSecret,
|
||||
apiKey: localProvider.apiKey
|
||||
});
|
||||
} else {
|
||||
setLocalProvider({
|
||||
...localProvider,
|
||||
nostr: undefined,
|
||||
openSecret: undefined,
|
||||
apiKey: localProvider.apiKey
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
@@ -1054,10 +1073,25 @@ export function AIProviderConfigDialog({
|
||||
<SelectContent>
|
||||
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
||||
<SelectItem value="nostr">Nostr</SelectItem>
|
||||
<SelectItem value="opensecret">OpenSecret</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{localProvider.openSecret && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="provider-opensecret-url">
|
||||
OpenSecret API URL <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="provider-opensecret-url"
|
||||
placeholder="https://enclave.trymaple.ai"
|
||||
value={localProvider.openSecret || ''}
|
||||
onChange={(e) => setLocalProvider({ ...localProvider, openSecret: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!localProvider.nostr && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="provider-apiKey">{t('apiKey')}</Label>
|
||||
|
||||
@@ -50,7 +50,8 @@ export function AddCustomAIProviderDialog({
|
||||
const [customIdManuallyEdited, setCustomIdManuallyEdited] = useState(false);
|
||||
const [customBaseURL, setCustomBaseURL] = useState('');
|
||||
const [customApiKey, setCustomApiKey] = useState('');
|
||||
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr'>('api-key');
|
||||
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr' | 'opensecret'>('api-key');
|
||||
const [customOpenSecretUrl, setCustomOpenSecretUrl] = useState('');
|
||||
const [customProxy, setCustomProxy] = useState(false);
|
||||
|
||||
const handleAdd = () => {
|
||||
@@ -66,6 +67,11 @@ export function AddCustomAIProviderDialog({
|
||||
provider.apiKey = customApiKey.trim();
|
||||
} else if (customAuthMethod === 'nostr') {
|
||||
provider.nostr = true;
|
||||
} else if (customAuthMethod === 'opensecret') {
|
||||
provider.openSecret = customOpenSecretUrl.trim();
|
||||
if (customApiKey.trim()) {
|
||||
provider.apiKey = customApiKey.trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (customProxy) {
|
||||
@@ -81,6 +87,7 @@ export function AddCustomAIProviderDialog({
|
||||
setCustomBaseURL('');
|
||||
setCustomApiKey('');
|
||||
setCustomAuthMethod('api-key');
|
||||
setCustomOpenSecretUrl('');
|
||||
setCustomProxy(false);
|
||||
|
||||
onOpenChange(false);
|
||||
@@ -89,6 +96,7 @@ export function AddCustomAIProviderDialog({
|
||||
const isValid = customProviderName.trim() &&
|
||||
customProviderId.trim() &&
|
||||
customBaseURL.trim() &&
|
||||
(customAuthMethod !== 'opensecret' || customOpenSecretUrl.trim()) &&
|
||||
!existingIds.includes(customProviderId.trim());
|
||||
|
||||
const idExists = existingIds.includes(customProviderId.trim());
|
||||
@@ -156,7 +164,7 @@ export function AddCustomAIProviderDialog({
|
||||
<Label htmlFor="custom-auth">{t('authentication')}</Label>
|
||||
<Select
|
||||
value={customAuthMethod}
|
||||
onValueChange={(value: 'api-key' | 'nostr') => {
|
||||
onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
|
||||
setCustomAuthMethod(value);
|
||||
if (value === 'nostr') {
|
||||
setCustomApiKey(''); // Clear API key when switching to Nostr auth
|
||||
@@ -169,11 +177,26 @@ export function AddCustomAIProviderDialog({
|
||||
<SelectContent>
|
||||
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
||||
<SelectItem value="nostr">Nostr</SelectItem>
|
||||
<SelectItem value="opensecret">OpenSecret</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{customAuthMethod === 'api-key' && (
|
||||
{customAuthMethod === 'opensecret' && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="custom-opensecret-url">
|
||||
OpenSecret API URL <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="custom-opensecret-url"
|
||||
placeholder="https://enclave.trymaple.ai"
|
||||
value={customOpenSecretUrl}
|
||||
onChange={(e) => setCustomOpenSecretUrl(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(customAuthMethod === 'api-key' || customAuthMethod === 'opensecret') && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="custom-apikey">{t('apiKey')}</Label>
|
||||
<PasswordInput
|
||||
|
||||
@@ -33,10 +33,10 @@ export function ExternalFavicon({
|
||||
const parsedUrl = new URL(url);
|
||||
|
||||
// Strip `ai.` and `api.` subdomains for a better chance at finding a favicon
|
||||
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.)/, '');
|
||||
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.|enclave\.)/, '');
|
||||
|
||||
// Normalize the URL to ensure it has a protocol
|
||||
return faviconUrl(config.faviconUrl, parsedUrl);
|
||||
return faviconUrl({ template: config.faviconUrl, url: parsedUrl });
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ export function ProjectTitleMenu({
|
||||
className="gap-2"
|
||||
>
|
||||
<MessageSquarePlus className="h-4 w-4" />
|
||||
{t('newChat')}
|
||||
New Chat
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
/** Visual divider between chat sessions */
|
||||
export function SessionDivider() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3 text-xs text-muted-foreground py-4">
|
||||
<div className="flex-1 h-px bg-border" />
|
||||
<span className="uppercase tracking-wide">
|
||||
{t('newChat', 'New chat')}
|
||||
</span>
|
||||
<div className="flex-1 h-px bg-border" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { OnboardingDialog } from '@/components/OnboardingDialog';
|
||||
import { ChevronDown, ChevronUp, Play } from 'lucide-react';
|
||||
import { ChevronDown, Play } from 'lucide-react';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
import { useFSPaths } from '@/hooks/useFSPaths';
|
||||
@@ -47,12 +47,11 @@ import OpenAI from 'openai';
|
||||
import { useGit } from '@/hooks/useGit';
|
||||
import { Quilly } from '@/components/Quilly';
|
||||
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||
import { SessionDivider } from '@/components/SessionDivider';
|
||||
import { ChatInput } from '@/components/Shakespeare/ChatInput';
|
||||
import { buildMessageContent } from '@/lib/buildMessageContent';
|
||||
import { DotAI } from '@/lib/DotAI';
|
||||
import { parseProviderModel } from '@/lib/parseProviderModel';
|
||||
import { AIMessage, DisplayMessage } from '@/lib/SessionManager';
|
||||
import { AIMessage } from '@/lib/SessionManager';
|
||||
|
||||
// Clean interfaces now handled by proper hooks
|
||||
|
||||
@@ -295,13 +294,9 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
|
||||
const {
|
||||
messages,
|
||||
displayMessages,
|
||||
sessionName,
|
||||
streamingMessage,
|
||||
isLoading: internalIsLoading,
|
||||
isLoadingHistory,
|
||||
hasMoreHistory,
|
||||
isLoadingMoreHistory,
|
||||
totalCost,
|
||||
lastInputTokens,
|
||||
lastFinishReason,
|
||||
@@ -310,7 +305,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
startGeneration,
|
||||
stopGeneration,
|
||||
startNewSession: internalStartNewSession,
|
||||
loadMoreHistory,
|
||||
} = useAIChat({
|
||||
projectId,
|
||||
tools,
|
||||
@@ -324,7 +318,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
const checkTemplateInfo = async () => {
|
||||
try {
|
||||
// Only check if we have at least 1 message
|
||||
if (displayMessages.length === 0) {
|
||||
if (messages.length === 0) {
|
||||
setShowTemplateInfo(false);
|
||||
return;
|
||||
}
|
||||
@@ -363,7 +357,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
};
|
||||
|
||||
checkTemplateInfo();
|
||||
}, [fs, projectsPath, projectId, displayMessages.length]);
|
||||
}, [fs, projectsPath, projectId, messages.length]);
|
||||
|
||||
// Handle console error help requests
|
||||
const handleConsoleErrorHelp = useCallback(async () => {
|
||||
@@ -442,11 +436,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
// Function to scroll to bottom
|
||||
const scrollToBottom = useCallback(() => {
|
||||
if (scrollAreaRef.current) {
|
||||
requestAnimationFrame(() => {
|
||||
if (scrollAreaRef.current) {
|
||||
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
|
||||
}
|
||||
});
|
||||
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -499,20 +489,17 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
|
||||
useEffect(() => {
|
||||
if (scrollAreaRef.current && (messages || streamingMessage)) {
|
||||
const container = scrollAreaRef.current;
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
const isUserMessage = lastMessage?.role === 'user';
|
||||
|
||||
// Check if user was already near the bottom (within 100px threshold)
|
||||
// Check if user was already at or near the bottom (within 100px threshold)
|
||||
const threshold = 100;
|
||||
const container = scrollAreaRef.current;
|
||||
const isNearBottom = container.scrollTop + container.clientHeight >= container.scrollHeight - threshold;
|
||||
|
||||
// Scroll to bottom if user sent a message or was already near the bottom
|
||||
if (isUserMessage || isNearBottom) {
|
||||
scrollToBottom();
|
||||
// Only auto-scroll if user was already near the bottom
|
||||
if (isNearBottom) {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
}
|
||||
}, [messages, streamingMessage, isLoading, scrollToBottom]);
|
||||
}, [messages, streamingMessage, isLoading]);
|
||||
|
||||
// Scroll to bottom when first visiting a project (including page refresh)
|
||||
useEffect(() => {
|
||||
@@ -590,11 +577,8 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
// Add model to recently used when sending a message
|
||||
addRecentlyUsedModel(modelToUse);
|
||||
|
||||
// Scroll to bottom when user sends a message
|
||||
scrollToBottom();
|
||||
|
||||
await sendMessage(messageContent, modelToUse);
|
||||
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath, scrollToBottom]);
|
||||
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath]);
|
||||
|
||||
// Handle textarea focus - show onboarding if not configured
|
||||
const handleTextareaFocus = useCallback(() => {
|
||||
@@ -773,7 +757,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
)}
|
||||
|
||||
{/* Empty state when no messages and not loading */}
|
||||
{!isLoadingHistory && displayMessages.length === 0 && !streamingMessage && !isLoading && (
|
||||
{!isLoadingHistory && messages.length === 0 && !streamingMessage && !isLoading && (
|
||||
<div className="flex-1 flex items-center justify-center min-h-[400px]">
|
||||
<div className="text-center space-y-4 max-w-md mx-auto">
|
||||
<div className="mb-6">
|
||||
@@ -797,49 +781,13 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Load older messages button */}
|
||||
{!isLoadingHistory && hasMoreHistory && (
|
||||
<div className="flex justify-center py-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={async () => {
|
||||
const container = scrollAreaRef.current;
|
||||
const oldScrollHeight = container?.scrollHeight || 0;
|
||||
await loadMoreHistory();
|
||||
// Preserve scroll position after prepending content
|
||||
if (container) {
|
||||
requestAnimationFrame(() => {
|
||||
container.scrollTop += container.scrollHeight - oldScrollHeight;
|
||||
});
|
||||
}
|
||||
}}
|
||||
disabled={isLoadingMoreHistory}
|
||||
className="gap-2 text-muted-foreground"
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
{isLoadingMoreHistory ? t('loading') : t('loadOlderMessages', 'Load older messages')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isLoadingHistory && displayMessages.map((message, index) => {
|
||||
// Get the current message's session ID and compare to previous
|
||||
const currentSessionId = (message as DisplayMessage).sessionId;
|
||||
const prevSessionId = index > 0 ? (displayMessages[index - 1] as DisplayMessage).sessionId : undefined;
|
||||
|
||||
// Show divider when session changes (not on first message)
|
||||
const showDivider = index > 0 && currentSessionId !== prevSessionId;
|
||||
|
||||
// Dim messages from older sessions (compare against current active session)
|
||||
const isOlderSession = currentSessionId !== sessionName;
|
||||
|
||||
{!isLoadingHistory && messages.map((message, index) => {
|
||||
// Find the corresponding tool call for tool messages
|
||||
let toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined = undefined;
|
||||
if (message.role === 'tool') {
|
||||
// Look backwards to find the assistant message with matching tool call
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
const prevMessage = displayMessages[i];
|
||||
const prevMessage = messages[i];
|
||||
if (prevMessage.role === 'assistant' && 'tool_calls' in prevMessage && prevMessage.tool_calls) {
|
||||
toolCall = prevMessage.tool_calls.find(tc => tc.id === message.tool_call_id);
|
||||
if (toolCall) break;
|
||||
@@ -848,27 +796,14 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
<AIMessageItem
|
||||
key={`${index}-${message.role}-${typeof message.content === 'string' ? message.content.slice(0, 50) : 'content'}`}
|
||||
className={isOlderSession ? 'opacity-65' : ''}
|
||||
>
|
||||
{showDivider && <SessionDivider />}
|
||||
<AIMessageItem
|
||||
message={message}
|
||||
toolCall={toolCall}
|
||||
/>
|
||||
</div>
|
||||
message={message}
|
||||
toolCall={toolCall}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Trailing session divider - shown when New Chat is clicked before sending a message */}
|
||||
{!isLoadingHistory && displayMessages.length > 0 && (() => {
|
||||
const lastSessionId = (displayMessages[displayMessages.length - 1] as DisplayMessage).sessionId;
|
||||
return sessionName && lastSessionId && sessionName !== lastSessionId ? (
|
||||
<SessionDivider key="trailing-divider" />
|
||||
) : null;
|
||||
})()}
|
||||
|
||||
{!isLoadingHistory && renderStreamingMessage()}
|
||||
|
||||
{/* Resume button - shown when not loading and finish reason is not "stop" or "length" (or no finish reason) */}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
import { useEffect, useRef, useState, useCallback } from 'react';
|
||||
import { MessageSquare, Minus, X } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ChatPane, type ChatPaneRef } from '@/components/Shakespeare/ChatPane';
|
||||
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||
import { ProjectPreviewConsoleError } from '@/lib/consoleMessages';
|
||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface FloatingChatWidgetProps {
|
||||
projectId: string;
|
||||
isMinimized: boolean;
|
||||
onToggleMinimize: () => void;
|
||||
onClose: () => void;
|
||||
onNewChat: () => void;
|
||||
onFirstInteraction?: () => void;
|
||||
onLoadingChange?: (isLoading: boolean) => void;
|
||||
isLoading?: boolean;
|
||||
isBuildLoading?: boolean;
|
||||
consoleError?: ProjectPreviewConsoleError | null;
|
||||
onDismissConsoleError?: () => void;
|
||||
}
|
||||
|
||||
interface ChatSize {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
const MIN_WIDTH = 320;
|
||||
const MIN_HEIGHT = 380;
|
||||
const MAX_WIDTH = 720;
|
||||
const MAX_HEIGHT = 900;
|
||||
const DEFAULT_WIDTH = 420;
|
||||
const DEFAULT_HEIGHT = 520;
|
||||
|
||||
export function FloatingChatWidget({
|
||||
projectId,
|
||||
isMinimized,
|
||||
onToggleMinimize,
|
||||
onClose,
|
||||
onNewChat,
|
||||
onFirstInteraction,
|
||||
onLoadingChange,
|
||||
isLoading,
|
||||
isBuildLoading,
|
||||
consoleError,
|
||||
onDismissConsoleError,
|
||||
}: FloatingChatWidgetProps) {
|
||||
const chatPaneRef = useRef<ChatPaneRef>(null);
|
||||
const [size, setSize] = useLocalStorage<ChatSize>('shk:floatingChatSize', {
|
||||
width: DEFAULT_WIDTH,
|
||||
height: DEFAULT_HEIGHT,
|
||||
});
|
||||
const [isResizing, setIsResizing] = useState(false);
|
||||
const resizeStartRef = useRef<{ x: number; y: number; width: number; height: number } | null>(null);
|
||||
|
||||
// Handle keyboard escape to minimize
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !isMinimized) {
|
||||
onToggleMinimize();
|
||||
}
|
||||
};
|
||||
|
||||
if (!isMinimized) {
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
return () => window.removeEventListener('keydown', handleKeyDown);
|
||||
}
|
||||
}, [isMinimized, onToggleMinimize]);
|
||||
|
||||
// Resize handlers
|
||||
const startResize = useCallback((e: React.PointerEvent, direction: 'right' | 'bottom' | 'top' | 'bottomLeft' | 'topRight') => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const target = e.currentTarget as HTMLElement;
|
||||
target.setPointerCapture(e.pointerId);
|
||||
|
||||
setIsResizing(true);
|
||||
document.body.style.userSelect = 'none';
|
||||
|
||||
resizeStartRef.current = {
|
||||
x: e.clientX,
|
||||
y: e.clientY,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
};
|
||||
|
||||
const handlePointerMove = (moveEvent: PointerEvent) => {
|
||||
if (!resizeStartRef.current) return;
|
||||
|
||||
const maxW = Math.min(MAX_WIDTH, window.innerWidth - 16);
|
||||
const maxH = Math.min(MAX_HEIGHT, window.innerHeight - 16);
|
||||
|
||||
let newWidth = resizeStartRef.current.width;
|
||||
let newHeight = resizeStartRef.current.height;
|
||||
|
||||
// Handle horizontal resizing (left edge for bottom-right anchored widget)
|
||||
if (direction === 'right' || direction === 'bottomLeft' || direction === 'topRight') {
|
||||
const deltaX = resizeStartRef.current.x - moveEvent.clientX;
|
||||
newWidth = Math.max(MIN_WIDTH, Math.min(maxW, resizeStartRef.current.width + deltaX));
|
||||
}
|
||||
|
||||
// Handle vertical resizing from bottom (grows downward)
|
||||
if (direction === 'bottom' || direction === 'bottomLeft') {
|
||||
const deltaY = resizeStartRef.current.y - moveEvent.clientY;
|
||||
newHeight = Math.max(MIN_HEIGHT, Math.min(maxH, resizeStartRef.current.height + deltaY));
|
||||
}
|
||||
|
||||
// Handle vertical resizing from top (grows upward, widget anchored at bottom)
|
||||
if (direction === 'top' || direction === 'topRight') {
|
||||
const deltaY = moveEvent.clientY - resizeStartRef.current.y;
|
||||
newHeight = Math.max(MIN_HEIGHT, Math.min(maxH, resizeStartRef.current.height - deltaY));
|
||||
}
|
||||
|
||||
setSize({ width: newWidth, height: newHeight });
|
||||
};
|
||||
|
||||
const handlePointerUp = () => {
|
||||
setIsResizing(false);
|
||||
document.body.style.userSelect = '';
|
||||
resizeStartRef.current = null;
|
||||
|
||||
window.removeEventListener('pointermove', handlePointerMove);
|
||||
window.removeEventListener('pointerup', handlePointerUp);
|
||||
};
|
||||
|
||||
window.addEventListener('pointermove', handlePointerMove);
|
||||
window.addEventListener('pointerup', handlePointerUp);
|
||||
}, [size, setSize]);
|
||||
|
||||
if (isMinimized) {
|
||||
return (
|
||||
<div className="fixed right-4 bottom-4 z-50">
|
||||
<Button
|
||||
onClick={onToggleMinimize}
|
||||
size="icon"
|
||||
className="h-14 w-14 rounded-full shadow-lg hover:shadow-xl transition-all duration-200"
|
||||
aria-label="Open chat"
|
||||
>
|
||||
<MessageSquare className="h-6 w-6" />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"fixed right-4 bottom-4 z-50",
|
||||
"rounded-lg border shadow-2xl bg-background",
|
||||
"flex flex-col overflow-hidden",
|
||||
isResizing && "select-none"
|
||||
)}
|
||||
style={{
|
||||
width: `${size.width}px`,
|
||||
height: `${size.height}px`,
|
||||
maxWidth: '92vw',
|
||||
maxHeight: '70vh',
|
||||
}}
|
||||
>
|
||||
{/* Header - Styled like ProjectSidebar */}
|
||||
<div className="h-12 px-4 border-b flex-shrink-0 flex items-center justify-between bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur">
|
||||
<div className="flex items-center gap-2">
|
||||
<ShakespeareLogo className="w-5 h-5" />
|
||||
<h2 className="text-base font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Shakespeare
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
onClick={onToggleMinimize}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
aria-label="Minimize chat"
|
||||
>
|
||||
<Minus className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={onClose}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
aria-label="Close floating chat"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Chat Body */}
|
||||
<div className="flex-1 min-h-0 overflow-hidden">
|
||||
<div className="h-full">
|
||||
<ChatPane
|
||||
ref={chatPaneRef}
|
||||
projectId={projectId}
|
||||
onNewChat={onNewChat}
|
||||
onFirstInteraction={onFirstInteraction}
|
||||
onLoadingChange={onLoadingChange}
|
||||
isLoading={isLoading}
|
||||
isBuildLoading={isBuildLoading}
|
||||
consoleError={consoleError}
|
||||
onDismissConsoleError={onDismissConsoleError}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Resize Handles */}
|
||||
{/* Left edge (appears as "right" from widget perspective, but it's on the left side) */}
|
||||
<div
|
||||
className="absolute top-0 left-0 h-full w-2 cursor-ew-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
|
||||
onPointerDown={(e) => startResize(e, 'right')}
|
||||
style={{ touchAction: 'none' }}
|
||||
/>
|
||||
|
||||
{/* Top edge */}
|
||||
<div
|
||||
className="absolute top-0 left-0 w-full h-2 cursor-ns-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
|
||||
onPointerDown={(e) => startResize(e, 'top')}
|
||||
style={{ touchAction: 'none' }}
|
||||
/>
|
||||
|
||||
{/* Bottom edge */}
|
||||
<div
|
||||
className="absolute bottom-0 left-0 w-full h-2 cursor-ns-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
|
||||
onPointerDown={(e) => startResize(e, 'bottom')}
|
||||
style={{ touchAction: 'none' }}
|
||||
/>
|
||||
|
||||
{/* Bottom-left corner */}
|
||||
<div
|
||||
className="absolute bottom-0 left-0 w-4 h-4 cursor-nesw-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
|
||||
onPointerDown={(e) => startResize(e, 'bottomLeft')}
|
||||
style={{ touchAction: 'none' }}
|
||||
/>
|
||||
|
||||
{/* Top-right corner */}
|
||||
<div
|
||||
className="absolute top-0 right-0 w-4 h-4 cursor-nesw-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
|
||||
onPointerDown={(e) => startResize(e, 'topRight')}
|
||||
style={{ touchAction: 'none' }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -63,10 +63,10 @@ export function CloudflareDeployForm({
|
||||
const workersUrl = `${baseURL}/accounts/${accountId}/workers/scripts`;
|
||||
|
||||
const [subdomainResponse, workersResponse] = await Promise.all([
|
||||
fetch(corsProxy ? proxyUrl(corsProxy, subdomainUrl) : subdomainUrl, {
|
||||
fetch(corsProxy ? proxyUrl({ template: corsProxy, url: subdomainUrl }) : subdomainUrl, {
|
||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||
}),
|
||||
fetch(corsProxy ? proxyUrl(corsProxy, workersUrl) : workersUrl, {
|
||||
fetch(corsProxy ? proxyUrl({ template: corsProxy, url: workersUrl }) : workersUrl, {
|
||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -56,7 +56,7 @@ export function DenoDeployForm({
|
||||
|
||||
try {
|
||||
const url = `${baseURL}/organizations/${organizationId}/projects?limit=100`;
|
||||
const targetUrl = corsProxy ? proxyUrl(corsProxy, url) : url;
|
||||
const targetUrl = corsProxy ? proxyUrl({ template: corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||
|
||||
@@ -53,7 +53,7 @@ export function NetlifyDeployForm({
|
||||
|
||||
try {
|
||||
const url = `${baseURL}/sites`;
|
||||
const targetUrl = corsProxy ? proxyUrl(corsProxy, url) : url;
|
||||
const targetUrl = corsProxy ? proxyUrl({ template: corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
headers: {
|
||||
|
||||
@@ -154,7 +154,7 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
|
||||
|
||||
if (url.protocol === 'nostr:') {
|
||||
const nostrUri = await NostrURI.parse(url.href);
|
||||
return ngitWebUrl(config.ngitWebUrl, nostrUri);
|
||||
return ngitWebUrl({ template: config.ngitWebUrl, nostrURI: nostrUri });
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface AIProvider {
|
||||
apiKey?: string;
|
||||
nostr?: boolean;
|
||||
proxy?: boolean;
|
||||
openSecret?: string;
|
||||
}
|
||||
|
||||
export interface MCPServer {
|
||||
|
||||
+2
-44
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
|
||||
import { useSessionManager } from '@/hooks/useSessionManager';
|
||||
import { useSessionSubscription } from '@/hooks/useSessionSubscription';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import type { AIMessage, DisplayMessage } from '@/lib/SessionManager';
|
||||
import type { AIMessage } from '@/lib/SessionManager';
|
||||
import type OpenAI from 'openai';
|
||||
import type { Tool } from '@/lib/tools/Tool';
|
||||
|
||||
@@ -39,16 +39,12 @@ export function useAIChat({
|
||||
|
||||
// Split session state into individual variables for efficient updates
|
||||
const [messages, setMessages] = useState<AIMessage[]>([]);
|
||||
const [displayMessages, setDisplayMessages] = useState<DisplayMessage[]>([]);
|
||||
const [sessionName, setSessionName] = useState<string>('');
|
||||
const [streamingMessage, setStreamingMessage] = useState<StreamingMessage | undefined>(undefined);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [totalCost, setTotalCost] = useState<number>(0);
|
||||
const [lastInputTokens, setLastInputTokens] = useState<number>(0);
|
||||
const [lastFinishReason, setLastFinishReason] = useState<string | null>(null);
|
||||
const [isLoadingHistory, setIsLoadingHistory] = useState<boolean>(true);
|
||||
const [hasMoreHistory, setHasMoreHistory] = useState<boolean>(false);
|
||||
const [isLoadingMoreHistory, setIsLoadingMoreHistory] = useState<boolean>(false);
|
||||
|
||||
const initSession = useCallback(async () => {
|
||||
setIsLoadingHistory(true);
|
||||
@@ -57,15 +53,11 @@ export function useAIChat({
|
||||
const session = await sessionManager.loadSession(projectId, tools, customTools, maxSteps);
|
||||
// Initialize individual state variables from existing session
|
||||
setMessages([...session.messages]);
|
||||
setDisplayMessages([...session.displayMessages]);
|
||||
setSessionName(session.sessionName);
|
||||
setStreamingMessage(session.streamingMessage ? { ...session.streamingMessage } : undefined);
|
||||
setIsLoading(session.isLoading);
|
||||
setTotalCost(session.totalCost || 0);
|
||||
setLastInputTokens(session.lastInputTokens || 0);
|
||||
setLastFinishReason(session.lastFinishReason ?? null);
|
||||
setHasMoreHistory(sessionManager.hasMoreHistory(projectId));
|
||||
setIsLoadingMoreHistory(session.isLoadingMoreHistory || false);
|
||||
} finally {
|
||||
setIsLoadingHistory(false);
|
||||
}
|
||||
@@ -131,25 +123,6 @@ export function useAIChat({
|
||||
}
|
||||
}, [projectId]);
|
||||
|
||||
useSessionSubscription('displayMessageAdded', (updatedProjectId: string, message: DisplayMessage) => {
|
||||
if (updatedProjectId === projectId) {
|
||||
setDisplayMessages(prev => [...prev, message]);
|
||||
}
|
||||
}, [projectId]);
|
||||
|
||||
useSessionSubscription('displayMessagesPrepended', (updatedProjectId: string, newMessages: DisplayMessage[]) => {
|
||||
if (updatedProjectId === projectId) {
|
||||
setDisplayMessages(prev => [...newMessages, ...prev]);
|
||||
setHasMoreHistory(sessionManager.hasMoreHistory(projectId));
|
||||
}
|
||||
}, [projectId, sessionManager]);
|
||||
|
||||
useSessionSubscription('loadingMoreHistoryChanged', (updatedProjectId: string, loading: boolean) => {
|
||||
if (updatedProjectId === projectId) {
|
||||
setIsLoadingMoreHistory(loading);
|
||||
}
|
||||
}, [projectId]);
|
||||
|
||||
// Actions
|
||||
const sendMessage = useCallback(async (
|
||||
content: string | Array<OpenAI.Chat.Completions.ChatCompletionContentPartText | OpenAI.Chat.Completions.ChatCompletionContentPartImage>,
|
||||
@@ -191,13 +164,7 @@ export function useAIChat({
|
||||
const startNewSession = useCallback(async () => {
|
||||
await sessionManager.startNewSession(projectId);
|
||||
|
||||
// Get the updated session to retrieve the new session name
|
||||
const session = sessionManager.getSession(projectId);
|
||||
if (session) {
|
||||
setSessionName(session.sessionName);
|
||||
}
|
||||
|
||||
// Reset only AI prompt state (not display state which is handled via events)
|
||||
// Reset individual state variables
|
||||
setMessages([]);
|
||||
setStreamingMessage(undefined);
|
||||
setTotalCost(0);
|
||||
@@ -210,19 +177,11 @@ export function useAIChat({
|
||||
await startNewSession();
|
||||
}, [startNewSession]);
|
||||
|
||||
const loadMoreHistory = useCallback(async () => {
|
||||
await sessionManager.loadOlderSession(projectId);
|
||||
}, [projectId, sessionManager]);
|
||||
|
||||
return {
|
||||
messages,
|
||||
displayMessages,
|
||||
sessionName,
|
||||
streamingMessage,
|
||||
isLoading,
|
||||
isLoadingHistory,
|
||||
hasMoreHistory,
|
||||
isLoadingMoreHistory,
|
||||
totalCost,
|
||||
lastInputTokens,
|
||||
lastFinishReason,
|
||||
@@ -232,7 +191,6 @@ export function useAIChat({
|
||||
clearMessages,
|
||||
startNewSession,
|
||||
addMessage,
|
||||
loadMoreHistory,
|
||||
isConfigured,
|
||||
projectId
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useGitHubOAuth() {
|
||||
redirectUri: window.location.origin + '/oauth/github',
|
||||
usePKCE: true, // GitHub supports PKCE
|
||||
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
||||
const userUrl = proxyUrl(corsProxy, 'https://api.github.com/user');
|
||||
const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.github.com/user' });
|
||||
const userResponse = await fetch(userUrl, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useNetlifyOAuth() {
|
||||
redirectUri: window.location.origin + '/oauth/netlify',
|
||||
usePKCE: false, // Netlify doesn't support PKCE
|
||||
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
||||
const userUrl = proxyUrl(corsProxy, 'https://api.netlify.com/api/v1/user');
|
||||
const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.netlify.com/api/v1/user' });
|
||||
const userResponse = await fetch(userUrl, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
||||
@@ -169,7 +169,7 @@ export function useOAuth(config: OAuthConfig) {
|
||||
}
|
||||
|
||||
// Exchange code for access token
|
||||
const tokenUrl = proxyUrl(corsProxy, config.tokenUrl);
|
||||
const tokenUrl = proxyUrl({ template: corsProxy, url: config.tokenUrl });
|
||||
const tokenResponse = await fetch(tokenUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -34,7 +34,7 @@ export function useVercelOAuth() {
|
||||
redirectUri: window.location.origin + '/oauth/vercel',
|
||||
usePKCE: false, // Vercel doesn't require PKCE
|
||||
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
||||
const userUrl = proxyUrl(corsProxy, 'https://api.vercel.com/v2/user');
|
||||
const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.vercel.com/v2/user' });
|
||||
const userResponse = await fetch(userUrl, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
||||
@@ -27,6 +27,73 @@ describe('DotAI', () => {
|
||||
dotAI = new DotAI(mockFS, '/test-project');
|
||||
});
|
||||
|
||||
describe('readLastSessionHistory', () => {
|
||||
it('should return null when history directory does not exist', async () => {
|
||||
// Mock historyDirExists to return false
|
||||
vi.spyOn(dotAI, 'historyDirExists').mockResolvedValue(false);
|
||||
|
||||
const result = await dotAI.readLastSessionHistory();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null when no session files exist', async () => {
|
||||
// Mock historyDirExists to return true
|
||||
vi.spyOn(dotAI, 'historyDirExists').mockResolvedValue(true);
|
||||
|
||||
// Mock readdir to return empty array
|
||||
vi.mocked(mockFS.readdir).mockResolvedValue([]);
|
||||
|
||||
const result = await dotAI.readLastSessionHistory();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return messages and session name from most recent file', async () => {
|
||||
// Mock historyDirExists to return true
|
||||
vi.spyOn(dotAI, 'historyDirExists').mockResolvedValue(true);
|
||||
|
||||
// Mock readdir to return session files
|
||||
vi.mocked(mockFS.readdir).mockResolvedValue([
|
||||
'2024-08-24T16-30-45Z-abc.jsonl',
|
||||
'2024-08-24T17-15-22Z-def.jsonl', // This should be the most recent
|
||||
'2024-08-24T15-00-00Z-xyz.jsonl'
|
||||
]);
|
||||
|
||||
// Mock readFile to return JSONL content
|
||||
const mockContent = `{"role":"user","content":"Hello"}
|
||||
{"role":"assistant","content":"Hi there!"}`;
|
||||
vi.mocked(mockFS.readFile).mockResolvedValue(mockContent);
|
||||
|
||||
const result = await dotAI.readLastSessionHistory();
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.sessionName).toBe('2024-08-24T17-15-22Z-def');
|
||||
expect(result?.messages).toHaveLength(2);
|
||||
expect(result?.messages[0]).toEqual({ role: 'user', content: 'Hello' });
|
||||
expect(result?.messages[1]).toEqual({ role: 'assistant', content: 'Hi there!' });
|
||||
});
|
||||
|
||||
it('should handle malformed JSON lines gracefully', async () => {
|
||||
// Mock historyDirExists to return true
|
||||
vi.spyOn(dotAI, 'historyDirExists').mockResolvedValue(true);
|
||||
|
||||
// Mock readdir to return session files
|
||||
vi.mocked(mockFS.readdir).mockResolvedValue(['session.jsonl']);
|
||||
|
||||
// Mock readFile to return content with malformed JSON
|
||||
const mockContent = `{"role":"user","content":"Hello"}
|
||||
invalid json line
|
||||
{"role":"assistant","content":"Hi there!"}`;
|
||||
vi.mocked(mockFS.readFile).mockResolvedValue(mockContent);
|
||||
|
||||
const result = await dotAI.readLastSessionHistory();
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.messages).toHaveLength(2); // Should skip the malformed line
|
||||
expect(result?.messages[0]).toEqual({ role: 'user', content: 'Hello' });
|
||||
expect(result?.messages[1]).toEqual({ role: 'assistant', content: 'Hi there!' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('setHistory', () => {
|
||||
it('should create history directory if it does not exist', async () => {
|
||||
// Mock historyDirExists to return false initially
|
||||
|
||||
+52
-36
@@ -216,50 +216,66 @@ export class DotAI {
|
||||
}
|
||||
|
||||
/**
|
||||
* List all session names sorted chronologically (oldest first)
|
||||
* Fast operation - does not load message content
|
||||
* @returns Array of session names (filenames without .jsonl extension)
|
||||
* Read the most recent session history
|
||||
* @returns Object containing messages array and session name, or null if no history found
|
||||
*/
|
||||
async listSessionNames(): Promise<string[]> {
|
||||
async readLastSessionHistory(): Promise<{
|
||||
messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[];
|
||||
sessionName: string;
|
||||
} | null> {
|
||||
try {
|
||||
// Check if history directory exists
|
||||
if (!(await this.historyDirExists())) {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
|
||||
const files = await this.fs.readdir(this.historyDir);
|
||||
return files
|
||||
.filter(file => file.endsWith('.jsonl'))
|
||||
.map(file => file.replace('.jsonl', ''))
|
||||
.sort(); // Chronological order (oldest first) - filenames contain timestamps
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
// Find the most recent session file
|
||||
try {
|
||||
const files = await this.fs.readdir(this.historyDir);
|
||||
const sessionFiles = files
|
||||
.filter(file => file.endsWith('.jsonl'))
|
||||
.sort()
|
||||
.reverse(); // Most recent first
|
||||
|
||||
/**
|
||||
* Read messages for a single session
|
||||
* @param sessionName The session name (filename without .jsonl)
|
||||
* @returns Array of messages, or empty array if session not found
|
||||
*/
|
||||
async readSessionHistory(sessionName: string): Promise<OpenAI.Chat.Completions.ChatCompletionMessageParam[]> {
|
||||
try {
|
||||
const sessionPath = join(this.historyDir, sessionName + '.jsonl');
|
||||
const content = await this.fs.readFile(sessionPath, 'utf8');
|
||||
const lines = content.trim().split('\n').filter(line => line.trim());
|
||||
const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const message = JSON.parse(line) as OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
||||
messages.push(message);
|
||||
} catch {
|
||||
// Skip malformed lines
|
||||
if (sessionFiles.length === 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
} catch {
|
||||
return [];
|
||||
const latestSessionFile = sessionFiles[0];
|
||||
const sessionPath = join(this.historyDir, latestSessionFile);
|
||||
|
||||
try {
|
||||
const content = await this.fs.readFile(sessionPath, 'utf8');
|
||||
const lines = content.trim().split('\n').filter(line => line.trim());
|
||||
const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const message = JSON.parse(line) as OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
||||
messages.push(message);
|
||||
} catch (parseError) {
|
||||
console.warn('Failed to parse message from history:', parseError);
|
||||
}
|
||||
}
|
||||
|
||||
// Return session name without .jsonl extension
|
||||
const sessionName = latestSessionFile.replace('.jsonl', '');
|
||||
|
||||
return {
|
||||
messages,
|
||||
sessionName
|
||||
};
|
||||
} catch (readError) {
|
||||
console.warn('Failed to read session file:', readError);
|
||||
return null;
|
||||
}
|
||||
} catch (readdirError) {
|
||||
console.warn('Failed to read history directory:', readdirError);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to read last session history:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+49
-119
@@ -24,20 +24,12 @@ export type AIMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam | {
|
||||
tool_calls?: OpenAI.Chat.Completions.ChatCompletionMessageToolCall[];
|
||||
};
|
||||
|
||||
/** AIMessage with session tracking for UI display */
|
||||
export type DisplayMessage = AIMessage & {
|
||||
sessionId?: string; // Session identifier for grouping messages in UI
|
||||
};
|
||||
|
||||
export interface SessionState {
|
||||
projectId: string;
|
||||
tools: Record<string, OpenAI.Chat.Completions.ChatCompletionTool>;
|
||||
customTools: Record<string, Tool<unknown>>;
|
||||
maxSteps?: number;
|
||||
messages: AIMessage[]; // Current session messages (sent to AI)
|
||||
displayMessages: DisplayMessage[]; // All messages from all sessions (for UI, with sessionId)
|
||||
availableSessionNames: string[]; // All session names (for lazy loading)
|
||||
loadedSessionCount: number; // How many sessions loaded from the end
|
||||
messages: AIMessage[];
|
||||
streamingMessage?: {
|
||||
role: 'assistant';
|
||||
content: string;
|
||||
@@ -45,7 +37,6 @@ export interface SessionState {
|
||||
tool_calls?: OpenAI.Chat.Completions.ChatCompletionMessageToolCall[];
|
||||
};
|
||||
isLoading: boolean;
|
||||
isLoadingMoreHistory: boolean; // Loading older sessions
|
||||
sessionName: string;
|
||||
lastActivity: Date;
|
||||
abortController?: AbortController;
|
||||
@@ -59,11 +50,8 @@ export interface SessionManagerEvents {
|
||||
sessionCreated: (projectId: string) => void;
|
||||
sessionDeleted: (projectId: string) => void;
|
||||
messageAdded: (projectId: string, message: AIMessage) => void;
|
||||
displayMessageAdded: (projectId: string, message: DisplayMessage) => void;
|
||||
displayMessagesPrepended: (projectId: string, messages: DisplayMessage[]) => void;
|
||||
streamingUpdate: (projectId: string, content: string, reasoningContent?: string, toolCalls?: OpenAI.Chat.Completions.ChatCompletionMessageToolCall[]) => void;
|
||||
loadingChanged: (projectId: string, isLoading: boolean) => void;
|
||||
loadingMoreHistoryChanged: (projectId: string, isLoading: boolean) => void;
|
||||
costUpdated: (projectId: string, totalCost: number) => void;
|
||||
contextUsageUpdated: (projectId: string, inputTokens: number) => void;
|
||||
fileChanged: (projectId: string, filePath: string) => void;
|
||||
@@ -109,7 +97,7 @@ export class SessionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new session for a project (lazy loading - only loads most recent session)
|
||||
* Create a new session for a project
|
||||
*/
|
||||
async loadSession(
|
||||
projectId: string,
|
||||
@@ -117,39 +105,18 @@ export class SessionManager {
|
||||
customTools: Record<string, Tool<unknown>>,
|
||||
maxSteps?: number
|
||||
): Promise<SessionState> {
|
||||
const messages: AIMessage[] = [];
|
||||
const displayMessages: DisplayMessage[] = [];
|
||||
let messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [];
|
||||
let sessionName = DotAI.generateSessionName();
|
||||
let availableSessionNames: string[] = [];
|
||||
let loadedSessionCount = 0;
|
||||
let lastFinishReason: string | null | undefined;
|
||||
|
||||
// Try to load existing history (lazy - only load last session)
|
||||
// Try to load existing history
|
||||
try {
|
||||
const config = this.getConfig();
|
||||
const dotAI = new DotAI(this.fs, `${config.fsPathProjects}/${projectId}`);
|
||||
|
||||
// Get all available session names (fast - no content loading)
|
||||
availableSessionNames = await dotAI.listSessionNames();
|
||||
|
||||
if (availableSessionNames.length > 0) {
|
||||
// Only load the most recent session
|
||||
const lastSessionName = availableSessionNames[availableSessionNames.length - 1];
|
||||
const lastSessionMessages = await dotAI.readSessionHistory(lastSessionName);
|
||||
|
||||
if (lastSessionMessages.length > 0) {
|
||||
// Add messages with sessionId annotation
|
||||
for (const msg of lastSessionMessages) {
|
||||
displayMessages.push({
|
||||
...msg as AIMessage,
|
||||
sessionId: lastSessionName,
|
||||
});
|
||||
}
|
||||
|
||||
messages.push(...lastSessionMessages as AIMessage[]);
|
||||
sessionName = lastSessionName;
|
||||
loadedSessionCount = 1;
|
||||
}
|
||||
const lastSession = await dotAI.readLastSessionHistory();
|
||||
if (lastSession) {
|
||||
messages = lastSession.messages;
|
||||
sessionName = lastSession.sessionName;
|
||||
}
|
||||
|
||||
// Load last finish reason
|
||||
@@ -164,33 +131,21 @@ export class SessionManager {
|
||||
customTools,
|
||||
maxSteps,
|
||||
isLoading: false,
|
||||
isLoadingMoreHistory: false,
|
||||
lastActivity: new Date(),
|
||||
totalCost: 0,
|
||||
lastInputTokens: 0,
|
||||
lastFinishReason,
|
||||
...this.sessions.get(projectId),
|
||||
messages,
|
||||
displayMessages,
|
||||
availableSessionNames,
|
||||
loadedSessionCount,
|
||||
sessionName,
|
||||
};
|
||||
|
||||
// Update session configuration
|
||||
session.projectId = projectId;
|
||||
session.tools = tools;
|
||||
|
||||
session.customTools = customTools;
|
||||
session.maxSteps = maxSteps;
|
||||
|
||||
// Update messages from loaded history if not already set by an existing session
|
||||
if (!this.sessions.has(projectId)) {
|
||||
session.messages = messages;
|
||||
session.displayMessages = displayMessages;
|
||||
session.availableSessionNames = availableSessionNames;
|
||||
session.loadedSessionCount = loadedSessionCount;
|
||||
session.sessionName = sessionName;
|
||||
}
|
||||
|
||||
this.sessions.set(projectId, session);
|
||||
|
||||
@@ -232,69 +187,11 @@ export class SessionManager {
|
||||
const session = this.sessions.get(projectId);
|
||||
if (!session) return;
|
||||
|
||||
// Add to current session messages (for AI prompts)
|
||||
session.messages.push(message);
|
||||
|
||||
// Also add to display messages with session ID annotation (for UI)
|
||||
const displayMessage: DisplayMessage = { ...message, sessionId: session.sessionName };
|
||||
session.displayMessages.push(displayMessage);
|
||||
|
||||
session.lastActivity = new Date();
|
||||
|
||||
await this.saveSessionHistory(projectId);
|
||||
this.emit('messageAdded', projectId, message);
|
||||
this.emit('displayMessageAdded', projectId, displayMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are more historical sessions to load
|
||||
*/
|
||||
hasMoreHistory(projectId: string): boolean {
|
||||
const session = this.sessions.get(projectId);
|
||||
if (!session) return false;
|
||||
return session.loadedSessionCount < session.availableSessionNames.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the next older session and prepend to displayMessages
|
||||
*/
|
||||
async loadOlderSession(projectId: string): Promise<void> {
|
||||
const session = this.sessions.get(projectId);
|
||||
if (!session || !this.hasMoreHistory(projectId) || session.isLoadingMoreHistory) return;
|
||||
|
||||
session.isLoadingMoreHistory = true;
|
||||
this.emit('loadingMoreHistoryChanged', projectId, true);
|
||||
|
||||
try {
|
||||
const config = this.getConfig();
|
||||
const dotAI = new DotAI(this.fs, `${config.fsPathProjects}/${projectId}`);
|
||||
|
||||
// Get the next older session (counting from the end)
|
||||
const nextIndex = session.availableSessionNames.length - session.loadedSessionCount - 1;
|
||||
if (nextIndex < 0) return;
|
||||
|
||||
const olderSessionName = session.availableSessionNames[nextIndex];
|
||||
const olderMessages = await dotAI.readSessionHistory(olderSessionName);
|
||||
|
||||
if (olderMessages.length > 0) {
|
||||
// Create display messages with sessionId
|
||||
const newDisplayMessages: DisplayMessage[] = olderMessages.map(msg => ({
|
||||
...msg as AIMessage,
|
||||
sessionId: olderSessionName,
|
||||
}));
|
||||
|
||||
// Prepend to displayMessages
|
||||
session.displayMessages = [...newDisplayMessages, ...session.displayMessages];
|
||||
session.loadedSessionCount++;
|
||||
|
||||
this.emit('displayMessagesPrepended', projectId, newDisplayMessages);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to load older session:', error);
|
||||
} finally {
|
||||
session.isLoadingMoreHistory = false;
|
||||
this.emit('loadingMoreHistoryChanged', projectId, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -802,7 +699,7 @@ export class SessionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new session (clear AI messages but keep display history)
|
||||
* Start a new session (clear messages but keep configuration)
|
||||
*/
|
||||
async startNewSession(projectId: string): Promise<void> {
|
||||
const session = this.sessions.get(projectId);
|
||||
@@ -810,13 +707,9 @@ export class SessionManager {
|
||||
|
||||
this.stopGeneration(projectId);
|
||||
|
||||
// Generate new session name - new messages will automatically get this sessionId
|
||||
const newSessionName = DotAI.generateSessionName();
|
||||
|
||||
// Clear only the AI prompt messages (not display messages)
|
||||
session.messages = [];
|
||||
session.streamingMessage = undefined;
|
||||
session.sessionName = newSessionName;
|
||||
session.sessionName = DotAI.generateSessionName();
|
||||
session.lastActivity = new Date();
|
||||
session.totalCost = 0;
|
||||
session.lastInputTokens = 0;
|
||||
@@ -827,13 +720,50 @@ export class SessionManager {
|
||||
this.emit('finishReasonChanged', projectId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if content exceeds size/line limits
|
||||
*/
|
||||
private exceedsLimits(content: string): boolean {
|
||||
const MAX_SIZE_BYTES = 50 * 1024; // 50 KiB
|
||||
const MAX_LINES = 2000;
|
||||
|
||||
const sizeBytes = new Blob([content]).size;
|
||||
const lineCount = content.split('\n').length;
|
||||
|
||||
return sizeBytes > MAX_SIZE_BYTES || lineCount > MAX_LINES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content to tmpDir and return the file path
|
||||
*/
|
||||
private async saveToTmpFile(projectId: string, content: string, toolCallId: string): Promise<string> {
|
||||
const config = this.getConfig();
|
||||
const timestamp = Date.now();
|
||||
const filename = `tool-output-${toolCallId}-${timestamp}.txt`;
|
||||
const filepath = `${config.fsPathTmp}/${filename}`;
|
||||
|
||||
await this.fs.writeFile(filepath, content, 'utf8');
|
||||
return filepath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to add tool messages and update conversation
|
||||
*/
|
||||
private async addToolMessage(projectId: string, toolCallId: string, content: string): Promise<void> {
|
||||
let finalContent = content;
|
||||
|
||||
// Check if content exceeds limits
|
||||
if (this.exceedsLimits(content)) {
|
||||
// Save full content to tmp file
|
||||
const filepath = await this.saveToTmpFile(projectId, content, toolCallId);
|
||||
|
||||
// Create placeholder message
|
||||
finalContent = `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse grep to search it for specific content, or text_editor_view with start_line/end_line to view specific sections.`;
|
||||
}
|
||||
|
||||
const toolMessage: AIMessage = {
|
||||
role: 'tool',
|
||||
content,
|
||||
content: finalContent,
|
||||
tool_call_id: toolCallId
|
||||
};
|
||||
|
||||
|
||||
@@ -12,17 +12,21 @@ import { proxyUrl } from './proxyUrl';
|
||||
* If the provider has proxy enabled, requests will be proxied through the corsProxy.
|
||||
*/
|
||||
export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: string): OpenAI {
|
||||
const baseConfig: ConstructorParameters<typeof OpenAI>[0] = {
|
||||
const openai = new OpenAI({
|
||||
baseURL: provider.baseURL,
|
||||
apiKey: provider.apiKey ?? '',
|
||||
dangerouslyAllowBrowser: true,
|
||||
};
|
||||
|
||||
const openai = new OpenAI({
|
||||
...baseConfig,
|
||||
fetch: async (input, init) => {
|
||||
let request = new Request(input, init);
|
||||
|
||||
// OpenSecret auth
|
||||
// https://docs.opensecret.cloud/docs/maple-ai/
|
||||
if (provider.openSecret) {
|
||||
const { createCustomFetch } = await import('@opensecret/react');
|
||||
return createCustomFetch({ apiKey: provider.apiKey, apiUrl: provider.openSecret })(input, init);
|
||||
}
|
||||
|
||||
// Add OpenRouter headers
|
||||
// https://openrouter.ai/docs/app-attribution
|
||||
if (provider.id === 'openrouter') {
|
||||
@@ -47,7 +51,7 @@ export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: s
|
||||
|
||||
// If proxy is enabled and we have a CORS proxy URL, modify the request URL
|
||||
if (provider.proxy && corsProxy) {
|
||||
request = new Request(proxyUrl(corsProxy, request.url), request);
|
||||
request = new Request(proxyUrl({ template: corsProxy, url: request.url }), request);
|
||||
}
|
||||
|
||||
return fetch(request);
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface PresetProvider {
|
||||
nostr?: boolean;
|
||||
tosURL?: string;
|
||||
proxy?: boolean;
|
||||
openSecret?: string;
|
||||
}
|
||||
|
||||
export const AI_PROVIDER_PRESETS: PresetProvider[] = [
|
||||
@@ -16,13 +17,6 @@ export const AI_PROVIDER_PRESETS: PresetProvider[] = [
|
||||
tosURL: "https://ai.shakespeare.diy/terms",
|
||||
nostr: true,
|
||||
},
|
||||
{
|
||||
id: "openrouter",
|
||||
name: "OpenRouter",
|
||||
baseURL: "https://openrouter.ai/api/v1",
|
||||
apiKeysURL: "https://openrouter.ai/settings/keys",
|
||||
tosURL: "https://openrouter.ai/terms",
|
||||
},
|
||||
{
|
||||
id: "opencode",
|
||||
name: "OpenCode Zen",
|
||||
@@ -31,6 +25,21 @@ export const AI_PROVIDER_PRESETS: PresetProvider[] = [
|
||||
tosURL: "https://opencode.ai/legal/terms-of-service",
|
||||
proxy: true,
|
||||
},
|
||||
{
|
||||
id: "maple",
|
||||
name: "Maple AI",
|
||||
baseURL: "https://enclave.trymaple.ai/v1",
|
||||
apiKeysURL: "https://trymaple.ai/",
|
||||
tosURL: "https://opensecret.cloud/terms",
|
||||
openSecret: "https://enclave.trymaple.ai",
|
||||
},
|
||||
{
|
||||
id: "openrouter",
|
||||
name: "OpenRouter",
|
||||
baseURL: "https://openrouter.ai/api/v1",
|
||||
apiKeysURL: "https://openrouter.ai/settings/keys",
|
||||
tosURL: "https://openrouter.ai/terms",
|
||||
},
|
||||
{
|
||||
id: "ppq",
|
||||
name: "PayPerQ",
|
||||
|
||||
@@ -260,6 +260,19 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
|
||||
// not a URL; continue
|
||||
}
|
||||
|
||||
// Check if this is a file: dependency
|
||||
const allDeps = {
|
||||
...packageJson.dependencies,
|
||||
...packageJson.devDependencies,
|
||||
...packageJson.peerDependencies,
|
||||
};
|
||||
const depVersion = allDeps[packageName];
|
||||
|
||||
if (depVersion && depVersion.startsWith("file:")) {
|
||||
// Let fsPlugin handle file: dependencies
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine importer lock path (breadcrumb)
|
||||
const importerLockPath = getImporterLockPath(args.importer);
|
||||
|
||||
@@ -430,6 +443,8 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
|
||||
if (contentType) {
|
||||
if (contentType === "application/javascript") {
|
||||
loader = "js";
|
||||
} else if (contentType === "application/json") {
|
||||
loader = "json";
|
||||
} else if (contentType === "text/css") {
|
||||
loader = "css";
|
||||
} else if (contentType === "application/wasm") {
|
||||
|
||||
@@ -10,14 +10,21 @@ interface TsConfig {
|
||||
};
|
||||
}
|
||||
|
||||
interface PackageJson {
|
||||
dependencies?: { [key: string]: string };
|
||||
devDependencies?: { [key: string]: string };
|
||||
peerDependencies?: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface FsPluginOptions {
|
||||
fs: JSRuntimeFS;
|
||||
cwd: string;
|
||||
tsconfig?: TsConfig;
|
||||
packageJson?: PackageJson;
|
||||
}
|
||||
|
||||
export function fsPlugin(options: FsPluginOptions): Plugin {
|
||||
const { fs, cwd, tsconfig } = options;
|
||||
const { fs, cwd, tsconfig, packageJson } = options;
|
||||
return {
|
||||
name: "fs",
|
||||
|
||||
@@ -30,21 +37,65 @@ export function fsPlugin(options: FsPluginOptions): Plugin {
|
||||
});
|
||||
|
||||
build.onResolve({ filter: /.*/ }, async (args) => {
|
||||
// Skip resolving paths from external URLs
|
||||
// Skip resolving paths from external URLs (but not fs: namespace)
|
||||
if (/^https?:\/\//.test(args.importer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let resolved: string;
|
||||
let resolved: string | undefined;
|
||||
|
||||
// Handle absolute paths
|
||||
if (args.path.startsWith("/")) {
|
||||
resolved = args.path;
|
||||
} else if (args.path.startsWith("@/")) {
|
||||
}
|
||||
// Handle @/ alias
|
||||
else if (args.path.startsWith("@/")) {
|
||||
resolved = join(cwd, "src", args.path.slice(2));
|
||||
} else if (args.importer && (args.path.startsWith("./") || args.path.startsWith("../"))) {
|
||||
resolved = join(dirname(args.importer), args.path);
|
||||
} else if (args.importer && tsconfig?.compilerOptions?.baseUrl) {
|
||||
}
|
||||
// Handle relative paths
|
||||
else if (args.importer && (args.path.startsWith("./") || args.path.startsWith("../"))) {
|
||||
// Remove fs: prefix from importer if present
|
||||
const importerPath = args.importer.replace(/^fs:/, '');
|
||||
resolved = join(dirname(importerPath), args.path);
|
||||
}
|
||||
// Handle bare imports (e.g., "react", "@scope/package")
|
||||
else if (args.path.match(/^[^./]/)) {
|
||||
// Check if this is a file: dependency
|
||||
const packageName = args.path.startsWith("@")
|
||||
? args.path.split("/").slice(0, 2).join("/")
|
||||
: args.path.split("/")[0];
|
||||
|
||||
const allDeps = {
|
||||
...packageJson?.dependencies,
|
||||
...packageJson?.devDependencies,
|
||||
...packageJson?.peerDependencies,
|
||||
};
|
||||
|
||||
const depVersion = allDeps[packageName];
|
||||
|
||||
if (depVersion && depVersion.startsWith("file:")) {
|
||||
// Extract the file path (e.g., "file:./path" -> "./path")
|
||||
const filePath = depVersion.slice(5); // Remove "file:" prefix
|
||||
const packagePath = join(cwd, filePath);
|
||||
|
||||
// Get the subpath within the package (e.g., "package/subdir/file" -> "/subdir/file")
|
||||
const subpath = args.path.slice(packageName.length);
|
||||
|
||||
resolved = join(packagePath, subpath);
|
||||
} else {
|
||||
return; // Let esmPlugin handle this
|
||||
}
|
||||
}
|
||||
// Handle tsconfig baseUrl
|
||||
else if (args.importer && tsconfig?.compilerOptions?.baseUrl) {
|
||||
resolved = join(cwd, tsconfig.compilerOptions.baseUrl, args.path);
|
||||
} else {
|
||||
}
|
||||
// Nothing matched, let other plugins handle it
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!resolved) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,8 +165,43 @@ async function tryFileVariants(
|
||||
return basePath;
|
||||
}
|
||||
|
||||
// If it's a directory, try index files
|
||||
// If it's a directory, try package.json first, then index files
|
||||
if (stat.isDirectory()) {
|
||||
// Try to read package.json for entry point
|
||||
try {
|
||||
const packageJsonPath = join(basePath, "package.json");
|
||||
const packageJsonText = await fs.readFile(packageJsonPath, "utf8");
|
||||
const packageJson = JSON.parse(packageJsonText);
|
||||
|
||||
// Check for various entry point fields
|
||||
const entryPoint = packageJson.exports?.['.']
|
||||
|| packageJson.module
|
||||
|| packageJson.main
|
||||
|| 'index.js';
|
||||
|
||||
// Resolve the entry point
|
||||
const entryPath = typeof entryPoint === 'string'
|
||||
? join(basePath, entryPoint)
|
||||
: join(basePath, 'index.js');
|
||||
|
||||
const entryStat = await statSafe(fs, entryPath);
|
||||
if (entryStat.isFile()) {
|
||||
return entryPath;
|
||||
}
|
||||
|
||||
// Try with different extensions if the entry point doesn't exist
|
||||
for (const ext of extensions) {
|
||||
const entryWithExt = entryPath.replace(/\.[^.]+$/, '') + ext;
|
||||
const entryExtStat = await statSafe(fs, entryWithExt);
|
||||
if (entryExtStat.isFile()) {
|
||||
return entryWithExt;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// package.json doesn't exist or is invalid, fall through to index files
|
||||
}
|
||||
|
||||
// Fall back to trying index files
|
||||
for (const ext of extensions) {
|
||||
const indexFile = join(basePath, "index" + ext);
|
||||
const indexStat = await statSafe(fs, indexFile);
|
||||
|
||||
@@ -535,4 +535,63 @@ react@^18.0.0:
|
||||
// Verify tsconfig.json was attempted to be read
|
||||
expect(mockFS.readFile).toHaveBeenCalledWith('/test/project/tsconfig.json', 'utf8');
|
||||
});
|
||||
|
||||
it('should support file: dependencies in package.json', async () => {
|
||||
const packageJsonWithFileDeps = JSON.stringify({
|
||||
name: "test-project",
|
||||
dependencies: {
|
||||
"@bitchat/capacitor-ble-mesh": "file:./capacitor-bitchat-mesh",
|
||||
"react": "^18.2.0"
|
||||
}
|
||||
});
|
||||
|
||||
// Mock required files
|
||||
vi.mocked(mockFS.readFile)
|
||||
.mockImplementation(async (path: string) => {
|
||||
if (path.endsWith('package.json')) {
|
||||
return packageJsonWithFileDeps;
|
||||
}
|
||||
if (path.endsWith('index.html')) {
|
||||
return '<html><head></head><body><script src="/src/main.tsx"></script></body></html>';
|
||||
}
|
||||
if (path.endsWith('package-lock.json')) {
|
||||
return '{"dependencies": {}}';
|
||||
}
|
||||
throw new Error(`File not found: ${path}`);
|
||||
});
|
||||
|
||||
// Mock stat to indicate no public directory
|
||||
vi.mocked(mockFS.stat)
|
||||
.mockImplementation(async (path: string) => {
|
||||
if (path === '/test/project/public') {
|
||||
throw new Error('Directory not found');
|
||||
}
|
||||
return { isDirectory: () => false, isFile: () => true };
|
||||
});
|
||||
|
||||
// Mock additional filesystem operations for buildProject
|
||||
vi.mocked(mockFS.readdir).mockImplementation(async (path: string) => {
|
||||
if (path === '/test/project/dist') {
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
vi.mocked(mockFS.mkdir).mockResolvedValue(undefined);
|
||||
vi.mocked(mockFS.writeFile).mockResolvedValue(undefined);
|
||||
|
||||
const result = await buildProject({
|
||||
fs: mockFS,
|
||||
projectPath: '/test/project',
|
||||
domParser: mockDOMParser,
|
||||
esmUrl: 'https://esm.shakespeare.diy',
|
||||
});
|
||||
|
||||
// Should successfully build with file: dependencies
|
||||
expect(result.files['stdin-abc123.js']).toEqual(new Uint8Array([1, 2, 3]));
|
||||
expect(result.files['index.html']).toBeDefined();
|
||||
|
||||
// Verify package.json was read
|
||||
expect(mockFS.readFile).toHaveBeenCalledWith('/test/project/package.json', 'utf8');
|
||||
});
|
||||
});
|
||||
@@ -130,7 +130,7 @@ async function bundle(
|
||||
assetNames: "[name]-[hash]",
|
||||
plugins: [
|
||||
shakespearePlugin({ esmUrl }),
|
||||
fsPlugin({ fs, cwd: projectPath, tsconfig }),
|
||||
fsPlugin({ fs, cwd: projectPath, tsconfig, packageJson }),
|
||||
esmPlugin({ packageJson, packageLock, target, esmUrl }),
|
||||
],
|
||||
define: {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class CurlCommand implements ShellCommand {
|
||||
|
||||
// Proxy the URL through configured CorsProxy
|
||||
const originalUrl = url.toString();
|
||||
const proxiedUrl = proxyUrl(this.corsProxy, originalUrl);
|
||||
const proxiedUrl = proxyUrl({ template: this.corsProxy, url: originalUrl });
|
||||
|
||||
// Prepare request
|
||||
const requestInit: RequestInit = {
|
||||
|
||||
@@ -37,6 +37,7 @@ const aiProviderSchema = z.object({
|
||||
apiKey: z.string().optional(),
|
||||
nostr: z.boolean().optional(),
|
||||
proxy: z.boolean().optional(),
|
||||
openSecret: z.string().url().optional(),
|
||||
});
|
||||
|
||||
const providerModelSchema = z.string().regex(
|
||||
|
||||
@@ -140,7 +140,7 @@ export class CloudflareAdapter implements DeployAdapter {
|
||||
|
||||
private async getWorkersSubdomain(): Promise<string> {
|
||||
const url = `${this.baseURL}/accounts/${this.accountId}/workers/subdomain`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'GET',
|
||||
@@ -160,7 +160,7 @@ export class CloudflareAdapter implements DeployAdapter {
|
||||
|
||||
private async enableWorkersDevSubdomain(scriptName: string): Promise<void> {
|
||||
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/subdomain`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
@@ -185,7 +185,7 @@ export class CloudflareAdapter implements DeployAdapter {
|
||||
manifest: AssetManifest
|
||||
): Promise<InitializeAssetsResponse> {
|
||||
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/assets-upload-session`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
@@ -211,7 +211,7 @@ export class CloudflareAdapter implements DeployAdapter {
|
||||
hashToFile: Map<string, { path: string; info: FileInfo }>
|
||||
): Promise<UploadResponse> {
|
||||
const url = `${this.baseURL}/accounts/${this.accountId}/workers/assets/upload?base64=true`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
@@ -251,7 +251,7 @@ export class CloudflareAdapter implements DeployAdapter {
|
||||
|
||||
private async deployWorker(scriptName: string, assetsJwt: string): Promise<WorkerScript> {
|
||||
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
// Create a minimal worker script that serves static assets
|
||||
// This is an assets-only worker - Cloudflare will automatically serve the uploaded assets
|
||||
|
||||
@@ -96,7 +96,7 @@ export class DenoDeployAdapter implements DeployAdapter {
|
||||
|
||||
private async findProject(projectName: string): Promise<Project | null> {
|
||||
const url = `${this.baseURL}/organizations/${this.organizationId}/projects?q=${encodeURIComponent(projectName)}`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'GET',
|
||||
@@ -116,7 +116,7 @@ export class DenoDeployAdapter implements DeployAdapter {
|
||||
|
||||
private async createProject(projectName: string): Promise<Project> {
|
||||
const url = `${this.baseURL}/organizations/${this.organizationId}/projects`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
@@ -143,7 +143,7 @@ export class DenoDeployAdapter implements DeployAdapter {
|
||||
domain: string
|
||||
): Promise<Deployment> {
|
||||
const url = `${this.baseURL}/projects/${projectId}/deployments`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
// Create a minimal server script that serves static files
|
||||
// For static sites, we use a simple file server entry point
|
||||
|
||||
@@ -89,7 +89,7 @@ export class NetlifyAdapter implements DeployAdapter {
|
||||
|
||||
private async createSite(name: string): Promise<NetlifySite> {
|
||||
const url = `${this.baseURL}/sites`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
@@ -113,7 +113,7 @@ export class NetlifyAdapter implements DeployAdapter {
|
||||
|
||||
private async getSite(siteId: string): Promise<NetlifySite> {
|
||||
const url = `${this.baseURL}/sites/${siteId}`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'GET',
|
||||
@@ -132,7 +132,7 @@ export class NetlifyAdapter implements DeployAdapter {
|
||||
|
||||
private async triggerDeploy(siteId: string, zipBlob: Blob): Promise<NetlifyBuildResponse> {
|
||||
const url = `${this.baseURL}/sites/${siteId}/deploys`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -72,7 +72,7 @@ export class ShakespeareAdapter implements DeployAdapter {
|
||||
|
||||
// Apply proxy if configured
|
||||
if (this.corsProxy) {
|
||||
request = new Request(proxyUrl(this.corsProxy, request.url), request);
|
||||
request = new Request(proxyUrl({ template: this.corsProxy, url: request.url }), request);
|
||||
}
|
||||
|
||||
// Deploy
|
||||
|
||||
@@ -68,7 +68,7 @@ export class VercelAdapter implements DeployAdapter {
|
||||
}
|
||||
|
||||
// Apply proxy if configured
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, apiUrl) : apiUrl;
|
||||
const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url: apiUrl }) : apiUrl;
|
||||
|
||||
// Deploy to Vercel
|
||||
const response = await fetch(targetUrl, {
|
||||
|
||||
+11
-5
@@ -1,15 +1,21 @@
|
||||
import UriTemplate from 'uri-templates';
|
||||
|
||||
export interface FaviconUrlOpts {
|
||||
template: string;
|
||||
url: string | URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a favicon URL from a template and input URL
|
||||
* @param template - URL template with placeholders like {hostname}, {origin}, etc.
|
||||
* @param url - The URL to extract parts from
|
||||
* @param opts - Options object
|
||||
* @param opts.template - URL template with placeholders like {hostname}, {origin}, etc.
|
||||
* @param opts.url - The URL to extract parts from
|
||||
* @returns The hydrated favicon URL
|
||||
*/
|
||||
export function faviconUrl(template: string, url: string | URL): string {
|
||||
const u = new URL(url);
|
||||
export function faviconUrl(opts: FaviconUrlOpts): string {
|
||||
const u = new URL(opts.url);
|
||||
|
||||
return UriTemplate(template).fill({
|
||||
return UriTemplate(opts.template).fill({
|
||||
href: u.href,
|
||||
origin: u.origin,
|
||||
protocol: u.protocol,
|
||||
|
||||
+1
-1
@@ -1115,7 +1115,7 @@ class GitHttp implements HttpClient {
|
||||
const url = new URL(request.url);
|
||||
|
||||
const target = this.proxy
|
||||
? proxyUrl(this.proxy, url)
|
||||
? proxyUrl({ template: this.proxy, url })
|
||||
: url.href;
|
||||
|
||||
const init: RequestInit = {
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ngitWebUrl', () => {
|
||||
const identifier = 'my-repo';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/);
|
||||
});
|
||||
@@ -20,7 +20,7 @@ describe('ngitWebUrl', () => {
|
||||
const identifier = 'my-repo';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
expect(result).toMatch(/^https:\/\/example\.com\/npub1/);
|
||||
});
|
||||
@@ -31,7 +31,7 @@ describe('ngitWebUrl', () => {
|
||||
const identifier = 'my-repo';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
expect(result).toBe(`https://example.com/${pubkey}`);
|
||||
});
|
||||
@@ -42,7 +42,7 @@ describe('ngitWebUrl', () => {
|
||||
const identifier = 'my-repo';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
expect(result).toBe('https://example.com/my-repo');
|
||||
});
|
||||
@@ -53,7 +53,7 @@ describe('ngitWebUrl', () => {
|
||||
const identifier = 'my-repo';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
expect(result).toMatch(/^https:\/\/example\.com\/npub1[^/]+\/my-repo$/);
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('ngitWebUrl', () => {
|
||||
const relay = 'wss://relay.example.com/';
|
||||
const nostrURI = new NostrURI({ pubkey, identifier, relay });
|
||||
|
||||
const result = ngitWebUrl(template, nostrURI);
|
||||
const result = ngitWebUrl({ template, nostrURI });
|
||||
|
||||
// The naddr should be longer when it includes relay information
|
||||
expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/);
|
||||
|
||||
+14
-8
@@ -2,20 +2,26 @@ import UriTemplate from 'uri-templates';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { NostrURI } from './NostrURI';
|
||||
|
||||
export interface NgitWebUrlOpts {
|
||||
template: string;
|
||||
nostrURI: NostrURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Nostr Git web URL from a template and Nostr URI
|
||||
* @param template - URL template with placeholders like {naddr}, {npub}, {pubkey}, {identifier}
|
||||
* @param nostrURI - The Nostr URI containing pubkey, identifier, and optional relay
|
||||
* @param opts - Options object
|
||||
* @param opts.template - URL template with placeholders like {naddr}, {npub}, {pubkey}, {identifier}
|
||||
* @param opts.nostrURI - The Nostr URI containing pubkey, identifier, and optional relay
|
||||
* @returns The hydrated web URL
|
||||
*/
|
||||
export function ngitWebUrl(template: string, nostrURI: NostrURI): string {
|
||||
const naddr = nostrURI.toNaddr();
|
||||
const npub = nip19.npubEncode(nostrURI.pubkey);
|
||||
export function ngitWebUrl(opts: NgitWebUrlOpts): string {
|
||||
const naddr = opts.nostrURI.toNaddr();
|
||||
const npub = nip19.npubEncode(opts.nostrURI.pubkey);
|
||||
|
||||
return UriTemplate(template).fill({
|
||||
return UriTemplate(opts.template).fill({
|
||||
naddr,
|
||||
npub,
|
||||
pubkey: nostrURI.pubkey,
|
||||
identifier: nostrURI.identifier,
|
||||
pubkey: opts.nostrURI.pubkey,
|
||||
identifier: opts.nostrURI.identifier,
|
||||
});
|
||||
}
|
||||
+8
-3
@@ -1,8 +1,13 @@
|
||||
import UriTemplate from 'uri-templates';
|
||||
|
||||
export function proxyUrl(template: string, url: string | URL): string {
|
||||
const u = new URL(url);
|
||||
return UriTemplate(template).fill({
|
||||
export interface ProxyUrlOpts {
|
||||
template: string;
|
||||
url: string | URL;
|
||||
}
|
||||
|
||||
export function proxyUrl(opts: ProxyUrlOpts): string {
|
||||
const u = new URL(opts.url);
|
||||
return UriTemplate(opts.template).fill({
|
||||
href: u.href,
|
||||
origin: u.origin,
|
||||
protocol: u.protocol,
|
||||
|
||||
@@ -137,7 +137,7 @@ export class GenerateImageTool implements Tool<GenerateImageParams> {
|
||||
}
|
||||
} else if (firstImage.url) {
|
||||
// Fetch the image from the URL
|
||||
const imageUrl = this.corsProxy ? proxyUrl(this.corsProxy, firstImage.url) : firstImage.url;
|
||||
const imageUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url: firstImage.url }) : firstImage.url;
|
||||
const imageResponse = await fetch(imageUrl);
|
||||
|
||||
if (!imageResponse.ok) {
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "Anonymous",
|
||||
"logIn": "Log in",
|
||||
"signUp": "Sign up",
|
||||
"newChat": "New Chat",
|
||||
"loadOlderMessages": "Load older messages",
|
||||
"preferencesDescription": "Manage your general application preferences and appearance settings.",
|
||||
"theme": "Theme",
|
||||
"themeDescription": "Choose between light, dark, or system theme preference.",
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "Maras Suna",
|
||||
"logIn": "Shiga",
|
||||
"signUp": "Yi Rajista",
|
||||
"newChat": "Sabon Tattaunawa",
|
||||
"loadOlderMessages": "Loda saƙonni masu tsufa",
|
||||
"preferencesDescription": "Sarrafa zaɓuɓɓukan aikace-aikacenku da saitunan bayyanar.",
|
||||
"theme": "Jigogi",
|
||||
"themeDescription": "Zaɓi tsakanin haske, duhu, ko zaɓin jigogi na tsarin.",
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "Onye na-amaghị aha",
|
||||
"logIn": "Banye",
|
||||
"signUp": "Debanye aha",
|
||||
"newChat": "Nkata Ọhụrụ",
|
||||
"loadOlderMessages": "Bulite ozi ochie",
|
||||
"preferencesDescription": "Jikwaa nhọrọ ngwa gị na ntọala ngosipụta.",
|
||||
"theme": "Isiokwu",
|
||||
"themeDescription": "Họrọ n'etiti ìhè, ọchịchịrị, ma ọ bụ nhọrọ isiokwu sistemu.",
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "Anônimo",
|
||||
"logIn": "Entrar",
|
||||
"signUp": "Cadastrar",
|
||||
"newChat": "Nova Conversa",
|
||||
"loadOlderMessages": "Carregar mensagens anteriores",
|
||||
"preferencesDescription": "Gerencie suas preferências gerais da aplicação e configurações de aparência.",
|
||||
"theme": "Tema",
|
||||
"themeDescription": "Escolha entre preferência de tema claro, escuro ou do sistema.",
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "Alainidamọ",
|
||||
"logIn": "Wọle",
|
||||
"signUp": "Forukọsilẹ",
|
||||
"newChat": "Ọrọ Tuntun",
|
||||
"loadOlderMessages": "Gbe awọn ifiranṣẹ atijọ",
|
||||
"preferencesDescription": "Ṣakoso awọn ayanfẹ ohun elo rẹ ati awọn eto iwoye.",
|
||||
"theme": "Akori",
|
||||
"themeDescription": "Yan laarin imọlẹ, okunkun, tabi ayanfẹ akori eto.",
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
"anonymous": "匿名",
|
||||
"logIn": "登录",
|
||||
"signUp": "注册",
|
||||
"newChat": "新对话",
|
||||
"loadOlderMessages": "加载更早的消息",
|
||||
"preferencesDescription": "管理您的应用程序偏好设置和外观设置。",
|
||||
"theme": "主题",
|
||||
"themeDescription": "选择浅色、深色或系统主题偏好。",
|
||||
|
||||
@@ -118,6 +118,9 @@ export function AISettings() {
|
||||
if (typeof preset.proxy === 'boolean') {
|
||||
newProvider.proxy = preset.proxy;
|
||||
}
|
||||
if (preset.openSecret) {
|
||||
newProvider.openSecret = preset.openSecret;
|
||||
}
|
||||
|
||||
setProvider(newProvider);
|
||||
};
|
||||
|
||||
+197
-97
@@ -31,6 +31,9 @@ import { useGitAutosync } from '@/hooks/useGitAutosync';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
import { FloatingChatWidget } from '@/components/Shakespeare/FloatingChatWidget';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
|
||||
export function ProjectView() {
|
||||
const { projectId } = useParams<{ projectId: string }>();
|
||||
@@ -59,6 +62,16 @@ export function ProjectView() {
|
||||
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(!isMobile);
|
||||
|
||||
// Floating chat state
|
||||
const [isFloatingChatEnabled, setIsFloatingChatEnabled] = useLocalStorage(
|
||||
'shk:floatingChatEnabled',
|
||||
false
|
||||
);
|
||||
const [isFloatingChatMinimized, setIsFloatingChatMinimized] = useLocalStorage(
|
||||
'shk:floatingChatMinimized',
|
||||
false
|
||||
);
|
||||
|
||||
const build = useBuildProject(projectId!);
|
||||
const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!);
|
||||
const { hasRunningSessions } = useProjectSessionStatus(projectId || '');
|
||||
@@ -227,7 +240,7 @@ export function ProjectView() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4 px-3">
|
||||
<div className="flex items-center gap-2 px-3">
|
||||
{project ? (
|
||||
<>
|
||||
<GitSyncButton
|
||||
@@ -239,6 +252,24 @@ export function ProjectView() {
|
||||
projectName={project.name}
|
||||
disabled={isAnyLoading}
|
||||
/>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={() => {
|
||||
setIsFloatingChatEnabled(true);
|
||||
setIsFloatingChatMinimized(false);
|
||||
}}
|
||||
aria-label="Floating chat"
|
||||
aria-pressed={isFloatingChatEnabled}
|
||||
>
|
||||
<MessageSquare className="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Floating chat</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
@@ -389,6 +420,23 @@ export function ProjectView() {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Floating Chat Widget - Mobile */}
|
||||
{isFloatingChatEnabled && project && (
|
||||
<FloatingChatWidget
|
||||
projectId={project.id}
|
||||
isMinimized={isFloatingChatMinimized}
|
||||
onToggleMinimize={() => setIsFloatingChatMinimized(!isFloatingChatMinimized)}
|
||||
onClose={() => setIsFloatingChatEnabled(false)}
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
onDismissConsoleError={handleDismissConsoleError}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -415,123 +463,175 @@ export function ProjectView() {
|
||||
{/* Main Content Area */}
|
||||
<div className="flex-1 flex flex-col overflow-hidden bg-background">
|
||||
<div className="flex-1 overflow-hidden">
|
||||
<ResizablePanelGroup direction="horizontal" className="h-full">
|
||||
{/* Chat Panel */}
|
||||
<ResizablePanel defaultSize={35} minSize={25}>
|
||||
<div className="h-full flex flex-col">
|
||||
{/* Chat Header */}
|
||||
<div className="h-12 px-4 border-b flex-shrink-0">
|
||||
<div className="flex items-center justify-between h-12">
|
||||
{/* Left side - Sidebar toggle (when collapsed) */}
|
||||
<div className="flex items-center gap-3 overflow-hidden">
|
||||
{!isSidebarVisible && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(true)}
|
||||
className="h-8 w-8 p-0"
|
||||
aria-label="Open sidebar"
|
||||
>
|
||||
<Menu className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
{isFloatingChatEnabled ? (
|
||||
// Full-width preview/code when floating chat is enabled
|
||||
<div className="h-full">
|
||||
{project ? (
|
||||
<PreviewPane
|
||||
projectId={project.id}
|
||||
activeTab={isPreviewable ? activeTab : 'code'}
|
||||
onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
|
||||
isPreviewable={isPreviewable}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
// Original resizable panel layout
|
||||
<ResizablePanelGroup direction="horizontal" className="h-full">
|
||||
{/* Chat Panel */}
|
||||
<ResizablePanel defaultSize={35} minSize={25}>
|
||||
<div className="h-full flex flex-col">
|
||||
{/* Chat Header */}
|
||||
<div className="h-12 px-4 border-b flex-shrink-0">
|
||||
<div className="flex items-center justify-between h-12">
|
||||
{/* Left side - Sidebar toggle (when collapsed) */}
|
||||
<div className="flex items-center gap-3 overflow-hidden">
|
||||
{!isSidebarVisible && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(true)}
|
||||
className="h-8 w-8 p-0"
|
||||
aria-label="Open sidebar"
|
||||
>
|
||||
<Menu className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Project title */}
|
||||
<div className="flex flex-1 min-w-0 truncate">
|
||||
{/* Project title */}
|
||||
<div className="flex flex-1 min-w-0 truncate">
|
||||
{project ? (
|
||||
<ProjectTitleMenu
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onGitHistory={() => setGitHistoryOpen(true)}
|
||||
onDuplicate={() => setDuplicateDialogOpen(true)}
|
||||
onDelete={() => setDeleteDialogOpen(true)}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isAILoading={isAILoading}
|
||||
isAnyLoading={isAnyLoading || isDeleting}
|
||||
className="text-lg"
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="h-6 w-40" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right side - Deploy and Sync buttons */}
|
||||
<div className="flex items-center gap-2">
|
||||
{project ? (
|
||||
<ProjectTitleMenu
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onGitHistory={() => setGitHistoryOpen(true)}
|
||||
onDuplicate={() => setDuplicateDialogOpen(true)}
|
||||
onDelete={() => setDeleteDialogOpen(true)}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isAILoading={isAILoading}
|
||||
isAnyLoading={isAnyLoading || isDeleting}
|
||||
className="text-lg"
|
||||
/>
|
||||
<>
|
||||
<GitSyncButton
|
||||
projectId={project.id}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
<DeployButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
disabled={isAnyLoading}
|
||||
/>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={() => setIsFloatingChatEnabled(true)}
|
||||
aria-label="Floating chat"
|
||||
aria-pressed={isFloatingChatEnabled}
|
||||
>
|
||||
<MessageSquare className="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Floating chat</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
) : (
|
||||
<Skeleton className="h-6 w-40" />
|
||||
<>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right side - Deploy and Sync buttons */}
|
||||
<div className="flex items-center gap-2">
|
||||
{project ? (
|
||||
<>
|
||||
<GitSyncButton
|
||||
projectId={project.id}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
<DeployButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
disabled={isAnyLoading}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{/* Chat Content */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
{project ? (
|
||||
<ChatPane
|
||||
ref={chatPaneRef}
|
||||
projectId={project.id}
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
onDismissConsoleError={handleDismissConsoleError}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-12 w-full" />
|
||||
<Skeleton className="h-8 w-3/4" />
|
||||
<Skeleton className="h-8 w-1/2" />
|
||||
<Skeleton className="h-32 w-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</ResizablePanel>
|
||||
|
||||
{/* Chat Content */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
{/* Resizable Handle */}
|
||||
<ResizableHandle withHandle />
|
||||
|
||||
{/* Preview/Code Panel */}
|
||||
<ResizablePanel defaultSize={65} minSize={30}>
|
||||
<div className="h-full">
|
||||
{project ? (
|
||||
<ChatPane
|
||||
ref={chatPaneRef}
|
||||
<PreviewPane
|
||||
projectId={project.id}
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
onDismissConsoleError={handleDismissConsoleError}
|
||||
activeTab={isPreviewable ? activeTab : 'code'}
|
||||
onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
|
||||
isPreviewable={isPreviewable}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-12 w-full" />
|
||||
<Skeleton className="h-8 w-3/4" />
|
||||
<Skeleton className="h-8 w-1/2" />
|
||||
<Skeleton className="h-32 w-full" />
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</ResizablePanel>
|
||||
|
||||
{/* Resizable Handle */}
|
||||
<ResizableHandle withHandle />
|
||||
|
||||
{/* Preview/Code Panel */}
|
||||
<ResizablePanel defaultSize={65} minSize={30}>
|
||||
<div className="h-full">
|
||||
{project ? (
|
||||
<PreviewPane
|
||||
projectId={project.id}
|
||||
activeTab={isPreviewable ? activeTab : 'code'}
|
||||
onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
|
||||
isPreviewable={isPreviewable}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ResizablePanel>
|
||||
</ResizablePanelGroup>
|
||||
</ResizablePanel>
|
||||
</ResizablePanelGroup>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating Chat Widget - Desktop */}
|
||||
{isFloatingChatEnabled && project && (
|
||||
<FloatingChatWidget
|
||||
projectId={project.id}
|
||||
isMinimized={isFloatingChatMinimized}
|
||||
onToggleMinimize={() => setIsFloatingChatMinimized(!isFloatingChatMinimized)}
|
||||
onClose={() => setIsFloatingChatEnabled(false)}
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
onDismissConsoleError={handleDismissConsoleError}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Dialogs */}
|
||||
{project && (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user