mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e024c3725d | ||
|
|
2e3a4b9bd7 | ||
|
|
f0c1784288 | ||
|
|
94b4dcbda6 | ||
|
|
c49e8811af | ||
|
|
37c72391a0 | ||
|
|
6c92b2dc4d | ||
|
|
676655ef66 | ||
|
|
27f9435be9 | ||
|
|
32656a8f5c | ||
|
|
bd9a276275 | ||
|
|
7fa4330249 | ||
|
|
b5c2c79feb | ||
|
|
f3a3d31977 | ||
|
|
68eee82c92 | ||
|
|
cd006889c8 | ||
|
|
d23778547f | ||
|
|
627a43309c | ||
|
|
07d594a373 | ||
|
|
5b8cb25675 | ||
|
|
89de28cb0c | ||
|
|
c5e5cafb77 | ||
|
|
926e63bb81 |
No files matched your search
Generated
+11
-33
@@ -196,7 +196,6 @@
|
||||
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
"@babel/generator": "^7.28.5",
|
||||
@@ -1832,7 +1831,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
@@ -1856,7 +1854,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
@@ -1878,7 +1875,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz",
|
||||
"integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@dnd-kit/accessibility": "^3.1.1",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
@@ -5463,7 +5459,8 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
|
||||
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@types/cacheable-request": {
|
||||
"version": "6.0.3",
|
||||
@@ -5705,7 +5702,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.20.tgz",
|
||||
"integrity": "sha512-IPaCZN7PShZK/3t6Q87pfTkRm6oLTd4vztyoj+cbHUF1g3FfVb2tFIL79uCRKEfv16AhqDMBywP2VW3KIZUvcg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/prop-types": "*",
|
||||
"csstype": "^3.0.2"
|
||||
@@ -5717,7 +5713,6 @@
|
||||
"integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.0.0"
|
||||
}
|
||||
@@ -5822,7 +5817,6 @@
|
||||
"integrity": "sha512-oU/OtYVydhXnumd0BobL9rkJg7wFJ9bFFPmSmB/bf/XWN85hlViji59ko6bSKBXyseT9V8l+CN1nwmlbiN0G7Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.31.1",
|
||||
"@typescript-eslint/types": "8.31.1",
|
||||
@@ -6182,7 +6176,6 @@
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -6686,7 +6679,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.8.19",
|
||||
"caniuse-lite": "^1.0.30001751",
|
||||
@@ -6955,7 +6947,6 @@
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
|
||||
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"anymatch": "~3.1.2",
|
||||
"braces": "~3.0.2",
|
||||
@@ -7756,7 +7747,8 @@
|
||||
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
|
||||
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/dom-helpers": {
|
||||
"version": "5.2.1",
|
||||
@@ -7840,8 +7832,7 @@
|
||||
"version": "8.6.0",
|
||||
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz",
|
||||
"integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/embla-carousel-react": {
|
||||
"version": "8.6.0",
|
||||
@@ -8155,7 +8146,6 @@
|
||||
"integrity": "sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
@@ -8421,7 +8411,6 @@
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
|
||||
"integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"accepts": "^2.0.0",
|
||||
"body-parser": "^2.2.0",
|
||||
@@ -9644,7 +9633,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.27.6"
|
||||
},
|
||||
@@ -10428,7 +10416,6 @@
|
||||
"integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"cssstyle": "^4.2.1",
|
||||
"data-urls": "^5.0.0",
|
||||
@@ -10825,6 +10812,7 @@
|
||||
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"lz-string": "bin/bin.js"
|
||||
}
|
||||
@@ -12622,7 +12610,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.8",
|
||||
"picocolors": "^1.1.1",
|
||||
@@ -12790,6 +12777,7 @@
|
||||
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1",
|
||||
"ansi-styles": "^5.0.0",
|
||||
@@ -12805,6 +12793,7 @@
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
@@ -12815,6 +12804,7 @@
|
||||
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
@@ -12827,7 +12817,8 @@
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
|
||||
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.30.0",
|
||||
@@ -13035,7 +13026,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
|
||||
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0"
|
||||
},
|
||||
@@ -13062,7 +13052,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
|
||||
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"scheduler": "^0.23.2"
|
||||
@@ -13088,7 +13077,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.1.tgz",
|
||||
"integrity": "sha512-qWAVokhSpshhcEuQDSANHx3jiAEFzu2HAaaQIzi/r9FNPm1ioAvuJSD4EuZzWd7Al7nTRKcKPnBKO7sRn+zavQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
@@ -13137,7 +13125,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz",
|
||||
"integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/hast": "^3.0.0",
|
||||
"@types/mdast": "^4.0.0",
|
||||
@@ -13719,7 +13706,6 @@
|
||||
"integrity": "sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.7"
|
||||
},
|
||||
@@ -14834,7 +14820,6 @@
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz",
|
||||
"integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@alloc/quick-lru": "^5.2.0",
|
||||
"arg": "^5.0.2",
|
||||
@@ -15038,7 +15023,6 @@
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -15334,7 +15318,6 @@
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -15862,7 +15845,6 @@
|
||||
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.4",
|
||||
@@ -16007,7 +15989,6 @@
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -16478,7 +16459,6 @@
|
||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fast-uri": "^3.0.1",
|
||||
@@ -16555,7 +16535,6 @@
|
||||
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
@@ -17015,7 +16994,6 @@
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
||||
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
||||
@@ -38,7 +38,14 @@ class JSONRPCClient {
|
||||
}
|
||||
}
|
||||
|
||||
async fetch(request) {
|
||||
/**
|
||||
* Generic JSON-RPC call method
|
||||
* @param {string} method - The RPC method name
|
||||
* @param {object} params - Parameters for the method
|
||||
* @param {number} timeout - Timeout in milliseconds (default: 10000)
|
||||
* @returns {Promise} - Resolves with the result or rejects with error
|
||||
*/
|
||||
async call(method, params, timeout = 10000) {
|
||||
const id = ++this.requestId;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -47,21 +54,25 @@ class JSONRPCClient {
|
||||
// Send JSON-RPC request to parent
|
||||
window.parent.postMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "fetch",
|
||||
params: { request },
|
||||
method,
|
||||
params,
|
||||
id,
|
||||
}, "*");
|
||||
|
||||
// Timeout after 10 seconds
|
||||
// Timeout handling
|
||||
setTimeout(() => {
|
||||
if (this.pendingRequests.has(id)) {
|
||||
this.pendingRequests.delete(id);
|
||||
reject(new Error(`Timeout fetching: ${request.url}`));
|
||||
reject(new Error(`RPC call to ${method} with ID ${id} timed out`));
|
||||
}
|
||||
}, 10000);
|
||||
}, timeout);
|
||||
});
|
||||
}
|
||||
|
||||
async fetch(request) {
|
||||
return this.call("fetch", { request }, 10000);
|
||||
}
|
||||
|
||||
handleResponse(message) {
|
||||
const { id, result, error } = message;
|
||||
const pending = this.pendingRequests.get(id);
|
||||
@@ -153,6 +164,38 @@ class ConsoleInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
// Nostr Bridge - proxies window.nostr calls to parent window
|
||||
class NostrBridge {
|
||||
constructor(rpcClient) {
|
||||
this.rpcClient = rpcClient;
|
||||
console.log('[NostrBridge] initializing...');
|
||||
this.injectNostr();
|
||||
}
|
||||
|
||||
injectNostr() {
|
||||
// Create the window.nostr object
|
||||
window.nostr = {
|
||||
getPublicKey: () => this.callNostrMethod('getPublicKey', []),
|
||||
signEvent: (event) => this.callNostrMethod('signEvent', [event]),
|
||||
nip04: {
|
||||
encrypt: (pubkey, plaintext) => this.callNostrMethod('nip04.encrypt', [pubkey, plaintext]),
|
||||
decrypt: (pubkey, ciphertext) => this.callNostrMethod('nip04.decrypt', [pubkey, ciphertext]),
|
||||
},
|
||||
nip44: {
|
||||
encrypt: (pubkey, plaintext) => this.callNostrMethod('nip44.encrypt', [pubkey, plaintext]),
|
||||
decrypt: (pubkey, ciphertext) => this.callNostrMethod('nip44.decrypt', [pubkey, ciphertext]),
|
||||
},
|
||||
};
|
||||
console.log('[NostrBridge] window.nostr injected');
|
||||
}
|
||||
|
||||
async callNostrMethod(method, args) {
|
||||
// Use the generic RPC client call method
|
||||
// Extension prompts may take time, so use 30 second timeout
|
||||
return this.rpcClient.call('nostr', { method, args }, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation Handler - manages iframe navigation and history
|
||||
class NavigationHandler {
|
||||
constructor() {
|
||||
@@ -319,8 +362,8 @@ class NavigationHandler {
|
||||
|
||||
// Main Fetch Client
|
||||
class FetchClient {
|
||||
constructor() {
|
||||
this.rpcClient = new JSONRPCClient();
|
||||
constructor(rpcClient) {
|
||||
this.rpcClient = rpcClient;
|
||||
this.consoleInterceptor = new ConsoleInterceptor();
|
||||
this.navigationHandler = new NavigationHandler();
|
||||
this.init();
|
||||
@@ -393,8 +436,8 @@ class FetchClient {
|
||||
active: navigator.serviceWorker.controller,
|
||||
installing: null,
|
||||
waiting: null,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
addEventListener: () => { },
|
||||
removeEventListener: () => { },
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -569,8 +612,14 @@ const setupGlobalErrorHandlers = () => {
|
||||
// Initialize
|
||||
setupGlobalErrorHandlers();
|
||||
|
||||
const init = () => {
|
||||
const rpcClient = new JSONRPCClient();
|
||||
new FetchClient(rpcClient);
|
||||
new NostrBridge(rpcClient);
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", () => new FetchClient());
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
} else {
|
||||
new FetchClient();
|
||||
}
|
||||
init();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export function AppLayout({
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<div className="relative left-0 top-0 h-full w-72 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={selectedProject}
|
||||
onSelectProject={(project) => {
|
||||
@@ -123,7 +123,7 @@ export function AppLayout({
|
||||
<div className="min-h-screen flex bg-background">
|
||||
{/* Fixed Sidebar - show if showSidebar is true and sidebar is visible */}
|
||||
{showSidebar && isSidebarVisible && (
|
||||
<div className="w-80 border-r bg-sidebar transition-all duration-300">
|
||||
<div className="w-72 border-r bg-sidebar transition-all duration-300">
|
||||
<ProjectSidebar
|
||||
selectedProject={selectedProject}
|
||||
onSelectProject={handleProjectSelect}
|
||||
|
||||
@@ -35,51 +35,25 @@ export function AppShowcase() {
|
||||
}, [config.showcaseModerator]);
|
||||
const isModerator = user?.pubkey === MODERATOR_HEX;
|
||||
|
||||
// Categorize and organize submissions - single pass for efficiency
|
||||
const {
|
||||
displayedFeaturedApps,
|
||||
displayedTemplateApps,
|
||||
moreApps
|
||||
} = useMemo(() => {
|
||||
const DISPLAY_LIMIT = 6;
|
||||
|
||||
// Single pass categorization
|
||||
const templates: typeof submissions = [];
|
||||
const featured: typeof submissions = [];
|
||||
const approved: typeof submissions = [];
|
||||
|
||||
for (const app of submissions) {
|
||||
if (app.isHidden) continue;
|
||||
|
||||
const isTemplate = app.appTags.includes('Template');
|
||||
const isFeatured = app.isFeatured;
|
||||
const isApproved = app.isApproved;
|
||||
|
||||
if (isTemplate) {
|
||||
templates.push(app);
|
||||
} else if (isFeatured) {
|
||||
featured.push(app);
|
||||
} else if (isApproved) {
|
||||
approved.push(app);
|
||||
}
|
||||
}
|
||||
|
||||
// Shuffle each category once
|
||||
const shuffledTemplates = shuffleArray(templates);
|
||||
const shuffledFeatured = shuffleArray(featured);
|
||||
const shuffledApproved = shuffleArray(approved);
|
||||
|
||||
// Split into display and more sections
|
||||
// Filter and shuffle submissions - memoized with stable dependency
|
||||
const { templateApps, featuredApps, approvedApps } = useMemo(() => {
|
||||
// Filter visible submissions
|
||||
const visibleSubmissions = submissions.filter(app => !app.isHidden);
|
||||
|
||||
// Separate template apps from other apps
|
||||
const templates = shuffleArray(visibleSubmissions.filter(app => app.appTags.includes('Template')));
|
||||
const nonTemplateSubmissions = visibleSubmissions.filter(app => !app.appTags.includes('Template'));
|
||||
|
||||
// Shuffle featured and approved apps for random display order
|
||||
const featured = shuffleArray(nonTemplateSubmissions.filter(app => app.isFeatured));
|
||||
const approved = shuffleArray(nonTemplateSubmissions.filter(app => app.isApproved && !app.isFeatured));
|
||||
|
||||
return {
|
||||
displayedFeaturedApps: shuffledFeatured.slice(0, DISPLAY_LIMIT),
|
||||
displayedTemplateApps: shuffledTemplates.slice(0, DISPLAY_LIMIT),
|
||||
moreApps: [
|
||||
...shuffledFeatured.slice(DISPLAY_LIMIT),
|
||||
...shuffledTemplates.slice(DISPLAY_LIMIT),
|
||||
...shuffledApproved,
|
||||
],
|
||||
templateApps: templates,
|
||||
featuredApps: featured,
|
||||
approvedApps: approved,
|
||||
};
|
||||
}, [submissions]);
|
||||
}, [submissions]); // Only depend on submissions, not intermediate filtered arrays
|
||||
|
||||
// Don't show showcase if disabled in settings
|
||||
if (!config.showcaseEnabled) {
|
||||
@@ -150,7 +124,7 @@ export function AppShowcase() {
|
||||
{/* Apps Grid */}
|
||||
<div className="space-y-12">
|
||||
{/* Featured Apps */}
|
||||
{displayedFeaturedApps.length > 0 && (
|
||||
{featuredApps.length > 0 && (
|
||||
<div>
|
||||
<div className="flex items-start gap-3 mb-6">
|
||||
<div className="flex-none w-8 h-8 bg-yellow-100 dark:bg-yellow-900/30 rounded-lg flex items-center justify-center">
|
||||
@@ -162,7 +136,7 @@ export function AppShowcase() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{displayedFeaturedApps.map((app) => (
|
||||
{featuredApps.slice(0, 6).map((app) => (
|
||||
<AppShowcaseCard
|
||||
key={app.id}
|
||||
app={app}
|
||||
@@ -175,7 +149,7 @@ export function AppShowcase() {
|
||||
)}
|
||||
|
||||
{/* Templates Section */}
|
||||
{displayedTemplateApps.length > 0 && (
|
||||
{templateApps.length > 0 && (
|
||||
<div>
|
||||
<div className="flex items-start gap-3 mb-6">
|
||||
<div className="flex-none w-8 h-8 bg-purple-100 dark:bg-purple-900/30 rounded-lg flex items-center justify-center">
|
||||
@@ -187,7 +161,7 @@ export function AppShowcase() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{displayedTemplateApps.map((app) => (
|
||||
{templateApps.slice(0, 6).map((app) => (
|
||||
<AppShowcaseCard
|
||||
key={app.id}
|
||||
app={app}
|
||||
@@ -199,8 +173,8 @@ export function AppShowcase() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* More Apps (Remaining Featured, Templates, and Approved) - Collapsible */}
|
||||
{moreApps.length > 0 && (
|
||||
{/* More Apps (Approved) - Collapsible */}
|
||||
{approvedApps.length > 0 && (
|
||||
<div>
|
||||
<Collapsible open={showAllApps} onOpenChange={setShowAllApps}>
|
||||
<CollapsibleTrigger asChild>
|
||||
@@ -211,7 +185,7 @@ export function AppShowcase() {
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<h3 className="text-xl font-bold text-foreground">
|
||||
{t('moreAppsCount', { count: moreApps.length })}
|
||||
{t('moreAppsCount', { count: approvedApps.length })}
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{showAllApps ? t('clickToCollapse') : t('clickToViewMore')}
|
||||
@@ -222,7 +196,7 @@ export function AppShowcase() {
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{moreApps.map((app) => (
|
||||
{approvedApps.map((app) => (
|
||||
<AppShowcaseCard
|
||||
key={app.id}
|
||||
app={app}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import QRCode from 'qrcode';
|
||||
import { CreditCard, Zap, ExternalLink, RefreshCw, Check, X, Clock, AlertCircle, Copy, RotateCcw, ArrowLeft, Gift, Plus, History, DollarSign, Printer, Download } from 'lucide-react';
|
||||
@@ -85,17 +85,33 @@ const PRESET_AMOUNTS = [5, 10, 25, 50, 100];
|
||||
interface LightningPaymentProps {
|
||||
invoice: string;
|
||||
amount: number;
|
||||
paymentId: string;
|
||||
provider: AIProvider;
|
||||
onClose: () => void;
|
||||
onPaymentCompleted: () => void;
|
||||
}
|
||||
|
||||
function LightningPayment({ invoice, amount, onClose }: LightningPaymentProps) {
|
||||
function LightningPayment({ invoice, amount, paymentId, provider, onClose, onPaymentCompleted }: LightningPaymentProps) {
|
||||
const { t } = useTranslation();
|
||||
const { user } = useCurrentUser();
|
||||
const { config } = useAppContext();
|
||||
const queryClient = useQueryClient();
|
||||
const [qrDataUrl, setQrDataUrl] = useState<string>('');
|
||||
const [isWebLNAvailable, setIsWebLNAvailable] = useState(false);
|
||||
const [isPayingWithWebLN, setIsPayingWithWebLN] = useState(false);
|
||||
const [showCopiedTooltip, setShowCopiedTooltip] = useState(false);
|
||||
const [paymentCompleted, setPaymentCompleted] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
const formatCurrency = useCallback((amount: number) => {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(amount);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Generate QR code
|
||||
QRCode.toDataURL(invoice, {
|
||||
@@ -113,6 +129,98 @@ function LightningPayment({ invoice, amount, onClose }: LightningPaymentProps) {
|
||||
setIsWebLNAvailable(typeof window !== 'undefined' && 'webln' in window);
|
||||
}, [invoice]);
|
||||
|
||||
// Poll payment status
|
||||
useEffect(() => {
|
||||
// Don't poll if payment already completed
|
||||
if (paymentCompleted) return;
|
||||
|
||||
let intervalId: NodeJS.Timeout | null = null;
|
||||
|
||||
const pollPaymentStatus = async () => {
|
||||
// Double-check in case state updated during async operation
|
||||
if (paymentCompleted) return;
|
||||
|
||||
try {
|
||||
const ai = createAIClient(provider, user, config.corsProxy);
|
||||
const payment = await ai.get(`/credits/payments/${paymentId}`) as Payment;
|
||||
|
||||
if (payment.status === 'completed') {
|
||||
// Mark as completed to prevent further polling
|
||||
setPaymentCompleted(true);
|
||||
|
||||
// Clear the interval immediately
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
intervalId = null;
|
||||
}
|
||||
|
||||
// Update credits balance
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['ai-credits', provider.nostr ? user?.pubkey ?? '' : '', provider.id],
|
||||
});
|
||||
|
||||
// Update payments list
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['ai-payments', provider.nostr ? user?.pubkey ?? '' : '', provider.id],
|
||||
});
|
||||
|
||||
// Show toast
|
||||
toast({
|
||||
title: t('paymentCompleted'),
|
||||
description: t('creditsAddedToAccount', { amount: formatCurrency(payment.amount) }),
|
||||
});
|
||||
|
||||
// Close dialog immediately
|
||||
onPaymentCompleted();
|
||||
} else if (payment.status === 'failed') {
|
||||
// Mark as completed to prevent further polling
|
||||
setPaymentCompleted(true);
|
||||
|
||||
// Clear the interval immediately
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
intervalId = null;
|
||||
}
|
||||
|
||||
toast({
|
||||
title: t('paymentFailed'),
|
||||
description: t('paymentFailed'),
|
||||
variant: 'destructive',
|
||||
});
|
||||
} else if (payment.status === 'expired') {
|
||||
// Mark as completed to prevent further polling
|
||||
setPaymentCompleted(true);
|
||||
|
||||
// Clear the interval immediately
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
intervalId = null;
|
||||
}
|
||||
|
||||
toast({
|
||||
title: t('paymentExpired'),
|
||||
description: t('paymentExpiredMessage'),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to poll payment status:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Poll immediately on mount
|
||||
pollPaymentStatus();
|
||||
|
||||
// Then poll every 3 seconds
|
||||
intervalId = setInterval(pollPaymentStatus, 3000);
|
||||
|
||||
return () => {
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
};
|
||||
}, [paymentId, provider, user, config.corsProxy, queryClient, toast, t, onPaymentCompleted, formatCurrency, paymentCompleted]);
|
||||
|
||||
const handleWebLNPay = async () => {
|
||||
if (!window.webln) return;
|
||||
|
||||
@@ -145,15 +253,6 @@ function LightningPayment({ invoice, amount, onClose }: LightningPaymentProps) {
|
||||
setTimeout(() => setShowCopiedTooltip(false), 2000);
|
||||
};
|
||||
|
||||
const formatCurrency = (amount: number) => {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(amount);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="text-center">
|
||||
@@ -223,6 +322,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
const [amount, setAmount] = useState<number>(10);
|
||||
const [paymentMethod, setPaymentMethod] = useState<'stripe' | 'lightning'>('stripe');
|
||||
const [lightningInvoice, setLightningInvoice] = useState<string | null>(null);
|
||||
const [lightningPaymentId, setLightningPaymentId] = useState<string | null>(null);
|
||||
const [refreshingPayments, setRefreshingPayments] = useState<Set<string>>(new Set());
|
||||
const [giftcardAmount, setGiftcardAmount] = useState<number>(10);
|
||||
const [giftcardQuantity, setGiftcardQuantity] = useState<number>(1);
|
||||
@@ -301,6 +401,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
} else if (payment.method === 'lightning') {
|
||||
// Show Lightning payment interface
|
||||
setLightningInvoice(payment.url);
|
||||
setLightningPaymentId(payment.id);
|
||||
}
|
||||
|
||||
// Refresh payments list
|
||||
@@ -486,6 +587,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
} else if (paymentPreview.method === 'lightning') {
|
||||
// Show Lightning payment interface
|
||||
setLightningInvoice(paymentPreview.url);
|
||||
setLightningPaymentId(paymentPreview.id);
|
||||
}
|
||||
|
||||
// Refresh payments list
|
||||
@@ -882,12 +984,22 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
</DialogHeader>
|
||||
|
||||
{/* Lightning Payment Interface */}
|
||||
{lightningInvoice ? (
|
||||
{lightningInvoice && lightningPaymentId ? (
|
||||
<div className="flex-1 overflow-y-auto px-1 -mx-1">
|
||||
<LightningPayment
|
||||
invoice={lightningInvoice}
|
||||
amount={amount}
|
||||
onClose={() => setLightningInvoice(null)}
|
||||
paymentId={lightningPaymentId}
|
||||
provider={provider}
|
||||
onClose={() => {
|
||||
setLightningInvoice(null);
|
||||
setLightningPaymentId(null);
|
||||
}}
|
||||
onPaymentCompleted={() => {
|
||||
// Close the lightning payment view immediately
|
||||
setLightningInvoice(null);
|
||||
setLightningPaymentId(null);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
@@ -1054,6 +1166,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
onClick={() => {
|
||||
if (payment.method === 'lightning') {
|
||||
setLightningInvoice(payment.url);
|
||||
setLightningPaymentId(payment.id);
|
||||
} else {
|
||||
window.open(payment.url, '_blank');
|
||||
}
|
||||
@@ -1172,7 +1285,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
||||
</AccordionItem>
|
||||
|
||||
{/* Your Gift Cards Accordion */}
|
||||
<AccordionItem value="list" className="border-b-0">
|
||||
<AccordionItem value="list">
|
||||
<AccordionTrigger className="hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<CreditCard className="h-4 w-4" />
|
||||
|
||||
@@ -182,7 +182,6 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
||||
await git.checkout({
|
||||
dir: projectPath,
|
||||
ref: branchName,
|
||||
force: true,
|
||||
});
|
||||
|
||||
toast({
|
||||
@@ -1289,7 +1288,6 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
||||
await git.checkout({
|
||||
dir: projectPath,
|
||||
ref: pr.sourceBranch,
|
||||
force: true,
|
||||
});
|
||||
await refetchGitStatus();
|
||||
toast({
|
||||
|
||||
@@ -269,7 +269,7 @@ export function MCPServersSection() {
|
||||
|
||||
{/* Add New MCP Server */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="add-server" className="border rounded-lg">
|
||||
<AccordionItem value="add-server">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<Plus className="h-4 w-4" />
|
||||
|
||||
@@ -111,13 +111,11 @@ describe('ModelSelector', () => {
|
||||
// Recently used section should NOT be visible
|
||||
expect(screen.queryByText('Recently Used')).not.toBeInTheDocument();
|
||||
|
||||
// provider1 should still be visible (models appear in both sections now)
|
||||
expect(screen.getByText('provider1')).toBeInTheDocument();
|
||||
expect(screen.getByText('model1')).toBeInTheDocument();
|
||||
expect(screen.getByText('model2')).toBeInTheDocument();
|
||||
// provider1 should be hidden since all its models are in recently used
|
||||
expect(screen.queryByText('provider1')).not.toBeInTheDocument();
|
||||
|
||||
// provider2 should still show with model3
|
||||
expect(screen.getByText('model3')).toBeInTheDocument();
|
||||
expect(screen.getByText('provider2/model3')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows recently used section when less than 5 models but some recently used are not available', async () => {
|
||||
@@ -162,17 +160,11 @@ describe('ModelSelector', () => {
|
||||
|
||||
// Wait for the dropdown to open
|
||||
await waitFor(() => {
|
||||
// provider1 appears in both recently used and available sections
|
||||
const provider1Elements = screen.queryAllByText('provider1');
|
||||
expect(provider1Elements.length).toBeGreaterThan(0);
|
||||
expect(screen.getByText('provider1')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Recently used section SHOULD be visible
|
||||
expect(screen.getByText('Recently Used')).toBeInTheDocument();
|
||||
|
||||
// provider1 should appear in both sections (recently used and available)
|
||||
const provider1Elements = screen.queryAllByText('provider1');
|
||||
expect(provider1Elements.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('shows recently used section when 5 or more models are available', async () => {
|
||||
@@ -225,22 +217,13 @@ describe('ModelSelector', () => {
|
||||
// Recently used section SHOULD be visible
|
||||
expect(screen.getByText('Recently Used')).toBeInTheDocument();
|
||||
|
||||
// provider1 should still be visible (models appear in both sections now)
|
||||
// Use queryAllByText since provider1 appears as a heading in both sections
|
||||
const provider1Elements = screen.queryAllByText('provider1');
|
||||
expect(provider1Elements.length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
// Models should be visible (display text is just the model name, not full ID)
|
||||
// model1 and model2 appear in both recently used and available sections
|
||||
const model1Elements = screen.queryAllByText('model1');
|
||||
expect(model1Elements.length).toBeGreaterThanOrEqual(1);
|
||||
const model2Elements = screen.queryAllByText('model2');
|
||||
expect(model2Elements.length).toBeGreaterThanOrEqual(1);
|
||||
// provider1 should be hidden since all its models are in recently used
|
||||
expect(screen.queryByText('provider1')).not.toBeInTheDocument();
|
||||
|
||||
// provider2 and provider3 should still show (only in available section)
|
||||
expect(screen.getByText('model3')).toBeInTheDocument();
|
||||
expect(screen.getByText('model4')).toBeInTheDocument();
|
||||
expect(screen.getByText('model5')).toBeInTheDocument();
|
||||
// provider2 and provider3 should still show
|
||||
expect(screen.getByText('provider2/model3')).toBeInTheDocument();
|
||||
expect(screen.getByText('provider2/model4')).toBeInTheDocument();
|
||||
expect(screen.getByText('provider3/model5')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides recently used section when no recently used models exist', async () => {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { useState, useMemo, useEffect, memo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Decimal } from 'decimal.js';
|
||||
import { Check, ChevronDown, Edit3, RefreshCw, AlertCircle, Settings, TriangleAlert } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '@/components/ui/command';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
@@ -15,72 +14,6 @@ import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { ModelPricing } from '@/components/ModelPricing';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
// Type for model (matches ProviderModel from useProviderModels)
|
||||
type ModelType = {
|
||||
id: string;
|
||||
name?: string;
|
||||
provider: string;
|
||||
fullId: string;
|
||||
description?: string;
|
||||
contextLength?: number;
|
||||
pricing?: {
|
||||
prompt: Decimal;
|
||||
completion: Decimal;
|
||||
};
|
||||
};
|
||||
|
||||
// Interface for grouped models by provider
|
||||
interface ModelGroup {
|
||||
provider: string;
|
||||
models: ModelType[];
|
||||
}
|
||||
|
||||
// Parse model ID into components (provider/company/model or provider/model)
|
||||
function parseModelId(fullId: string) {
|
||||
const parts = fullId.split('/');
|
||||
return {
|
||||
provider: parts[0] || '',
|
||||
company: parts.length >= 3 ? parts[1] : null,
|
||||
modelName: parts.length >= 3 ? parts.slice(2).join('/') : parts[1] || '',
|
||||
};
|
||||
}
|
||||
|
||||
// Group models by provider and sort
|
||||
function groupModelsByProvider(models: ModelType[], excludeIds: Set<string>): ModelGroup[] {
|
||||
const groups: Record<string, ModelType[]> = {};
|
||||
|
||||
// Group by provider
|
||||
models.forEach(model => {
|
||||
if (!excludeIds.has(model.fullId)) {
|
||||
const { provider } = parseModelId(model.fullId);
|
||||
if (!groups[provider]) groups[provider] = [];
|
||||
groups[provider].push(model);
|
||||
}
|
||||
});
|
||||
|
||||
// Sort models within each group and convert to array
|
||||
return Object.entries(groups)
|
||||
.map(([provider, models]) => ({
|
||||
provider,
|
||||
models: models.sort((a, b) => {
|
||||
const aParsed = parseModelId(a.fullId);
|
||||
const bParsed = parseModelId(b.fullId);
|
||||
// Sort by company, then model name
|
||||
if (aParsed.company && bParsed.company) {
|
||||
const diff = aParsed.company.localeCompare(bParsed.company);
|
||||
if (diff !== 0) return diff;
|
||||
}
|
||||
return aParsed.modelName.localeCompare(bParsed.modelName);
|
||||
}),
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
// Shakespeare first, then alphabetical
|
||||
if (a.provider === 'shakespeare') return -1;
|
||||
if (b.provider === 'shakespeare') return 1;
|
||||
return a.provider.localeCompare(b.provider);
|
||||
});
|
||||
}
|
||||
|
||||
interface ModelSelectorProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
@@ -91,46 +24,6 @@ interface ModelSelectorProps {
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
// Render a model item in the list
|
||||
const ModelItem = memo(({ model, currentValue, onSelect, valuePrefix = '' }: {
|
||||
model: ModelType;
|
||||
currentValue: string;
|
||||
onSelect: (value: string) => void;
|
||||
valuePrefix?: string;
|
||||
}) => {
|
||||
const parsed = parseModelId(model.fullId);
|
||||
const displayText = parsed.company
|
||||
? `${parsed.company}/${parsed.modelName}`
|
||||
: parsed.modelName;
|
||||
|
||||
// Use prefix to make value unique (prevents both recently used and available from highlighting together)
|
||||
const uniqueValue = valuePrefix ? `${valuePrefix}-${model.fullId}` : model.fullId;
|
||||
|
||||
return (
|
||||
<CommandItem
|
||||
key={model.fullId}
|
||||
value={uniqueValue}
|
||||
keywords={[model.fullId]}
|
||||
onSelect={() => onSelect(model.fullId)}
|
||||
className="cursor-pointer"
|
||||
title={model.fullId}
|
||||
>
|
||||
<Check
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4 shrink-0",
|
||||
currentValue === model.fullId ? "opacity-100" : "opacity-0"
|
||||
)}
|
||||
/>
|
||||
<span className="flex-1 min-w-0 truncate">
|
||||
{displayText}
|
||||
</span>
|
||||
{model.pricing && (
|
||||
<ModelPricing pricing={model.pricing} className="ml-2 shrink-0" />
|
||||
)}
|
||||
</CommandItem>
|
||||
);
|
||||
});
|
||||
|
||||
export const ModelSelector = memo(function ModelSelector({
|
||||
value,
|
||||
onChange,
|
||||
@@ -159,11 +52,25 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
|
||||
const recentlyUsedModels = useMemo(() => settings.recentlyUsedModels || [], [settings.recentlyUsedModels]);
|
||||
|
||||
// Group models by provider (don't exclude recently used - they should appear in both sections)
|
||||
const modelGroups = useMemo(
|
||||
() => groupModelsByProvider(models, new Set()),
|
||||
[models]
|
||||
);
|
||||
// Create a Set of recently used model IDs for efficient lookup
|
||||
const recentlyUsedSet = useMemo(() => new Set(recentlyUsedModels), [recentlyUsedModels]);
|
||||
|
||||
// Group models by provider, excluding models that are in the recently used section
|
||||
const modelsByProvider = useMemo(() => {
|
||||
const groups: Record<string, typeof models> = {};
|
||||
for (const model of models) {
|
||||
// Skip models that are already shown in recently used
|
||||
if (recentlyUsedSet.has(model.fullId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!groups[model.provider]) {
|
||||
groups[model.provider] = [];
|
||||
}
|
||||
groups[model.provider].push(model);
|
||||
}
|
||||
return groups;
|
||||
}, [models, recentlyUsedSet]);
|
||||
|
||||
// Determine if we should show the "Recently Used" section
|
||||
const shouldShowRecentlyUsed = useMemo(() => {
|
||||
@@ -188,15 +95,6 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
return !allRecentlyUsedAreAvailable;
|
||||
}, [recentlyUsedModels, models]);
|
||||
|
||||
// Group recently used models (same structure as available models)
|
||||
const recentlyUsedGroups = useMemo(() => {
|
||||
if (!shouldShowRecentlyUsed) return [];
|
||||
const recentModels = recentlyUsedModels
|
||||
.map(id => models.find(m => m.fullId === id))
|
||||
.filter((m): m is ModelType => m !== undefined);
|
||||
return groupModelsByProvider(recentModels, new Set());
|
||||
}, [recentlyUsedModels, models, shouldShowRecentlyUsed]);
|
||||
|
||||
// Check if the current model is free
|
||||
const isCurrentModelFree = useMemo(() => {
|
||||
if (!value) return false;
|
||||
@@ -373,8 +271,8 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
role="combobox"
|
||||
@@ -389,28 +287,13 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
</span>
|
||||
<ChevronDown className="size-3 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent
|
||||
className={cn(
|
||||
"p-0 max-w-[90vw] sm:max-w-lg md:max-w-2xl",
|
||||
"max-h-[85vh] overflow-hidden flex flex-col"
|
||||
)}
|
||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||
>
|
||||
<Command
|
||||
className="flex flex-col h-full overflow-hidden"
|
||||
filter={(value, search, keywords) => {
|
||||
// Substring search: match if search appears anywhere in value or keywords
|
||||
const s = search.toLowerCase();
|
||||
if (value.toLowerCase().includes(s)) return 1;
|
||||
if (keywords?.some(k => typeof k === 'string' && k.toLowerCase().includes(s))) return 1;
|
||||
return 0;
|
||||
}}
|
||||
>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="p-0 w-80" align="end">
|
||||
<Command>
|
||||
{(isConfigured && models.length >= 5) && (
|
||||
<CommandInput placeholder={t('searchModels')} className="h-9" autoFocus={false} />
|
||||
<CommandInput placeholder={t('searchModels')} className="h-9" />
|
||||
)}
|
||||
<CommandList className="flex-1 overflow-y-auto overflow-x-hidden">
|
||||
<CommandList>
|
||||
<CommandEmpty>
|
||||
<div className="py-6 text-center text-sm text-muted-foreground">
|
||||
<p>{t('noModelsFound')}</p>
|
||||
@@ -418,31 +301,34 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
</div>
|
||||
</CommandEmpty>
|
||||
|
||||
{/* Recently Used section */}
|
||||
{shouldShowRecentlyUsed && (
|
||||
<>
|
||||
<CommandGroup heading={t('recentlyUsed')} />
|
||||
{recentlyUsedGroups.map((group) => (
|
||||
<CommandGroup key={`recent-${group.provider}`} heading={group.provider}>
|
||||
{group.models.map((model) => (
|
||||
<ModelItem
|
||||
key={model.fullId}
|
||||
model={model}
|
||||
currentValue={value}
|
||||
onSelect={handleSelect}
|
||||
valuePrefix="recent"
|
||||
<CommandGroup heading={t('recentlyUsed')}>
|
||||
{recentlyUsedModels.map((modelId) => {
|
||||
const modelData = models.find(m => m.fullId === modelId);
|
||||
return (
|
||||
<CommandItem
|
||||
key={modelId}
|
||||
value={modelId}
|
||||
onSelect={() => handleSelect(modelId)}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Check
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
value === modelId ? "opacity-100" : "opacity-0"
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
</CommandGroup>
|
||||
))}
|
||||
{modelGroups.length > 0 && <CommandSeparator />}
|
||||
</>
|
||||
<span className="truncate flex-1">{modelId}</span>
|
||||
{modelData?.pricing && (
|
||||
<ModelPricing pricing={modelData.pricing} className="ml-2" />
|
||||
)}
|
||||
</CommandItem>
|
||||
);
|
||||
})}
|
||||
</CommandGroup>
|
||||
)}
|
||||
|
||||
{/* Available Models section */}
|
||||
{!isLoading && modelGroups.length > 0 && (
|
||||
<CommandGroup heading={t('availableModels')} />
|
||||
)}
|
||||
{shouldShowRecentlyUsed && <CommandSeparator />}
|
||||
|
||||
{/* Loading state */}
|
||||
{isLoading && (
|
||||
@@ -480,25 +366,32 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
</CommandGroup>
|
||||
)}
|
||||
|
||||
{/* No models available state */}
|
||||
{!isLoading && !error && !shouldShowRecentlyUsed && modelGroups.length === 0 && (
|
||||
<div className="py-12 text-center text-sm text-muted-foreground">
|
||||
<p>{t('noModelsFound')}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Provider models */}
|
||||
{!isLoading && modelGroups.map((group) => (
|
||||
<CommandGroup key={group.provider} heading={group.provider}>
|
||||
{group.models.map((model) => (
|
||||
<ModelItem
|
||||
key={model.fullId}
|
||||
model={model}
|
||||
currentValue={value}
|
||||
onSelect={handleSelect}
|
||||
/>
|
||||
))}
|
||||
</CommandGroup>
|
||||
{!isLoading && Object.entries(modelsByProvider).map(([provider, providerModels]) => (
|
||||
<div key={provider}>
|
||||
<CommandSeparator />
|
||||
<CommandGroup heading={provider}>
|
||||
{providerModels.map((model) => (
|
||||
<CommandItem
|
||||
key={model.fullId}
|
||||
value={model.fullId}
|
||||
onSelect={() => handleSelect(model.fullId)}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Check
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
value === model.fullId ? "opacity-100" : "opacity-0"
|
||||
)}
|
||||
/>
|
||||
<span className="truncate flex-1">{model.fullId}</span>
|
||||
{model.pricing && (
|
||||
<ModelPricing pricing={model.pricing} className="ml-2" />
|
||||
)}
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Custom model option and manage providers - moved to bottom */}
|
||||
@@ -525,8 +418,8 @@ export const ModelSelector = memo(function ModelSelector({
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Alert,
|
||||
AlertDescription,
|
||||
AlertTitle,
|
||||
} from '@/components/ui/alert';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
interface NostrPermissionDialogProps {
|
||||
open: boolean;
|
||||
onResponse: (granted: boolean) => void;
|
||||
}
|
||||
|
||||
export function NostrPermissionDialog({ open, onResponse }: NostrPermissionDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(isOpen) => {
|
||||
if (!isOpen) {
|
||||
onResponse(false);
|
||||
}
|
||||
}}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Allow Nostr Access?</DialogTitle>
|
||||
<DialogDescription className="space-y-3">
|
||||
<p>
|
||||
This project is requesting access to your Nostr signer (window.nostr).
|
||||
</p>
|
||||
<Alert variant="destructive">
|
||||
<AlertTitle>Warning</AlertTitle>
|
||||
<AlertDescription>
|
||||
Granting access will allow this app to take actions on your behalf, including:
|
||||
<ul className="list-disc list-inside mt-2 space-y-1">
|
||||
<li>Read your public key</li>
|
||||
<li>Sign events (publish posts, reactions, etc.)</li>
|
||||
<li>Encrypt and decrypt messages</li>
|
||||
</ul>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Only grant access if you trust this application.
|
||||
</p>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter className="gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => onResponse(false)}
|
||||
>
|
||||
Deny
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => onResponse(true)}
|
||||
>
|
||||
Allow
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
interface NostrSignerRequiredDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export function NostrSignerRequiredDialog({ open, onOpenChange }: NostrSignerRequiredDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Nostr Signer Required</DialogTitle>
|
||||
<DialogDescription className="space-y-3">
|
||||
<p>
|
||||
This page tried to use a NIP-07 signer, but you don't have one installed!
|
||||
</p>
|
||||
<p>
|
||||
Please install a Nostr signer extension to continue:
|
||||
</p>
|
||||
<div className="space-y-2 mt-4">
|
||||
<a
|
||||
href="https://github.com/soapbox-pub/soapbox-signer"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="block text-primary hover:underline"
|
||||
>
|
||||
• Soapbox Signer
|
||||
</a>
|
||||
<a
|
||||
href="https://getalby.com/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="block text-primary hover:underline"
|
||||
>
|
||||
• Alby
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/fiatjaf/nos2x"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="block text-primary hover:underline"
|
||||
>
|
||||
• nos2x
|
||||
</a>
|
||||
</div>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Close
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRegisterSW } from 'virtual:pwa-register/react';
|
||||
import { Sparkles } from 'lucide-react';
|
||||
import { Sparkles, X } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* Component that prompts users to update when a new service worker is available
|
||||
@@ -52,22 +52,38 @@ export function PWAUpdatePrompt() {
|
||||
updateServiceWorker(true);
|
||||
};
|
||||
|
||||
const handleDismiss = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
setShowPrompt(false);
|
||||
};
|
||||
|
||||
if (!showPrompt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-4 left-1/2 -translate-x-1/2 md:top-4 md:right-4 md:bottom-auto md:left-auto md:translate-x-0 z-50 animate-in slide-in-from-bottom-4 md:slide-in-from-top-4 duration-500 max-w-full">
|
||||
<button
|
||||
onClick={handleUpdate}
|
||||
disabled={isUpdating}
|
||||
className="group relative flex items-center gap-2 px-4 py-2.5 bg-gradient-to-r from-amber-100 to-yellow-100 dark:from-amber-900 dark:to-yellow-900 border border-amber-300 dark:border-amber-700 rounded-full shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 active:scale-95 disabled:cursor-not-allowed disabled:hover:scale-100 max-w-full truncate"
|
||||
>
|
||||
<Sparkles className={`h-4 w-4 text-amber-600 dark:text-amber-400 ${isUpdating ? 'animate-spin' : 'group-hover:rotate-12 transition-transform duration-300'}`} />
|
||||
<span className="text-sm font-medium whitespace-nowrap max-w-full truncate text-amber-900 dark:text-amber-100">
|
||||
{isUpdating ? 'Updating...' : 'Update available — Click to refresh'}
|
||||
</span>
|
||||
</button>
|
||||
<div className="relative group">
|
||||
<button
|
||||
onClick={handleUpdate}
|
||||
disabled={isUpdating}
|
||||
className={`relative flex items-center gap-2 px-4 py-2.5 ${!isUpdating ? 'pr-10' : ''} bg-gradient-to-r from-amber-100 to-yellow-100 dark:from-amber-900 dark:to-yellow-900 border border-amber-300 dark:border-amber-700 rounded-full shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 active:scale-95 disabled:cursor-not-allowed disabled:hover:scale-100 max-w-full truncate`}
|
||||
>
|
||||
<Sparkles className={`h-4 w-4 text-amber-600 dark:text-amber-400 ${isUpdating ? 'animate-spin' : 'group-hover:rotate-12 transition-transform duration-300'}`} />
|
||||
<span className="text-sm font-medium whitespace-nowrap max-w-full truncate text-amber-900 dark:text-amber-100">
|
||||
{isUpdating ? 'Updating...' : 'Update available — Click to refresh'}
|
||||
</span>
|
||||
</button>
|
||||
{!isUpdating && (
|
||||
<button
|
||||
onClick={handleDismiss}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded-full hover:bg-amber-200 dark:hover:bg-amber-800 transition-colors duration-200"
|
||||
aria-label="Dismiss update notification"
|
||||
>
|
||||
<X className="h-4 w-4 text-amber-700 dark:text-amber-300" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ export function PluginsSection() {
|
||||
|
||||
{/* Add Plugin Section */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="add-plugin" className="border rounded-lg">
|
||||
<AccordionItem value="add-plugin">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<Plus className="h-4 w-4" />
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, useState, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle } from 'lucide-react';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle, Search } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { useProjects } from '@/hooks/useProjects';
|
||||
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||
@@ -93,10 +94,24 @@ export function ProjectSidebar({
|
||||
const queryClient = useQueryClient();
|
||||
const { data: projects = [], isLoading, error } = useProjects();
|
||||
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Fast in-memory search filtering
|
||||
const filteredProjects = useMemo(() => {
|
||||
if (!searchQuery.trim()) {
|
||||
return projects;
|
||||
}
|
||||
|
||||
const query = searchQuery.toLowerCase();
|
||||
return projects.filter(project =>
|
||||
project.id.toLowerCase().includes(query) ||
|
||||
project.name.toLowerCase().includes(query)
|
||||
);
|
||||
}, [projects, searchQuery]);
|
||||
|
||||
// Custom navigate function that closes sidebar on mobile
|
||||
const navigateAndClose = (path: string) => {
|
||||
navigate(path);
|
||||
@@ -166,12 +181,12 @@ export function ProjectSidebar({
|
||||
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<div className="p-2">
|
||||
<div className="mb-2">
|
||||
<div className="mb-2 space-y-3">
|
||||
<div className="relative rounded-md bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90 transition-all duration-200">
|
||||
<div className="flex">
|
||||
<button
|
||||
onClick={handleNewProject}
|
||||
className="flex-1 flex items-center justify-center px-3 py-2 text-sm font-medium text-primary-foreground rounded-l-md hover:bg-white/10 transition-colors"
|
||||
className="flex-1 flex items-center justify-center px-3 py-2.5 text-sm font-medium text-primary-foreground rounded-l-md hover:bg-white/10 transition-colors"
|
||||
>
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
{t('newProject')}
|
||||
@@ -179,7 +194,7 @@ export function ProjectSidebar({
|
||||
<div className="w-px bg-white/20" />
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="px-2 py-2 text-primary-foreground hover:bg-white/10 rounded-r-md transition-colors">
|
||||
<button className="px-3 py-2.5 text-primary-foreground hover:bg-white/10 rounded-r-md transition-colors">
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
@@ -195,6 +210,20 @@ export function ProjectSidebar({
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Search Input */}
|
||||
{projects.length > 0 && (
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder={t('searchProjects')}
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-9 h-9 text-sm bg-sidebar-accent/50 border-sidebar-border focus-visible:ring-primary/50"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
@@ -214,9 +243,15 @@ export function ProjectSidebar({
|
||||
<p className="text-sm">{t('noProjectsYet')}</p>
|
||||
<p className="text-xs">{t('createFirstProject')}</p>
|
||||
</div>
|
||||
) : filteredProjects.length === 0 ? (
|
||||
<div className="text-center p-6 text-muted-foreground">
|
||||
<Search className="h-8 w-8 mx-auto mb-2 opacity-50" />
|
||||
<p className="text-sm">{t('noProjectsFound')}</p>
|
||||
<p className="text-xs">{t('tryDifferentSearch')}</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-1">
|
||||
{projects.map((project) => (
|
||||
{filteredProjects.map((project) => (
|
||||
<ProjectItem
|
||||
key={project.id}
|
||||
project={project}
|
||||
|
||||
@@ -197,7 +197,13 @@ function QuillyContent({ error, onDismiss, onNewChat, onOpenModelSelector, onTry
|
||||
message: error.message
|
||||
? `AI service error: ${error.message}`
|
||||
: 'Sorry, I encountered an unexpected error. Please try again.',
|
||||
actions: [],
|
||||
actions: onTryAgain ? [{
|
||||
label: 'Try again',
|
||||
onClick: () => {
|
||||
onTryAgain();
|
||||
onDismiss();
|
||||
},
|
||||
}] : [],
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { GitBranch } from 'lucide-react';
|
||||
import type { Repository } from '@/hooks/useUserRepositories';
|
||||
import { useAuthor } from '@/hooks/useAuthor';
|
||||
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar';
|
||||
import { genUserName } from '@/lib/genUserName';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
|
||||
interface RepositoryCardProps {
|
||||
repo: Repository;
|
||||
}
|
||||
|
||||
export function RepositoryCard({ repo }: RepositoryCardProps) {
|
||||
const { data: authorData } = useAuthor(repo.pubkey);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const displayName = authorData?.metadata?.name || genUserName(repo.pubkey);
|
||||
const profileImage = authorData?.metadata?.picture;
|
||||
|
||||
// Construct Nostr clone URL
|
||||
const nostrCloneUrl = `nostr://${nip19.npubEncode(repo.pubkey)}/${repo.repoId}`;
|
||||
|
||||
const handleClone = () => {
|
||||
// Navigate to clone page with Nostr URL parameter
|
||||
navigate(`/clone?url=${encodeURIComponent(nostrCloneUrl)}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="h-full flex flex-col hover:shadow-lg transition-shadow cursor-pointer" onClick={handleClone}>
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
{/* Header with name and author */}
|
||||
<div className="mb-4">
|
||||
<h3 className="font-semibold text-lg leading-tight mb-2 truncate">
|
||||
{repo.name}
|
||||
</h3>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Avatar className="h-4 w-4">
|
||||
{profileImage && (
|
||||
<AvatarImage src={profileImage} alt={displayName} />
|
||||
)}
|
||||
<AvatarFallback className="text-[8px]">
|
||||
{displayName.slice(0, 2).toUpperCase()}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="truncate">{displayName}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
{repo.description && (
|
||||
<p className="text-sm text-muted-foreground line-clamp-2 mb-4">
|
||||
{repo.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Tags */}
|
||||
{repo.repoTags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1 mb-4">
|
||||
{repo.repoTags.slice(0, 3).map((tag, index) => (
|
||||
<Badge key={index} variant="secondary" className="text-xs">
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
{repo.repoTags.length > 3 && (
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
+{repo.repoTags.length - 3}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Personal fork badge */}
|
||||
{repo.isPersonalFork && (
|
||||
<div className="mb-4">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
Personal Fork
|
||||
</Badge>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<div className="mt-auto">
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-full"
|
||||
onClick={handleClone}
|
||||
>
|
||||
<GitBranch className="h-4 w-4 mr-2" />
|
||||
Clone
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface SettingsItemProps {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
onClick: () => void;
|
||||
isActive?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function SettingsItem({
|
||||
icon: Icon,
|
||||
title,
|
||||
onClick,
|
||||
isActive = false,
|
||||
className,
|
||||
}: SettingsItemProps) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'group w-full text-left p-2 rounded-lg transition-all duration-200 border',
|
||||
{
|
||||
'bg-primary/10 border-primary/20 shadow-sm': isActive,
|
||||
'border-transparent hover:bg-muted/60 hover:shadow-sm': !isActive,
|
||||
},
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="rounded-md transition-all duration-200">
|
||||
<Icon className={cn('h-4 w-4 flex-shrink-0 transition-colors duration-200', {
|
||||
'text-primary': isActive,
|
||||
'text-muted-foreground group-hover:text-foreground': !isActive,
|
||||
})} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className={cn('text-sm font-medium transition-colors duration-200', {
|
||||
'text-primary': isActive,
|
||||
'text-foreground': !isActive,
|
||||
})}>
|
||||
{title}
|
||||
</div>
|
||||
</div>
|
||||
<ChevronRight className={cn(
|
||||
'h-4 w-4 flex-shrink-0 transition-all duration-200',
|
||||
'opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0',
|
||||
{
|
||||
'text-primary opacity-60': isActive,
|
||||
'text-muted-foreground': !isActive,
|
||||
}
|
||||
)} />
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface SettingsItemMobileProps {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
onClick: () => void;
|
||||
isFirst?: boolean;
|
||||
isLast?: boolean;
|
||||
}
|
||||
|
||||
export function SettingsItemMobile({
|
||||
icon: Icon,
|
||||
title,
|
||||
onClick,
|
||||
isFirst = false,
|
||||
isLast = false,
|
||||
}: SettingsItemMobileProps) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'w-full text-left px-4 py-3.5 bg-background transition-colors active:bg-muted/50',
|
||||
'flex items-center gap-3',
|
||||
'border-b border-border last:border-b-0',
|
||||
{
|
||||
'rounded-t-xl': isFirst,
|
||||
'rounded-b-xl': isLast,
|
||||
}
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10">
|
||||
<Icon className="h-4 w-4 text-primary flex-shrink-0" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-base text-foreground">
|
||||
{title}
|
||||
</div>
|
||||
</div>
|
||||
<ChevronRight className="h-5 w-5 text-muted-foreground/50 flex-shrink-0" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { type Project } from '@/lib/ProjectsManager';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { getSettingsItems } from '@/lib/settingsItems';
|
||||
import { getSettingsCategories } from '@/lib/settingsItems';
|
||||
import { SettingsItem } from '@/components/SettingsItem';
|
||||
|
||||
export function SettingsLayout() {
|
||||
const { t } = useTranslation();
|
||||
@@ -60,9 +60,11 @@ export function SettingsLayout() {
|
||||
};
|
||||
|
||||
// Get current settings page
|
||||
const settingsItems = getSettingsItems(t);
|
||||
const settingsCategories = getSettingsCategories(t);
|
||||
const currentPath = location.pathname;
|
||||
const currentSettingsId = settingsItems.find(item => item.href === currentPath)?.id;
|
||||
const currentSettingsId = settingsCategories
|
||||
.flatMap(category => category.items)
|
||||
.find(item => item.href === currentPath)?.id;
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
@@ -89,7 +91,7 @@ export function SettingsLayout() {
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<div className="relative left-0 top-0 h-full w-72 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={(project) => {
|
||||
@@ -112,7 +114,7 @@ export function SettingsLayout() {
|
||||
<div className="h-screen flex bg-background overflow-hidden">
|
||||
{/* Left Column - Projects Sidebar (optionally hidden) */}
|
||||
{isSidebarVisible && (
|
||||
<div className="w-80 border-r bg-sidebar flex-shrink-0">
|
||||
<div className="w-72 border-r bg-sidebar flex-shrink-0">
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={handleProjectSelect}
|
||||
@@ -123,7 +125,7 @@ export function SettingsLayout() {
|
||||
)}
|
||||
|
||||
{/* Middle Column - Settings Navigation */}
|
||||
<div className="w-96 border-r bg-background flex flex-col flex-shrink-0">
|
||||
<div className="w-72 border-r bg-background flex flex-col flex-shrink-0">
|
||||
{/* Header with toggle button */}
|
||||
<div className="h-12 px-4 py-2 border-b flex-shrink-0">
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -146,36 +148,29 @@ export function SettingsLayout() {
|
||||
|
||||
{/* Settings Navigation - Scrollable */}
|
||||
<ScrollArea className="flex-1">
|
||||
<div className="p-4">
|
||||
<div className="space-y-2">
|
||||
{settingsItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
const isActive = currentSettingsId === item.id;
|
||||
<div className="p-4 space-y-6">
|
||||
{settingsCategories.map((category) => (
|
||||
<div key={category.id}>
|
||||
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-2">
|
||||
{category.title}
|
||||
</h3>
|
||||
<div className="space-y-1">
|
||||
{category.items.map((item) => {
|
||||
const isActive = currentSettingsId === item.id;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => navigate(item.href)}
|
||||
className={cn('w-full text-left p-3 rounded-lg transition-colors border border-transparent', {
|
||||
'bg-primary/10 border border-primary/20': isActive,
|
||||
'hover:bg-muted/50': !isActive,
|
||||
})}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<Icon className={`h-5 w-5 mt-0.5 ${isActive ? 'text-primary' : 'text-muted-foreground'}`} />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className={`font-medium ${isActive ? 'text-primary' : 'text-foreground'}`}>
|
||||
{item.title}
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground mt-0.5">
|
||||
{item.description}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
return (
|
||||
<SettingsItem
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
onClick={() => navigate(item.href)}
|
||||
isActive={isActive}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useFSPaths } from '@/hooks/useFSPaths';
|
||||
import { addConsoleMessage, getConsoleMessages, type ConsoleMessage } from '@/lib/consoleMessages';
|
||||
import { useConsoleError } from '@/hooks/useConsoleError';
|
||||
import { useBuildProject } from '@/hooks/useBuildProject';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -25,6 +26,8 @@ import {
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from '@/components/ui/popover';
|
||||
import { NostrPermissionDialog } from '@/components/NostrPermissionDialog';
|
||||
import { NostrSignerRequiredDialog } from '@/components/NostrSignerRequiredDialog';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { FileTree } from './FileTree';
|
||||
import { FileEditor } from './FileEditor';
|
||||
@@ -57,6 +60,16 @@ interface JSONRPCRequest {
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface NostrRPCRequest {
|
||||
jsonrpc: '2.0';
|
||||
method: 'nostr';
|
||||
params: {
|
||||
method: string;
|
||||
args: unknown[];
|
||||
};
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface JSONRPCResponse {
|
||||
jsonrpc: '2.0';
|
||||
result?: {
|
||||
@@ -93,6 +106,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
const { fs } = useFS();
|
||||
const { projectsPath } = useFSPaths();
|
||||
const projectsManager = useProjectsManager();
|
||||
const { user } = useCurrentUser();
|
||||
|
||||
// Use console error state from provider
|
||||
const { hasErrors: hasConsoleErrors, clearErrors } = useConsoleError();
|
||||
@@ -319,6 +333,155 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
}
|
||||
}, [historyIndex, navigationHistory, sendNavigationCommand]);
|
||||
|
||||
// Track which projects have been granted Nostr access
|
||||
const [nostrPermissions, setNostrPermissions] = useState<Set<string>>(new Set());
|
||||
const [nostrPermissionDialog, setNostrPermissionDialog] = useState<{
|
||||
open: boolean;
|
||||
projectId: string;
|
||||
resolve: (granted: boolean) => void;
|
||||
} | null>(null);
|
||||
const [noSignerDialog, setNoSignerDialog] = useState(false);
|
||||
|
||||
const requestNostrPermission = useCallback(async (projectId: string): Promise<boolean> => {
|
||||
// Check if permission already granted
|
||||
if (nostrPermissions.has(projectId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Show permission dialog and wait for user response
|
||||
return new Promise<boolean>((resolve) => {
|
||||
setNostrPermissionDialog({
|
||||
open: true,
|
||||
projectId,
|
||||
resolve,
|
||||
});
|
||||
});
|
||||
}, [nostrPermissions]);
|
||||
|
||||
const handleNostrPermissionResponse = useCallback((granted: boolean) => {
|
||||
if (nostrPermissionDialog) {
|
||||
const { projectId, resolve } = nostrPermissionDialog;
|
||||
|
||||
if (granted) {
|
||||
// Grant permission for this project
|
||||
setNostrPermissions(prev => new Set([...prev, projectId]));
|
||||
}
|
||||
|
||||
// Close dialog and resolve the promise
|
||||
setNostrPermissionDialog(null);
|
||||
resolve(granted);
|
||||
}
|
||||
}, [nostrPermissionDialog]);
|
||||
|
||||
const handleNostr = useCallback(async (request: NostrRPCRequest) => {
|
||||
const { params, id } = request;
|
||||
const { method, args } = params;
|
||||
|
||||
console.log('[NOSTR BRIDGE] Handling request:', method, args);
|
||||
|
||||
try {
|
||||
// Check if user is logged in with a signer
|
||||
if (!user?.signer) {
|
||||
// Show the "no signer" dialog
|
||||
setNoSignerDialog(true);
|
||||
throw new Error('NO_SIGNER_INSTALLED');
|
||||
}
|
||||
|
||||
// Request permission if this is the first Nostr access from this project
|
||||
const hasPermission = await requestNostrPermission(projectId);
|
||||
|
||||
if (!hasPermission) {
|
||||
throw new Error('User denied Nostr access');
|
||||
}
|
||||
|
||||
let result: unknown;
|
||||
|
||||
// Route to appropriate signer method
|
||||
switch (method) {
|
||||
case 'getPublicKey':
|
||||
result = await user.signer.getPublicKey();
|
||||
break;
|
||||
|
||||
case 'signEvent':
|
||||
if (!args[0] || typeof args[0] !== 'object') {
|
||||
throw new Error('Invalid event object');
|
||||
}
|
||||
result = await user.signer.signEvent(args[0] as Parameters<typeof user.signer.signEvent>[0]);
|
||||
break;
|
||||
|
||||
case 'nip04.encrypt':
|
||||
if (!user.signer.nip04?.encrypt) {
|
||||
throw new Error('NIP-04 encryption not supported by signer');
|
||||
}
|
||||
if (typeof args[0] !== 'string' || typeof args[1] !== 'string') {
|
||||
throw new Error('Invalid arguments for nip04.encrypt');
|
||||
}
|
||||
result = await user.signer.nip04.encrypt(args[0], args[1]);
|
||||
break;
|
||||
|
||||
case 'nip04.decrypt':
|
||||
if (!user.signer.nip04?.decrypt) {
|
||||
throw new Error('NIP-04 decryption not supported by signer');
|
||||
}
|
||||
if (typeof args[0] !== 'string' || typeof args[1] !== 'string') {
|
||||
throw new Error('Invalid arguments for nip04.decrypt');
|
||||
}
|
||||
result = await user.signer.nip04.decrypt(args[0], args[1]);
|
||||
break;
|
||||
|
||||
case 'nip44.encrypt':
|
||||
if (!user.signer.nip44?.encrypt) {
|
||||
throw new Error('NIP-44 encryption not supported by signer');
|
||||
}
|
||||
if (typeof args[0] !== 'string' || typeof args[1] !== 'string') {
|
||||
throw new Error('Invalid arguments for nip44.encrypt');
|
||||
}
|
||||
result = await user.signer.nip44.encrypt(args[0], args[1]);
|
||||
break;
|
||||
|
||||
case 'nip44.decrypt':
|
||||
if (!user.signer.nip44?.decrypt) {
|
||||
throw new Error('NIP-44 decryption not supported by signer');
|
||||
}
|
||||
if (typeof args[0] !== 'string' || typeof args[1] !== 'string') {
|
||||
throw new Error('Invalid arguments for nip44.decrypt');
|
||||
}
|
||||
result = await user.signer.nip44.decrypt(args[0], args[1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Unsupported Nostr method: ${method}`);
|
||||
}
|
||||
|
||||
console.log('[NOSTR BRIDGE] Success:', method, result);
|
||||
|
||||
// Send success response
|
||||
if (iframeRef.current?.contentWindow) {
|
||||
const targetOrigin = `https://${projectId}.${previewDomain}`;
|
||||
iframeRef.current.contentWindow.postMessage({
|
||||
jsonrpc: '2.0',
|
||||
result,
|
||||
id
|
||||
}, targetOrigin);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[NOSTR BRIDGE] Error:', method, error);
|
||||
|
||||
// Send error response
|
||||
if (iframeRef.current?.contentWindow) {
|
||||
const targetOrigin = `https://${projectId}.${previewDomain}`;
|
||||
iframeRef.current.contentWindow.postMessage({
|
||||
jsonrpc: '2.0',
|
||||
error: {
|
||||
code: -32000,
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
},
|
||||
id
|
||||
}, targetOrigin);
|
||||
}
|
||||
}
|
||||
}, [user, projectId, previewDomain, requestNostrPermission]);
|
||||
|
||||
const handleFetch = useCallback(async (request: JSONRPCRequest) => {
|
||||
const { params, id } = request;
|
||||
const { request: fetchRequest } = params;
|
||||
@@ -441,7 +604,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
// Verify origin for security
|
||||
const expectedOrigin = `https://${projectId}.${previewDomain}`;
|
||||
if (event.origin !== expectedOrigin) {
|
||||
console.log(`Ignoring message from unexpected origin: ${event.origin}, expected: ${expectedOrigin}`);
|
||||
console.log(`Ignoring message with source ${event.data.source} from unexpected origin: ${event.origin}, expected: ${expectedOrigin}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -449,6 +612,8 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
console.log('Received message from iframe:', message);
|
||||
if (message.jsonrpc === '2.0' && message.method === 'fetch') {
|
||||
handleFetch(message);
|
||||
} else if (message.jsonrpc === '2.0' && message.method === 'nostr') {
|
||||
handleNostr(message);
|
||||
} else if (message.jsonrpc === '2.0' && message.method === 'console') {
|
||||
handleConsoleMessage(message);
|
||||
} else if (message.jsonrpc === '2.0' && message.method === 'updateNavigationState') {
|
||||
@@ -458,7 +623,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
|
||||
window.addEventListener('message', handleMessage);
|
||||
return () => window.removeEventListener('message', handleMessage);
|
||||
}, [handleFetch, handleConsoleMessage, handleUpdateNavigationState, projectId, previewDomain]);
|
||||
}, [handleFetch, handleNostr, handleConsoleMessage, handleUpdateNavigationState, projectId, previewDomain]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedFile) {
|
||||
@@ -948,6 +1113,18 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
onOpenChange={setDeployDialogOpen}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Nostr Permission Dialog */}
|
||||
<NostrPermissionDialog
|
||||
open={nostrPermissionDialog?.open ?? false}
|
||||
onResponse={handleNostrPermissionResponse}
|
||||
/>
|
||||
|
||||
{/* No Signer Installed Dialog */}
|
||||
<NostrSignerRequiredDialog
|
||||
open={noSignerDialog}
|
||||
onOpenChange={setNoSignerDialog}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,6 @@ export function BranchManager({ projectId, currentBranch, onBranchChange }: Bran
|
||||
await git.checkout({
|
||||
dir: projectPath,
|
||||
ref: branchName,
|
||||
force: true,
|
||||
});
|
||||
|
||||
toast({
|
||||
|
||||
@@ -12,7 +12,7 @@ const AccordionItem = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AccordionPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn("border-b", className)}
|
||||
className={cn("border rounded-lg bg-card text-card-foreground shadow-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
|
||||
@@ -11,7 +11,7 @@ const Checkbox = React.forwardRef<
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||
"peer h-4 w-4 shrink-0 rounded-xs border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -17,7 +17,7 @@ const SelectTrigger = React.forwardRef<
|
||||
<SelectPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:bg-border/20 dark:hover:bg-border/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
/**
|
||||
* Hook to get the user's contact list (kind 3 follow list)
|
||||
* Returns an array of pubkeys that the user follows
|
||||
*/
|
||||
export function useContacts(userPubkey?: string) {
|
||||
const { nostr } = useNostr();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['nostr', 'contacts', userPubkey],
|
||||
queryFn: async (): Promise<string[]> => {
|
||||
if (!userPubkey) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get the user's contact list (kind 3)
|
||||
const events = await nostr.query([{
|
||||
kinds: [3],
|
||||
authors: [userPubkey],
|
||||
limit: 1,
|
||||
}], { signal: AbortSignal.timeout(3000) });
|
||||
|
||||
if (events.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get the most recent contact list event
|
||||
const contactList = events.sort((a, b) => b.created_at - a.created_at)[0];
|
||||
|
||||
// Extract pubkeys from 'p' tags
|
||||
const followedPubkeys = contactList.tags
|
||||
.filter(tag => tag[0] === 'p' && tag[1])
|
||||
.map(tag => tag[1]);
|
||||
|
||||
return followedPubkeys;
|
||||
},
|
||||
enabled: !!userPubkey,
|
||||
staleTime: 60000, // 1 minute
|
||||
refetchInterval: 300000, // 5 minutes
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
import type { Repository } from './useUserRepositories';
|
||||
|
||||
// Kind 30617 for repository announcements (NIP-34)
|
||||
const REPOSITORY_KIND = 30617;
|
||||
|
||||
/**
|
||||
* Hook to get repositories from a list of followed users
|
||||
*/
|
||||
export function useFollowedRepositories(followedPubkeys: string[] = []) {
|
||||
const { nostr } = useNostr();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['nostr', 'followed-repositories', followedPubkeys.sort().join(',')],
|
||||
queryFn: async (): Promise<Repository[]> => {
|
||||
if (followedPubkeys.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get all repository announcements from followed users
|
||||
const events = await nostr.query([{
|
||||
kinds: [REPOSITORY_KIND],
|
||||
authors: followedPubkeys,
|
||||
limit: 500, // Increased limit to get more repos from follows
|
||||
}], { signal: AbortSignal.timeout(5000) });
|
||||
|
||||
// Process repository events
|
||||
const repositories: Repository[] = [];
|
||||
const repoMap = new Map<string, NostrEvent>();
|
||||
|
||||
// Group by author+d-tag to get latest version of each repo
|
||||
for (const event of events) {
|
||||
const dTag = event.tags.find(tag => tag[0] === 'd')?.[1];
|
||||
if (!dTag) continue;
|
||||
|
||||
const key = `${event.pubkey}:${dTag}`;
|
||||
const existing = repoMap.get(key);
|
||||
if (!existing || event.created_at > existing.created_at) {
|
||||
repoMap.set(key, event);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to Repository objects
|
||||
for (const [, event] of repoMap) {
|
||||
try {
|
||||
const dTag = event.tags.find(tag => tag[0] === 'd')?.[1];
|
||||
if (!dTag) continue;
|
||||
|
||||
const name = event.tags.find(tag => tag[0] === 'name')?.[1] || dTag;
|
||||
const description = event.tags.find(tag => tag[0] === 'description')?.[1] || '';
|
||||
const webUrls = event.tags.filter(tag => tag[0] === 'web').map(tag => tag[1]).filter(Boolean);
|
||||
const cloneUrls = event.tags.filter(tag => tag[0] === 'clone').map(tag => tag[1]).filter(Boolean);
|
||||
const relays = event.tags.filter(tag => tag[0] === 'relays').map(tag => tag[1]).filter(Boolean);
|
||||
const maintainers = event.tags.filter(tag => tag[0] === 'maintainers').map(tag => tag[1]).filter(Boolean);
|
||||
const repoTags = event.tags.filter(tag => tag[0] === 't' && tag[1] !== 'personal-fork').map(tag => tag[1]);
|
||||
const earliestUniqueCommit = event.tags.find(tag => tag[0] === 'r' && tag[2] === 'euc')?.[1];
|
||||
const isPersonalFork = event.tags.some(tag => tag[0] === 't' && tag[1] === 'personal-fork');
|
||||
|
||||
// Filter out invalid repositories without clone URLs
|
||||
if (cloneUrls.length === 0) {
|
||||
console.warn('Skipping repository without clone URLs:', dTag);
|
||||
continue;
|
||||
}
|
||||
|
||||
repositories.push({
|
||||
...event,
|
||||
repoId: dTag,
|
||||
name,
|
||||
description,
|
||||
webUrls,
|
||||
cloneUrls,
|
||||
relays,
|
||||
maintainers,
|
||||
repoTags,
|
||||
earliestUniqueCommit,
|
||||
isPersonalFork,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to parse repository:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by created_at (newest first)
|
||||
return repositories.sort((a, b) => b.created_at - a.created_at);
|
||||
},
|
||||
enabled: followedPubkeys.length > 0,
|
||||
staleTime: 30000, // 30 seconds
|
||||
refetchInterval: 60000, // 1 minute
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
// Kind 30617 for repository announcements (NIP-34)
|
||||
const REPOSITORY_KIND = 30617;
|
||||
|
||||
export interface Repository extends NostrEvent {
|
||||
repoId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
webUrls: string[];
|
||||
cloneUrls: string[];
|
||||
relays: string[];
|
||||
maintainers: string[];
|
||||
repoTags: string[];
|
||||
earliestUniqueCommit?: string;
|
||||
isPersonalFork: boolean;
|
||||
}
|
||||
|
||||
export function useUserRepositories(userPubkey?: string) {
|
||||
const { nostr } = useNostr();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['nostr', 'user-repositories', userPubkey],
|
||||
queryFn: async (): Promise<Repository[]> => {
|
||||
if (!userPubkey) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get all repository announcements for this user
|
||||
const events = await nostr.query([{
|
||||
kinds: [REPOSITORY_KIND],
|
||||
authors: [userPubkey],
|
||||
limit: 100,
|
||||
}], { signal: AbortSignal.timeout(3000) });
|
||||
|
||||
// Process repository events
|
||||
const repositories: Repository[] = [];
|
||||
const repoMap = new Map<string, NostrEvent>();
|
||||
|
||||
// Group by d-tag (repo-id) to get latest version
|
||||
for (const event of events) {
|
||||
const dTag = event.tags.find(tag => tag[0] === 'd')?.[1];
|
||||
if (!dTag) continue;
|
||||
|
||||
const existing = repoMap.get(dTag);
|
||||
if (!existing || event.created_at > existing.created_at) {
|
||||
repoMap.set(dTag, event);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to Repository objects
|
||||
for (const [dTag, event] of repoMap) {
|
||||
try {
|
||||
const name = event.tags.find(tag => tag[0] === 'name')?.[1] || dTag;
|
||||
const description = event.tags.find(tag => tag[0] === 'description')?.[1] || '';
|
||||
const webUrls = event.tags.filter(tag => tag[0] === 'web').map(tag => tag[1]).filter(Boolean);
|
||||
const cloneUrls = event.tags.filter(tag => tag[0] === 'clone').map(tag => tag[1]).filter(Boolean);
|
||||
const relays = event.tags.filter(tag => tag[0] === 'relays').map(tag => tag[1]).filter(Boolean);
|
||||
const maintainers = event.tags.filter(tag => tag[0] === 'maintainers').map(tag => tag[1]).filter(Boolean);
|
||||
const repoTags = event.tags.filter(tag => tag[0] === 't' && tag[1] !== 'personal-fork').map(tag => tag[1]);
|
||||
const earliestUniqueCommit = event.tags.find(tag => tag[0] === 'r' && tag[2] === 'euc')?.[1];
|
||||
const isPersonalFork = event.tags.some(tag => tag[0] === 't' && tag[1] === 'personal-fork');
|
||||
|
||||
// Filter out invalid repositories without clone URLs
|
||||
if (cloneUrls.length === 0) {
|
||||
console.warn('Skipping repository without clone URLs:', dTag);
|
||||
continue;
|
||||
}
|
||||
|
||||
repositories.push({
|
||||
...event,
|
||||
repoId: dTag,
|
||||
name,
|
||||
description,
|
||||
webUrls,
|
||||
cloneUrls,
|
||||
relays,
|
||||
maintainers,
|
||||
repoTags,
|
||||
earliestUniqueCommit,
|
||||
isPersonalFork,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to parse repository:', error);
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
},
|
||||
enabled: !!userPubkey,
|
||||
staleTime: 30000, // 30 seconds
|
||||
refetchInterval: 60000, // 1 minute
|
||||
});
|
||||
}
|
||||
+1
-6
@@ -37,7 +37,7 @@
|
||||
--input: 220 13% 91%;
|
||||
--ring: 271 81% 56%;
|
||||
|
||||
--radius: 0.375rem;
|
||||
--radius: 0.75rem;
|
||||
|
||||
/* Sidebar colors - Enhanced purple theme */
|
||||
--sidebar-background: 271 81% 96%;
|
||||
@@ -113,16 +113,11 @@
|
||||
border-color: hsl(var(--border));
|
||||
}
|
||||
|
||||
html {
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: hsl(var(--background));
|
||||
color: hsl(var(--foreground));
|
||||
font-family: 'Inter Variable', 'Inter', 'system-ui', 'sans-serif';
|
||||
font-feature-settings: "rlig" 1, "calt" 1;
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
/* GitHub-style scrollbars */
|
||||
|
||||
@@ -122,7 +122,6 @@ export class GitCheckoutCommand implements GitSubcommand {
|
||||
await this.git.checkout({
|
||||
dir: cwd,
|
||||
ref: branchName,
|
||||
force: true,
|
||||
});
|
||||
|
||||
return createSuccessResult(`Switched to branch '${branchName}'\n`);
|
||||
@@ -165,7 +164,6 @@ export class GitCheckoutCommand implements GitSubcommand {
|
||||
await this.git.checkout({
|
||||
dir: cwd,
|
||||
ref: branchName,
|
||||
force: true,
|
||||
});
|
||||
|
||||
return createSuccessResult(`Switched to a new branch '${branchName}'\n`);
|
||||
|
||||
@@ -1244,7 +1244,6 @@ export class Git {
|
||||
fs: this.fs,
|
||||
dir: options.dir,
|
||||
ref: expectedBranch,
|
||||
force: true,
|
||||
});
|
||||
} catch (checkoutError) {
|
||||
console.warn(`Failed to checkout branch ${expectedBranch}:`, checkoutError);
|
||||
|
||||
+70
-55
@@ -2,72 +2,87 @@ import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket } fro
|
||||
|
||||
export interface SettingsItem {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export interface SettingsCategory {
|
||||
id: string;
|
||||
title: string;
|
||||
items: SettingsItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of settings items with translations
|
||||
* Get the categorized list of settings items with translations
|
||||
* @param t - Translation function from useTranslation hook
|
||||
* @returns Array of settings items
|
||||
* @returns Array of settings categories with translated items
|
||||
*/
|
||||
export const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
|
||||
export const getSettingsCategories = (t: (key: string) => string): SettingsCategory[] => [
|
||||
{
|
||||
id: 'preferences',
|
||||
title: t('preferences'),
|
||||
description: t('preferencesDescription'),
|
||||
icon: Settings2,
|
||||
href: '/settings/preferences',
|
||||
id: 'general',
|
||||
title: t('general'),
|
||||
items: [
|
||||
{
|
||||
id: 'preferences',
|
||||
icon: Settings2,
|
||||
title: t('preferences'),
|
||||
href: '/settings/preferences',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'ai',
|
||||
title: t('aiSettings'),
|
||||
description: t('aiSettingsDescription'),
|
||||
icon: Bot,
|
||||
href: '/settings/ai',
|
||||
id: 'integrations',
|
||||
title: t('integrations'),
|
||||
items: [
|
||||
{
|
||||
id: 'ai',
|
||||
icon: Bot,
|
||||
title: t('aiSettings'),
|
||||
href: '/settings/ai',
|
||||
},
|
||||
{
|
||||
id: 'git',
|
||||
icon: GitBranch,
|
||||
title: t('gitSettings'),
|
||||
href: '/settings/git',
|
||||
},
|
||||
{
|
||||
id: 'nostr',
|
||||
icon: Wifi,
|
||||
title: t('nostrSettings'),
|
||||
href: '/settings/nostr',
|
||||
},
|
||||
{
|
||||
id: 'deploy',
|
||||
icon: Rocket,
|
||||
title: t('deploySettings'),
|
||||
href: '/settings/deploy',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'git',
|
||||
title: t('gitSettings'),
|
||||
description: t('gitSettingsDescription'),
|
||||
icon: GitBranch,
|
||||
href: '/settings/git',
|
||||
},
|
||||
{
|
||||
id: 'deploy',
|
||||
title: t('deploySettings'),
|
||||
description: t('deploySettingsDescription'),
|
||||
icon: Rocket,
|
||||
href: '/settings/deploy',
|
||||
},
|
||||
{
|
||||
id: 'nostr',
|
||||
title: t('nostrSettings'),
|
||||
description: t('nostrSettingsDescription'),
|
||||
icon: Wifi,
|
||||
href: '/settings/nostr',
|
||||
},
|
||||
{
|
||||
id: 'storage',
|
||||
title: t('storageSettings'),
|
||||
description: t('storageSettingsDescription'),
|
||||
icon: Database,
|
||||
href: '/settings/storage',
|
||||
},
|
||||
{
|
||||
id: 'system',
|
||||
title: t('systemSettings'),
|
||||
description: t('systemSettingsDescription'),
|
||||
icon: Settings,
|
||||
href: '/settings/system',
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
title: t('aboutShakespeare'),
|
||||
description: t('aboutShakespeareDescription'),
|
||||
icon: Info,
|
||||
href: '/settings/about',
|
||||
id: 'advanced',
|
||||
title: t('advanced'),
|
||||
items: [
|
||||
{
|
||||
id: 'storage',
|
||||
icon: Database,
|
||||
title: t('storageSettings'),
|
||||
href: '/settings/storage',
|
||||
},
|
||||
{
|
||||
id: 'system',
|
||||
icon: Settings,
|
||||
title: t('systemSettings'),
|
||||
href: '/settings/system',
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
icon: Info,
|
||||
title: t('aboutShakespeare'),
|
||||
href: '/settings/about',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
+4
-4
@@ -29,7 +29,7 @@ export const defaultSystemPrompt = `{% if mode === "init" %}You are Shakespeare,
|
||||
|
||||
# Your Environment
|
||||
|
||||
You are operating within **Shakespeare**, an AI-powered Nostr website builder that allows users to create custom Nostr applications through natural language conversation.
|
||||
You are operating within **Shakespeare**, an AI-powered website builder that allows users to create custom applications through natural language conversation.
|
||||
|
||||
- **Current Date**: {{ date }}
|
||||
- **Current Page**: {{ location.href }}
|
||||
@@ -38,7 +38,7 @@ You are operating within **Shakespeare**, an AI-powered Nostr website builder th
|
||||
|
||||
## What Shakespeare Is
|
||||
|
||||
Shakespeare is a web-based development environment where users can build Nostr websites and applications by chatting with an AI assistant (you). The platform combines the power of AI-driven development with a user-friendly interface that requires no coding knowledge from the user.
|
||||
Shakespeare is a web-based development environment where users can build websites and applications by chatting with an AI assistant (you). The platform combines the power of AI-driven development with a user-friendly interface that requires no coding knowledge from the user.
|
||||
|
||||
**Important Architecture Notes:**
|
||||
|
||||
@@ -140,11 +140,11 @@ Shakespeare operates on a browser-based virtual filesystem (VFS) that persists a
|
||||
|
||||
As the AI assistant in Shakespeare, you help users by:
|
||||
- Understanding their requirements through natural conversation
|
||||
- Writing and modifying code files to build their Nostr applications
|
||||
- Writing and modifying code files to build their applications
|
||||
- Explaining technical concepts in accessible terms
|
||||
- Providing suggestions and best practices
|
||||
- Troubleshooting issues and implementing fixes
|
||||
- Building complete, functional Nostr websites and applications
|
||||
- Building complete, functional websites and applications
|
||||
- Learning from existing projects in the VFS to provide better solutions
|
||||
|
||||
The user expects you to handle all technical implementation while they focus on describing their vision and requirements. You can leverage the knowledge from other projects in the VFS to build better, more sophisticated applications.
|
||||
|
||||
@@ -185,4 +185,58 @@ describe('GitCommitTool', () => {
|
||||
|
||||
expect(result).toContain('✅ Successfully committed');
|
||||
});
|
||||
|
||||
it('should error when HEAD is detached (currentBranch returns null)', async () => {
|
||||
// Mock .git directory exists
|
||||
vi.mocked(mockFS.stat).mockResolvedValue({
|
||||
isDirectory: () => true,
|
||||
isFile: () => false,
|
||||
});
|
||||
|
||||
// Mock detached HEAD state - currentBranch returns null
|
||||
vi.mocked(mockGitInstance.currentBranch).mockResolvedValue(null);
|
||||
|
||||
await expect(tool.execute({ message: 'Test commit' })).rejects.toThrow('❌ Cannot commit: Git is in a detached HEAD state');
|
||||
|
||||
// Verify commit was never called
|
||||
expect(mockGitInstance.commit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should error when HEAD is detached (currentBranch returns undefined)', async () => {
|
||||
// Mock .git directory exists
|
||||
vi.mocked(mockFS.stat).mockResolvedValue({
|
||||
isDirectory: () => true,
|
||||
isFile: () => false,
|
||||
});
|
||||
|
||||
// Mock detached HEAD state - currentBranch returns undefined
|
||||
vi.mocked(mockGitInstance.currentBranch).mockResolvedValue(undefined);
|
||||
|
||||
await expect(tool.execute({ message: 'Test commit' })).rejects.toThrow('❌ Cannot commit: Git is in a detached HEAD state');
|
||||
|
||||
// Verify commit was never called
|
||||
expect(mockGitInstance.commit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should provide helpful instructions when HEAD is detached', async () => {
|
||||
// Mock .git directory exists
|
||||
vi.mocked(mockFS.stat).mockResolvedValue({
|
||||
isDirectory: () => true,
|
||||
isFile: () => false,
|
||||
});
|
||||
|
||||
// Mock detached HEAD state
|
||||
vi.mocked(mockGitInstance.currentBranch).mockResolvedValue(null);
|
||||
|
||||
try {
|
||||
await tool.execute({ message: 'Test commit' });
|
||||
expect.fail('Should have thrown an error');
|
||||
} catch (error) {
|
||||
const errorMessage = (error as Error).message;
|
||||
// Verify the error message contains safe instructions that preserve changes
|
||||
expect(errorMessage).toContain('git checkout -b temp-branch');
|
||||
expect(errorMessage).toContain('try the commit again');
|
||||
expect(errorMessage).toContain('preserving all changes');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -41,6 +41,26 @@ export class GitCommitTool implements Tool<GitCommitParams> {
|
||||
throw new Error(`❌ Commit message cannot be empty.`);
|
||||
}
|
||||
|
||||
// Check for detached HEAD state before doing any work
|
||||
// currentBranch returns null when HEAD is detached
|
||||
const currentBranch = await this.git.currentBranch({
|
||||
dir: this.cwd,
|
||||
});
|
||||
|
||||
if (currentBranch === null || currentBranch === undefined) {
|
||||
throw new Error(
|
||||
`❌ Cannot commit: Git is in a detached HEAD state.\n\n` +
|
||||
`This usually happens after checking out a specific commit. ` +
|
||||
`Your changes need to be on a branch before committing.\n\n` +
|
||||
`To fix this and preserve your staged changes:\n` +
|
||||
` 1. Run: git checkout -b temp-branch\n` +
|
||||
` (This creates a new branch from your current state, preserving all changes)\n` +
|
||||
` 2. Then try the commit again\n` +
|
||||
` 3. After committing, you can merge to main with:\n` +
|
||||
` git checkout main && git merge temp-branch`
|
||||
);
|
||||
}
|
||||
|
||||
// Get git status to see what files have changed
|
||||
const statusMatrix = await this.git.statusMatrix({
|
||||
dir: this.cwd,
|
||||
@@ -79,16 +99,6 @@ export class GitCommitTool implements Tool<GitCommitParams> {
|
||||
}
|
||||
}
|
||||
|
||||
// Get current branch name
|
||||
let currentBranch = 'main';
|
||||
try {
|
||||
currentBranch = await this.git.currentBranch({
|
||||
dir: this.cwd,
|
||||
}) || 'main';
|
||||
} catch {
|
||||
// Default to 'main' if we can't get the current branch
|
||||
}
|
||||
|
||||
// Commit the changes (author/committer will be set automatically by Git class)
|
||||
const commitSha = await this.git.commit({
|
||||
dir: this.cwd,
|
||||
|
||||
+6
-7
@@ -3,6 +3,9 @@
|
||||
"settings": "Settings",
|
||||
"backToSettings": "Back to Settings",
|
||||
"help": "Help",
|
||||
"general": "General",
|
||||
"integrations": "Integrations",
|
||||
"advanced": "Advanced",
|
||||
"anonymous": "Anonymous",
|
||||
"logIn": "Log in",
|
||||
"signUp": "Sign up",
|
||||
@@ -94,14 +97,12 @@
|
||||
"chooseModel": "Choose a model...",
|
||||
"selectModelToDescribe": "Please select a model below, then describe what you'd like to build...",
|
||||
"examplePrompt": "e.g., Create a farming equipment marketplace for local farmers to buy and sell tractors, tools, and supplies...",
|
||||
"settingsDescription": "Manage your application settings and preferences.",
|
||||
"aiSettings": "AI",
|
||||
"aiSettingsDescription": "Configure AI providers and API keys",
|
||||
"gitSettings": "Git",
|
||||
"gitSettingsDescription": "Configure Git credentials for HTTP authentication",
|
||||
"deploySettings": "Deployment",
|
||||
"deploySettingsDescription": "Configure deployment providers",
|
||||
"deploySettingsDescriptionLong": "Configure deployment providers to deploy your projects to various hosting platforms.",
|
||||
"nostrSettings": "Nostr",
|
||||
"nostrSettingsDescription": "Configure relay connections and Nostr preferences",
|
||||
"storageSettings": "Storage",
|
||||
@@ -112,6 +113,9 @@
|
||||
"importRepository": "Import Repository",
|
||||
"noProjectsYet": "No projects yet",
|
||||
"createFirstProject": "Create your first project to get started",
|
||||
"searchProjects": "Search projects...",
|
||||
"noProjectsFound": "No projects found",
|
||||
"tryDifferentSearch": "Try a different search term",
|
||||
"closeSidebar": "Close sidebar",
|
||||
"collapseSidebar": "Collapse sidebar",
|
||||
"welcomeToShakespeare": "Welcome to Shakespeare",
|
||||
@@ -179,7 +183,6 @@
|
||||
"pushFailed": "Push failed",
|
||||
"pullSuccessful": "Pull successful",
|
||||
"pullFailed": "Pull failed",
|
||||
"aiSettingsDescriptionLong": "Configure AI providers by adding your API keys. Settings are automatically saved and stored locally in your browser.",
|
||||
"configuredProviders": "Configured Providers",
|
||||
"addProvider": "Add Provider",
|
||||
"getApiKey": "Get API key",
|
||||
@@ -205,7 +208,6 @@
|
||||
"shakespeareDeployNostrAuth": "This provider uses Nostr authentication. Make sure you are logged in to deploy.",
|
||||
"providerType": "Provider Type",
|
||||
"selectProviderType": "Select a provider type",
|
||||
"gitSettingsDescriptionLong": "Configure Git credentials for HTTP authentication. Settings are automatically saved and stored locally in your browser.",
|
||||
"configuredCredentials": "Configured Credentials",
|
||||
"origin": "Origin",
|
||||
"username": "Username",
|
||||
@@ -226,7 +228,6 @@
|
||||
"license": "License",
|
||||
"loadingLicense": "Loading license...",
|
||||
"failedToLoadLicense": "Failed to load license",
|
||||
"dataSettingsDescriptionLong": "Export files and manage local data.",
|
||||
"offlineCache": "Offline Cache",
|
||||
"offlineCacheDescription": "Shakespeare caches files locally to enable offline functionality. Clear the cache to free up space or troubleshoot issues.",
|
||||
"cacheSize": "Cache size",
|
||||
@@ -281,7 +282,6 @@
|
||||
"noModelsFound": "No models found.",
|
||||
"tryCustomModel": "Try using a custom model instead.",
|
||||
"recentlyUsed": "Recently Used",
|
||||
"availableModels": "Available Models",
|
||||
"errorLoadingModels": "Error Loading Models",
|
||||
"apiAuthenticationFailed": "API Authentication Failed",
|
||||
"invalidApiKey": "Invalid API key for {{provider}}. Please check your API key in Settings.",
|
||||
@@ -295,7 +295,6 @@
|
||||
"untracked": "untracked",
|
||||
"toggleSidebar": "Toggle sidebar",
|
||||
"openSidebar": "Open sidebar",
|
||||
"nostrSettingsDescriptionLong": "Configure your Nostr connection settings and relay preferences.",
|
||||
"nostrAccounts": "Nostr Accounts",
|
||||
"noAccountsLoggedIn": "No accounts logged in. Add an account to get started.",
|
||||
"createAccount": "Create Account",
|
||||
|
||||
+6
-5
@@ -3,6 +3,9 @@
|
||||
"settings": "Saitunan",
|
||||
"backToSettings": "Koma zuwa Saitunan",
|
||||
"help": "Taimako",
|
||||
"general": "Gabaɗaya",
|
||||
"integrations": "Haɗin Kai",
|
||||
"advanced": "Ci Gaba",
|
||||
"anonymous": "Maras Suna",
|
||||
"logIn": "Shiga",
|
||||
"signUp": "Yi Rajista",
|
||||
@@ -105,6 +108,9 @@
|
||||
"importRepository": "Shigo da Repository",
|
||||
"noProjectsYet": "Babu ayyuka har yanzu",
|
||||
"createFirstProject": "Ƙirƙiri aikin farko don farawa",
|
||||
"searchProjects": "Nemo ayyuka...",
|
||||
"noProjectsFound": "Ba a sami ayyuka ba",
|
||||
"tryDifferentSearch": "Gwada kalmar nema daban",
|
||||
"closeSidebar": "Rufe gefen mashigi",
|
||||
"collapseSidebar": "Rufe gefen mashigi",
|
||||
"welcomeToShakespeare": "Maraba da Shakespeare",
|
||||
@@ -172,7 +178,6 @@
|
||||
"pushFailed": "Turawa ta gaza",
|
||||
"pullSuccessful": "Ja ya yi nasara",
|
||||
"pullFailed": "Ja ya gaza",
|
||||
"aiSettingsDescriptionLong": "Saita masu samar da AI ta hanyar ƙara maɓallan API. Saitunan ana ajiye su kai tsaye kuma ana adana su a cikin burauzar ku.",
|
||||
"configuredProviders": "Masu Samarwa da aka Saita",
|
||||
"addProvider": "Ƙara Mai Samarwa",
|
||||
"getApiKey": "Sami maɓallin API",
|
||||
@@ -198,7 +203,6 @@
|
||||
"shakespeareDeployNostrAuth": "Wannan mai samarwa yana amfani da tabbatar da Nostr. Tabbatar cewa kun shiga don tura.",
|
||||
"providerType": "Nau'in Mai Samarwa",
|
||||
"selectProviderType": "Zaɓi nau'in mai samarwa",
|
||||
"gitSettingsDescriptionLong": "Saita bayanan shaidar Git don tabbatar da HTTP. Saitunan ana ajiye su kai tsaye kuma ana adana su a cikin burauzar ku.",
|
||||
"configuredCredentials": "Bayanan Shaidar da aka Saita",
|
||||
"origin": "Asali",
|
||||
"username": "Sunan mai amfani",
|
||||
@@ -210,7 +214,6 @@
|
||||
"gitEmail": "Imel Git",
|
||||
"coAuthoredByShakespeare": "Haɗin marubuta da Shakespeare",
|
||||
"gitIdentityDescription": "Idan an saita suna da imel, za a yi amfani da su azaman marubucin aikin. In ba haka ba, za a yi amfani da shakespeare.diy. Lokacin da aka kunna haɗin marubuta, za a ƙara Shakespeare azaman haɗin marubuta.",
|
||||
"dataSettingsDescriptionLong": "Fitar da fayiloli da sarrafa bayanan gida.",
|
||||
"exportFiles": "Fitar da Fayiloli",
|
||||
"exportFilesDescription": "Sauke duk ayyukanku da fayiloli azaman ajiyar ZIP. Wannan ya haɗa da duk fayilolin aikin, saitunan, da bayanan da aka adana a gida.",
|
||||
"exportAllFiles": "Fitar da Duk Fayiloli",
|
||||
@@ -267,7 +270,6 @@
|
||||
"noModelsFound": "Ba a sami samfura ba.",
|
||||
"tryCustomModel": "Gwada amfani da samfuri na musamman.",
|
||||
"recentlyUsed": "An yi amfani da su kwanan nan",
|
||||
"availableModels": "Samfura Masu Samuwa",
|
||||
"errorLoadingModels": "Kuskure wajen Lodin Samfura",
|
||||
"apiAuthenticationFailed": "Gazawar Tabbatarwar API",
|
||||
"invalidApiKey": "Maɓallin API na {{provider}} ba daidai ba ne. Da fatan za a duba maɓallin API a cikin Saitunan.",
|
||||
@@ -281,7 +283,6 @@
|
||||
"untracked": "ba a bi ba",
|
||||
"toggleSidebar": "Juya gefen mashigi",
|
||||
"openSidebar": "Buɗe gefen mashigi",
|
||||
"nostrSettingsDescriptionLong": "Saita saitunan haɗin Nostr da zaɓuɓɓukan relay.",
|
||||
"nostrAccounts": "Asusun Nostr",
|
||||
"noAccountsLoggedIn": "Babu asusun da aka shiga. Ƙara asusu don farawa.",
|
||||
"createAccount": "Ƙirƙiri Asusu",
|
||||
|
||||
+6
-5
@@ -3,6 +3,9 @@
|
||||
"settings": "Ntọala",
|
||||
"backToSettings": "Laghachi na Ntọala",
|
||||
"help": "Enyemaka",
|
||||
"general": "Izugbe",
|
||||
"integrations": "Njikọta",
|
||||
"advanced": "Dị elu",
|
||||
"anonymous": "Onye na-amaghị aha",
|
||||
"logIn": "Banye",
|
||||
"signUp": "Debanye aha",
|
||||
@@ -105,6 +108,9 @@
|
||||
"importRepository": "Bubata Repository",
|
||||
"noProjectsYet": "Enwebeghị ọrụ ọ bụla",
|
||||
"createFirstProject": "Mepụta ọrụ mbụ gị iji malite",
|
||||
"searchProjects": "Chọọ ọrụ...",
|
||||
"noProjectsFound": "Achọtaghị ọrụ ọ bụla",
|
||||
"tryDifferentSearch": "Nwalee okwu ọchụchọ dị iche",
|
||||
"closeSidebar": "Mechie sidebar",
|
||||
"collapseSidebar": "Gbakọọ sidebar",
|
||||
"welcomeToShakespeare": "Nnọọ na Shakespeare",
|
||||
@@ -172,7 +178,6 @@
|
||||
"pushFailed": "Nkwanye dara",
|
||||
"pullSuccessful": "Ndọta gara nke ọma",
|
||||
"pullFailed": "Ndọta dara",
|
||||
"aiSettingsDescriptionLong": "Hazie ndị na-enye AI site na ịtinye igodo API gị. Ntọala na-echekwa onwe ya ma chekwaa ya na mpaghara na browser gị.",
|
||||
"configuredProviders": "Ndị Na-enye Ahaziri",
|
||||
"addProvider": "Tinye Onye Na-enye",
|
||||
"getApiKey": "Nweta igodo API",
|
||||
@@ -198,7 +203,6 @@
|
||||
"shakespeareDeployNostrAuth": "Onye na-enye a na-eji nkwenye Nostr. Jide n'aka na ị banyere iji bufee.",
|
||||
"providerType": "Ụdị Onye Na-enye",
|
||||
"selectProviderType": "Họrọ ụdị onye na-enye",
|
||||
"gitSettingsDescriptionLong": "Hazie nzere Git maka nkwenye HTTP. Ntọala na-echekwa onwe ya ma chekwaa ya na mpaghara na browser gị.",
|
||||
"configuredCredentials": "Nzere Ahaziri",
|
||||
"origin": "Mmalite",
|
||||
"username": "Aha onye ọrụ",
|
||||
@@ -210,7 +214,6 @@
|
||||
"gitEmail": "Ozi-eletrọniki Git",
|
||||
"coAuthoredByShakespeare": "Ndekọ ọnụ na Shakespeare",
|
||||
"gitIdentityDescription": "Ọ bụrụ na ahaziri aha na ozi-eletrọniki, a ga-eji ha dị ka onye dere ya. Ma ọ bụghị, a ga-eji shakespeare.diy. Mgbe emere ndekọ ọnụ, a ga-etinye Shakespeare dị ka ndekọ ọnụ.",
|
||||
"dataSettingsDescriptionLong": "Bupụta faịlụ ma jikwaa data mpaghara.",
|
||||
"exportFiles": "Bupụta Faịlụ",
|
||||
"exportFilesDescription": "Budata ọrụ gị niile na faịlụ dị ka mkpokọta ZIP. Nke a gụnyere faịlụ ọrụ niile, ntọala, na data echekwara na mpaghara.",
|
||||
"exportAllFiles": "Bupụta Faịlụ Niile",
|
||||
@@ -267,7 +270,6 @@
|
||||
"noModelsFound": "Ahụghị ụdịdị ọ bụla.",
|
||||
"tryCustomModel": "Gbalịa iji ụdịdị omenala kama.",
|
||||
"recentlyUsed": "Ejiri Na Nso Nso A",
|
||||
"availableModels": "Ụdịdị Dị",
|
||||
"errorLoadingModels": "Njehie Na-ebu Ụdịdị",
|
||||
"contextUsage": "Ojiji ọnọdụ: {{tokens}} / {{total}} tokens ({{percentage}}%)",
|
||||
"totalCostSession": "Mkpokọta ọnụ ahịa maka oge nkata a",
|
||||
@@ -278,7 +280,6 @@
|
||||
"untracked": "na-esoghị",
|
||||
"toggleSidebar": "Gbanwee sidebar",
|
||||
"openSidebar": "Meghee sidebar",
|
||||
"nostrSettingsDescriptionLong": "Hazie ntọala njikọ Nostr gị na nhọrọ relay.",
|
||||
"nostrAccounts": "Akaụntụ Nostr",
|
||||
"noAccountsLoggedIn": "Enweghị akaụntụ banyere. Tinye akaụntụ iji malite.",
|
||||
"createAccount": "Mepụta Akaụntụ",
|
||||
|
||||
+6
-6
@@ -3,6 +3,9 @@
|
||||
"settings": "Configurações",
|
||||
"backToSettings": "Voltar às Configurações",
|
||||
"help": "Ajuda",
|
||||
"general": "Geral",
|
||||
"integrations": "Integrações",
|
||||
"advanced": "Avançado",
|
||||
"anonymous": "Anônimo",
|
||||
"logIn": "Entrar",
|
||||
"signUp": "Cadastrar",
|
||||
@@ -97,7 +100,6 @@
|
||||
"gitSettingsDescription": "Configure credenciais do Git para autenticação HTTP",
|
||||
"deploySettings": "Implantação",
|
||||
"deploySettingsDescription": "Configure provedores de implantação",
|
||||
"deploySettingsDescriptionLong": "Configure provedores de implantação para implantar seus projetos em várias plataformas de hospedagem.",
|
||||
"nostrSettings": "Nostr",
|
||||
"nostrSettingsDescription": "Configure conexões de relay e preferências do Nostr",
|
||||
"storageSettings": "Armazenamento",
|
||||
@@ -108,6 +110,9 @@
|
||||
"importRepository": "Importar Repositório",
|
||||
"noProjectsYet": "Nenhum projeto ainda",
|
||||
"createFirstProject": "Crie seu primeiro projeto para começar",
|
||||
"searchProjects": "Pesquisar projetos...",
|
||||
"noProjectsFound": "Nenhum projeto encontrado",
|
||||
"tryDifferentSearch": "Tente um termo de pesquisa diferente",
|
||||
"closeSidebar": "Fechar barra lateral",
|
||||
"collapseSidebar": "Recolher barra lateral",
|
||||
"welcomeToShakespeare": "Bem-vindo ao Shakespeare",
|
||||
@@ -175,7 +180,6 @@
|
||||
"pushFailed": "Push falhou",
|
||||
"pullSuccessful": "Pull realizado com sucesso",
|
||||
"pullFailed": "Pull falhou",
|
||||
"aiSettingsDescriptionLong": "Configure provedores de IA adicionando suas chaves de API. As configurações são salvas automaticamente e armazenadas localmente em seu navegador.",
|
||||
"configuredProviders": "Provedores Configurados",
|
||||
"addProvider": "Adicionar Provedor",
|
||||
"getApiKey": "Obter chave de API",
|
||||
@@ -201,7 +205,6 @@
|
||||
"shakespeareDeployNostrAuth": "Este provedor usa autenticação Nostr. Certifique-se de estar logado para implantar.",
|
||||
"providerType": "Tipo de Provedor",
|
||||
"selectProviderType": "Selecione um tipo de provedor",
|
||||
"gitSettingsDescriptionLong": "Configure credenciais do Git para autenticação HTTP. As configurações são salvas automaticamente e armazenadas localmente em seu navegador.",
|
||||
"configuredCredentials": "Credenciais Configuradas",
|
||||
"origin": "Origem",
|
||||
"username": "Nome de usuário",
|
||||
@@ -213,7 +216,6 @@
|
||||
"gitEmail": "Email Git",
|
||||
"coAuthoredByShakespeare": "Co-autoria de Shakespeare",
|
||||
"gitIdentityDescription": "Se nome e email estiverem configurados, eles serão usados como autor do commit. Caso contrário, shakespeare.diy será usado. Quando co-autoria estiver ativada, Shakespeare será adicionado como co-autor.",
|
||||
"dataSettingsDescriptionLong": "Exporte arquivos e gerencie dados locais.",
|
||||
"offlineCache": "Cache Offline",
|
||||
"offlineCacheDescription": "O Shakespeare armazena arquivos localmente para permitir funcionalidade offline. Limpe o cache para liberar espaço ou solucionar problemas.",
|
||||
"cacheSize": "Tamanho do cache",
|
||||
@@ -277,7 +279,6 @@
|
||||
"noModelsFound": "Nenhum modelo encontrado.",
|
||||
"tryCustomModel": "Tente usar um modelo personalizado.",
|
||||
"recentlyUsed": "Usados Recentemente",
|
||||
"availableModels": "Modelos Disponíveis",
|
||||
"errorLoadingModels": "Erro ao Carregar Modelos",
|
||||
"apiAuthenticationFailed": "Falha na Autenticação da API",
|
||||
"invalidApiKey": "Chave de API inválida para {{provider}}. Verifique sua chave de API nas Configurações.",
|
||||
@@ -291,7 +292,6 @@
|
||||
"untracked": "não rastreado",
|
||||
"toggleSidebar": "Alternar barra lateral",
|
||||
"openSidebar": "Abrir barra lateral",
|
||||
"nostrSettingsDescriptionLong": "Configure suas configurações de conexão Nostr e preferências de relay.",
|
||||
"nostrAccounts": "Contas Nostr",
|
||||
"noAccountsLoggedIn": "Nenhuma conta logada. Adicione uma conta para começar.",
|
||||
"createAccount": "Criar Conta",
|
||||
|
||||
+6
-5
@@ -3,6 +3,9 @@
|
||||
"settings": "Awọn eto",
|
||||
"backToSettings": "Pada si Awọn eto",
|
||||
"help": "Iranlọwọ",
|
||||
"general": "Gbogbogbo",
|
||||
"integrations": "Awọn isopọ",
|
||||
"advanced": "To siwaju",
|
||||
"anonymous": "Alainidamọ",
|
||||
"logIn": "Wọle",
|
||||
"signUp": "Forukọsilẹ",
|
||||
@@ -105,6 +108,9 @@
|
||||
"importRepository": "Gbe Repository wọle",
|
||||
"noProjectsYet": "Ko si awọn iṣẹ akanṣe sibẹsibẹ",
|
||||
"createFirstProject": "Ṣẹda iṣẹ akanṣe akọkọ rẹ lati bẹrẹ",
|
||||
"searchProjects": "Wa awọn iṣẹ akanṣe...",
|
||||
"noProjectsFound": "Ko ri awọn iṣẹ akanṣe",
|
||||
"tryDifferentSearch": "Gbiyanju ọrọ wiwa miiran",
|
||||
"closeSidebar": "Ti ẹgbẹ sidebar",
|
||||
"collapseSidebar": "Subu sidebar",
|
||||
"welcomeToShakespeare": "Kaabo si Shakespeare",
|
||||
@@ -172,7 +178,6 @@
|
||||
"pushFailed": "Titari kuna",
|
||||
"pullSuccessful": "Fifa ni aṣeyọri",
|
||||
"pullFailed": "Fifa kuna",
|
||||
"aiSettingsDescriptionLong": "Tunto awọn olupese AI nipa fifi awọn bọtini API rẹ kun. Awọn eto ni a fi pamọ laifọwọyi ati pe a tọju wọn ni agbegbe ninu awọn aṣawakiri rẹ.",
|
||||
"configuredProviders": "Awọn Olupese Ti a Tunto",
|
||||
"addProvider": "Fi Olupese kun",
|
||||
"getApiKey": "Gba bọtini API",
|
||||
@@ -198,7 +203,6 @@
|
||||
"shakespeareDeployNostrAuth": "Olupese yii nlo ijẹrisi Nostr. Rii daju pe o ti wọle lati gbe jade.",
|
||||
"providerType": "Iru Olupese",
|
||||
"selectProviderType": "Yan iru olupese kan",
|
||||
"gitSettingsDescriptionLong": "Tunto awọn ẹri Git fun ijẹrisi HTTP. Awọn eto ni a fi pamọ laifọwọyi ati pe a tọju wọn ni agbegbe ninu awọn aṣawakiri rẹ.",
|
||||
"configuredCredentials": "Awọn Ẹri Ti a Tunto",
|
||||
"origin": "Ipilẹṣẹ",
|
||||
"username": "Orukọ olumulo",
|
||||
@@ -210,7 +214,6 @@
|
||||
"gitEmail": "Imeeli Git",
|
||||
"coAuthoredByShakespeare": "Ajọpọ onkọwe pẹlu Shakespeare",
|
||||
"gitIdentityDescription": "Ti a ba tunto orukọ ati imeeli, wọn yoo jẹ lilo bi onkọwe. Bibẹẹkọ, shakespeare.diy yoo jẹ lilo. Nigbati a ba mu ajọpọ onkọwe ṣiṣẹ, Shakespeare yoo jẹ fifikun bi ajọpọ onkọwe.",
|
||||
"dataSettingsDescriptionLong": "Gbe awọn faili jade ati ṣakoso data agbegbe.",
|
||||
"exportFiles": "Gbe Awọn faili jade",
|
||||
"exportFilesDescription": "Gba gbogbo awọn iṣẹ akanṣe ati awọn faili rẹ gẹgẹbi apo ZIP. Eyi pẹlu gbogbo awọn faili iṣẹ akanṣe, awọn eto, ati data ti a tọju ni agbegbe.",
|
||||
"exportAllFiles": "Gbe Gbogbo Awọn faili jade",
|
||||
@@ -267,7 +270,6 @@
|
||||
"noModelsFound": "Ko si awọn awoṣe ti a ri.",
|
||||
"tryCustomModel": "Gbiyanju lilo awoṣe aṣa dipo.",
|
||||
"recentlyUsed": "Ti a Lo Laipẹ",
|
||||
"availableModels": "Awọn awoṣe Ti O Wa",
|
||||
"errorLoadingModels": "Aṣiṣe Gbigbe Awọn awoṣe",
|
||||
"contextUsage": "Lilo aaye oro: {{tokens}} / {{total}} awọn token ({{percentage}}%)",
|
||||
"totalCostSession": "Lapapọ iye owo fun igba ibaraẹnisọrọ yii",
|
||||
@@ -278,7 +280,6 @@
|
||||
"untracked": "ti a ko tọpa",
|
||||
"toggleSidebar": "Yipada sidebar",
|
||||
"openSidebar": "Ṣi sidebar",
|
||||
"nostrSettingsDescriptionLong": "Tunto awọn eto asopọ Nostr rẹ ati awọn ayanfẹ relay.",
|
||||
"nostrAccounts": "Awọn Akọọlẹ Nostr",
|
||||
"noAccountsLoggedIn": "Ko si awọn akọọlẹ ti o wọle. Fi akọọlẹ kun lati bẹrẹ.",
|
||||
"createAccount": "Ṣẹda Akọọlẹ",
|
||||
|
||||
+6
-6
@@ -3,6 +3,9 @@
|
||||
"settings": "设置",
|
||||
"backToSettings": "返回设置",
|
||||
"help": "帮助",
|
||||
"general": "常规",
|
||||
"integrations": "集成",
|
||||
"advanced": "高级",
|
||||
"anonymous": "匿名",
|
||||
"logIn": "登录",
|
||||
"signUp": "注册",
|
||||
@@ -97,7 +100,6 @@
|
||||
"gitSettingsDescription": "配置HTTP身份验证的Git凭据",
|
||||
"deploySettings": "部署",
|
||||
"deploySettingsDescription": "配置部署提供商",
|
||||
"deploySettingsDescriptionLong": "配置部署提供商以将您的项目部署到各种托管平台。",
|
||||
"nostrSettings": "Nostr",
|
||||
"nostrSettingsDescription": "配置中继连接和Nostr偏好",
|
||||
"storageSettings": "存储",
|
||||
@@ -108,6 +110,9 @@
|
||||
"importRepository": "导入仓库",
|
||||
"noProjectsYet": "还没有项目",
|
||||
"createFirstProject": "创建您的第一个项目开始使用",
|
||||
"searchProjects": "搜索项目...",
|
||||
"noProjectsFound": "未找到项目",
|
||||
"tryDifferentSearch": "尝试不同的搜索词",
|
||||
"closeSidebar": "关闭侧边栏",
|
||||
"collapseSidebar": "折叠侧边栏",
|
||||
"welcomeToShakespeare": "欢迎使用Shakespeare",
|
||||
@@ -175,7 +180,6 @@
|
||||
"pushFailed": "推送失败",
|
||||
"pullSuccessful": "拉取成功",
|
||||
"pullFailed": "拉取失败",
|
||||
"aiSettingsDescriptionLong": "通过添加您的API密钥来配置AI提供商。设置会自动保存并存储在您的浏览器本地。",
|
||||
"configuredProviders": "已配置的提供商",
|
||||
"addProvider": "添加提供商",
|
||||
"getApiKey": "获取API密钥",
|
||||
@@ -201,7 +205,6 @@
|
||||
"shakespeareDeployNostrAuth": "此提供商使用Nostr身份验证。请确保您已登录以进行部署。",
|
||||
"providerType": "提供商类型",
|
||||
"selectProviderType": "选择提供商类型",
|
||||
"gitSettingsDescriptionLong": "配置HTTP身份验证的Git凭据。设置会自动保存并存储在您的浏览器本地。",
|
||||
"configuredCredentials": "已配置的凭据",
|
||||
"origin": "源",
|
||||
"username": "用户名",
|
||||
@@ -213,7 +216,6 @@
|
||||
"gitEmail": "Git邮箱",
|
||||
"coAuthoredByShakespeare": "Shakespeare共同作者",
|
||||
"gitIdentityDescription": "如果配置了名称和邮箱,它们将用作提交作者。否则,将使用shakespeare.diy。启用共同作者时,Shakespeare将被添加为共同作者。",
|
||||
"dataSettingsDescriptionLong": "导出文件和管理本地数据。",
|
||||
"offlineCache": "离线缓存",
|
||||
"offlineCacheDescription": "Shakespeare在本地缓存文件以启用离线功能。清除缓存以释放空间或解决问题。",
|
||||
"cacheSize": "缓存大小",
|
||||
@@ -277,7 +279,6 @@
|
||||
"noModelsFound": "未找到模型。",
|
||||
"tryCustomModel": "尝试使用自定义模型。",
|
||||
"recentlyUsed": "最近使用",
|
||||
"availableModels": "可用模型",
|
||||
"errorLoadingModels": "加载模型时出错",
|
||||
"apiAuthenticationFailed": "API身份验证失败",
|
||||
"invalidApiKey": "{{provider}}的API密钥无效。请在设置中检查您的API密钥。",
|
||||
@@ -291,7 +292,6 @@
|
||||
"untracked": "未跟踪",
|
||||
"toggleSidebar": "切换侧边栏",
|
||||
"openSidebar": "打开侧边栏",
|
||||
"nostrSettingsDescriptionLong": "配置您的Nostr连接设置和中继偏好。",
|
||||
"nostrAccounts": "Nostr账户",
|
||||
"noAccountsLoggedIn": "没有账户登录。添加账户开始使用。",
|
||||
"createAccount": "创建账户",
|
||||
|
||||
+42
-39
@@ -26,6 +26,7 @@ import { PasswordInput } from '@/components/ui/password-input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { CreditsBadge } from '@/components/CreditsBadge';
|
||||
import { CreditsDialog } from '@/components/CreditsDialog';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
@@ -303,7 +304,7 @@ export function AISettings() {
|
||||
{t('aiSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aiSettingsDescriptionLong')}
|
||||
{t('aiSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -316,7 +317,7 @@ export function AISettings() {
|
||||
{t('aiSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aiSettingsDescriptionLong')}
|
||||
{t('aiSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
@@ -368,43 +369,44 @@ export function AISettings() {
|
||||
const showNostrLoginRequired = isNostrPreset && !isLoggedIntoNostr;
|
||||
|
||||
return (
|
||||
<div key={preset.id} className="border rounded-lg p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
url={preset.baseURL}
|
||||
size={16}
|
||||
fallback={<Bot size={16} />}
|
||||
/>
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
<Card key={preset.id}>
|
||||
<CardContent className="p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
url={preset.baseURL}
|
||||
size={16}
|
||||
fallback={<Bot size={16} />}
|
||||
/>
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
</div>
|
||||
{(preset.apiKeysURL && preset.id !== "routstr") && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.apiKeysURL, '_blank')}
|
||||
>
|
||||
{t('getApiKey')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{(preset.apiKeysURL && preset.id !== "routstr") && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.apiKeysURL, '_blank')}
|
||||
>
|
||||
{t('getApiKey')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{showNostrLoginRequired ? (
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('loginToNostrRequired')}
|
||||
</p>
|
||||
<Button
|
||||
asChild
|
||||
className="w-full"
|
||||
>
|
||||
<Link to="/settings/nostr">
|
||||
{t('goToNostrSettings')}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{showNostrLoginRequired ? (
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('loginToNostrRequired')}
|
||||
</p>
|
||||
<Button
|
||||
asChild
|
||||
className="w-full"
|
||||
>
|
||||
<Link to="/settings/nostr">
|
||||
{t('goToNostrSettings')}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<div className="flex gap-2">
|
||||
{!preset.nostr && (
|
||||
<PasswordInput
|
||||
@@ -469,7 +471,8 @@ export function AISettings() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@@ -479,7 +482,7 @@ export function AISettings() {
|
||||
{/* Custom Provider */}
|
||||
<div className="space-y-3">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="custom-provider" className="border rounded-lg">
|
||||
<AccordionItem value="custom-provider">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">{t('addCustomProvider')}</h4>
|
||||
</AccordionTrigger>
|
||||
|
||||
+18
-13
@@ -5,6 +5,7 @@ import { Info, ExternalLink, Loader2, AlertTriangle, ArrowLeft, Code, Globe } fr
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { EmailSubscription } from '@/components/EmailSubscription';
|
||||
|
||||
@@ -85,7 +86,7 @@ export function AboutSettings() {
|
||||
<div className="space-y-3">
|
||||
{/* Mirrors */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="mirrors" className="border rounded-lg">
|
||||
<AccordionItem value="mirrors">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<Globe className="h-5 w-5" />
|
||||
@@ -131,21 +132,25 @@ export function AboutSettings() {
|
||||
</Accordion>
|
||||
|
||||
{/* Project Information */}
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full h-12 flex items-center gap-2 justify-start text-base"
|
||||
asChild
|
||||
>
|
||||
<a href="https://gitlab.com/soapbox-pub/shakespeare" target="_blank">
|
||||
<Code className="!size-5" />
|
||||
{t('sourceCode')}
|
||||
<ExternalLink className="ml-auto" />
|
||||
</a>
|
||||
</Button>
|
||||
<Card>
|
||||
<CardContent className="p-0">
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-full h-12 flex items-center gap-2 justify-start text-base"
|
||||
asChild
|
||||
>
|
||||
<a href="https://gitlab.com/soapbox-pub/shakespeare" target="_blank">
|
||||
<Code className="!size-5" />
|
||||
{t('sourceCode')}
|
||||
<ExternalLink className="ml-auto" />
|
||||
</a>
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* License */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="license-text" className="border rounded-lg">
|
||||
<AccordionItem value="license-text">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<Info className="h-5 w-5" />
|
||||
|
||||
@@ -10,6 +10,14 @@ import { useToast } from '@/hooks/useToast';
|
||||
import { ZipImportDialog } from '@/components/ZipImportDialog';
|
||||
import { useSeoMeta } from '@unhead/react';
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useUserRepositories } from '@/hooks/useUserRepositories';
|
||||
import { useContacts } from '@/hooks/useContacts';
|
||||
import { useFollowedRepositories } from '@/hooks/useFollowedRepositories';
|
||||
import { RepositoryCard } from '@/components/RepositoryCard';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||
|
||||
export default function Clone() {
|
||||
const { t } = useTranslation();
|
||||
@@ -22,6 +30,11 @@ export default function Clone() {
|
||||
const { toast } = useToast();
|
||||
const autoCloneInitiatedRef = useRef(false);
|
||||
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
|
||||
const { user } = useCurrentUser();
|
||||
const { data: repositories = [], isLoading: isLoadingRepos } = useUserRepositories(user?.pubkey);
|
||||
const { data: contacts = [] } = useContacts(user?.pubkey);
|
||||
const { data: followedRepositories = [], isLoading: isLoadingFollowedRepos } = useFollowedRepositories(contacts);
|
||||
const [activeTab, setActiveTab] = useState<'my-projects' | 'follows'>('my-projects');
|
||||
|
||||
useSeoMeta({
|
||||
title: `${t('importRepository')} - Shakespeare`,
|
||||
@@ -276,6 +289,128 @@ export default function Clone() {
|
||||
open={isZipDialogOpen}
|
||||
onOpenChange={setIsZipDialogOpen}
|
||||
/>
|
||||
|
||||
{/* NIP-34 Repositories with Tabs */}
|
||||
{user && (
|
||||
<div className="mt-16 max-w-7xl mx-auto">
|
||||
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as 'my-projects' | 'follows')}>
|
||||
<TabsList className="mb-6">
|
||||
<TabsTrigger value="my-projects">
|
||||
My Projects
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="follows">
|
||||
Follows
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="my-projects">
|
||||
{isLoadingRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : repositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{repositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
No repositories found. Publish your first repository to Nostr to see it here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="follows">
|
||||
{isLoadingFollowedRepos ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<Card key={i} className="h-full flex flex-col">
|
||||
<CardContent className="p-6 flex flex-col flex-1">
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<Skeleton className="w-12 h-12 rounded-lg" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 mb-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-4/5" />
|
||||
</div>
|
||||
<div className="flex gap-1 mb-4">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mt-auto flex gap-2">
|
||||
<Skeleton className="h-9 flex-1" />
|
||||
<Skeleton className="h-9 w-9" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : followedRepositories.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{followedRepositories.map((repo) => (
|
||||
<RepositoryCard key={repo.id} repo={repo} />
|
||||
))}
|
||||
</div>
|
||||
) : contacts.length > 0 ? (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
None of the people you follow have published repositories yet.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="py-12 px-8 text-center">
|
||||
<div className="max-w-sm mx-auto space-y-4">
|
||||
<p className="text-muted-foreground">
|
||||
You're not following anyone yet. Follow people on Nostr to see their repositories here.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { PasswordInput } from '@/components/ui/password-input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useDeploySettings } from '@/hooks/useDeploySettings';
|
||||
import { useNetlifyOAuth } from '@/hooks/useNetlifyOAuth';
|
||||
@@ -83,7 +84,6 @@ function SortableProviderItem({ provider, index, preset, onRemove, onUpdate, sho
|
||||
ref={setNodeRef}
|
||||
style={style}
|
||||
value={String(index)}
|
||||
className="border rounded-lg"
|
||||
>
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -519,7 +519,7 @@ export function DeploySettings() {
|
||||
{t('deploySettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('deploySettingsDescriptionLong')}
|
||||
{t('deploySettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -532,7 +532,7 @@ export function DeploySettings() {
|
||||
{t('deploySettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('deploySettingsDescriptionLong')}
|
||||
{t('deploySettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
@@ -591,36 +591,37 @@ export function DeploySettings() {
|
||||
const oauthError = oauthHook?.error ?? null;
|
||||
|
||||
return (
|
||||
<div key={preset.id} className="border rounded-lg p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
{(() => {
|
||||
const url = getProviderUrl(preset);
|
||||
return url ? (
|
||||
<ExternalFavicon
|
||||
url={url}
|
||||
size={16}
|
||||
fallback={<Rocket size={16} />}
|
||||
/>
|
||||
) : (
|
||||
<Rocket size={16} />
|
||||
);
|
||||
})()}
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
<Card key={preset.id}>
|
||||
<CardContent className="p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
{(() => {
|
||||
const url = getProviderUrl(preset);
|
||||
return url ? (
|
||||
<ExternalFavicon
|
||||
url={url}
|
||||
size={16}
|
||||
fallback={<Rocket size={16} />}
|
||||
/>
|
||||
) : (
|
||||
<Rocket size={16} />
|
||||
);
|
||||
})()}
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
</div>
|
||||
{preset.apiKeyURL && !isOAuthConfigured && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.apiKeyURL, '_blank')}
|
||||
>
|
||||
{t('getApiKey')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{preset.apiKeyURL && !isOAuthConfigured && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.apiKeyURL, '_blank')}
|
||||
>
|
||||
{t('getApiKey')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">{preset.description}</p>
|
||||
<p className="text-sm text-muted-foreground">{preset.description}</p>
|
||||
|
||||
{showNostrLoginRequired ? (
|
||||
{showNostrLoginRequired ? (
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('loginToNostrRequired')}
|
||||
@@ -724,7 +725,8 @@ export function DeploySettings() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@@ -734,7 +736,7 @@ export function DeploySettings() {
|
||||
{/* Custom Provider */}
|
||||
<div className="space-y-3">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="custom-provider" className="border rounded-lg">
|
||||
<AccordionItem value="custom-provider">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">{t('addCustomProvider')}</h4>
|
||||
</AccordionTrigger>
|
||||
|
||||
+29
-26
@@ -6,6 +6,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -126,7 +127,7 @@ export function GitSettings() {
|
||||
{t('gitSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('gitSettingsDescriptionLong')}
|
||||
{t('gitSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,7 +140,7 @@ export function GitSettings() {
|
||||
{t('gitSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('gitSettingsDescriptionLong')}
|
||||
{t('gitSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
@@ -156,7 +157,7 @@ export function GitSettings() {
|
||||
const isCustom = !preset;
|
||||
|
||||
return (
|
||||
<AccordionItem key={origin} value={origin} className="border rounded-lg">
|
||||
<AccordionItem key={origin} value={origin}>
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
@@ -223,28 +224,29 @@ export function GitSettings() {
|
||||
<h4 className="text-sm font-medium">{t('addProvider')}</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
{availablePresets.map((preset) => (
|
||||
<div key={preset.id} className="border rounded-lg p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
url={preset.origin}
|
||||
size={16}
|
||||
fallback={<GitBranch size={16} />}
|
||||
/>
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
<Card key={preset.id}>
|
||||
<CardContent className="p-4 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ExternalFavicon
|
||||
url={preset.origin}
|
||||
size={16}
|
||||
fallback={<GitBranch size={16} />}
|
||||
/>
|
||||
<h5 className="font-medium">{preset.name}</h5>
|
||||
</div>
|
||||
{preset.tokenURL && (preset.id !== 'github' || !isOAuthConfigured) && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.tokenURL, '_blank')}
|
||||
>
|
||||
{t('getToken')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{preset.tokenURL && (preset.id !== 'github' || !isOAuthConfigured) && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground underline hover:text-foreground"
|
||||
onClick={() => window.open(preset.tokenURL, '_blank')}
|
||||
>
|
||||
{t('getToken')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{preset.id === 'github' ? (
|
||||
{preset.id === 'github' ? (
|
||||
// Special rendering for GitHub - OAuth button if configured, otherwise token input
|
||||
isOAuthConfigured && !forceManualEntry[preset.id] ? (
|
||||
<div className="space-y-3">
|
||||
@@ -349,7 +351,8 @@ export function GitSettings() {
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -358,7 +361,7 @@ export function GitSettings() {
|
||||
{/* Custom Provider */}
|
||||
<div className="space-y-3">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="custom-provider" className="border rounded-lg">
|
||||
<AccordionItem value="custom-provider">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">{t('addCustomProvider')}</h4>
|
||||
</AccordionTrigger>
|
||||
@@ -419,7 +422,7 @@ export function GitSettings() {
|
||||
{/* Git Identity */}
|
||||
<div className="space-y-3">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="git-identity" className="border rounded-lg">
|
||||
<AccordionItem value="git-identity">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">{t('gitIdentity')}</h4>
|
||||
</AccordionTrigger>
|
||||
|
||||
@@ -150,7 +150,7 @@ export function NostrSettings() {
|
||||
{t('nostrSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('nostrSettingsDescriptionLong')}
|
||||
{t('nostrSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -163,7 +163,7 @@ export function NostrSettings() {
|
||||
{t('nostrSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('nostrSettingsDescriptionLong')}
|
||||
{t('nostrSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -199,7 +199,7 @@ export function ProjectView() {
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<div className="relative left-0 top-0 h-full w-72 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={project}
|
||||
onSelectProject={(selectedProject) => {
|
||||
@@ -314,7 +314,7 @@ export function ProjectView() {
|
||||
return (
|
||||
<div className="h-screen flex bg-background">
|
||||
{/* Fixed Sidebar */}
|
||||
<div className={`w-80 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
|
||||
<div className={`w-72 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
|
||||
<ProjectSidebar
|
||||
selectedProject={project}
|
||||
onSelectProject={(selectedProject) => {
|
||||
|
||||
+24
-28
@@ -1,42 +1,38 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { getSettingsItems } from '@/lib/settingsItems';
|
||||
import { getSettingsCategories } from '@/lib/settingsItems';
|
||||
import { SettingsItemMobile } from '@/components/SettingsItemMobile';
|
||||
|
||||
export function Settings() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const settingsItems = getSettingsItems(t);
|
||||
const settingsCategories = getSettingsCategories(t);
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-xl font-bold">{t('settings')}</h2>
|
||||
<p className="text-muted-foreground">
|
||||
{t('settingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{settingsItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
className="flex items-center gap-3 p-4 rounded-lg border hover:border-primary/20 hover:bg-primary/5 cursor-pointer transition-colors"
|
||||
onClick={() => navigate(item.href)}
|
||||
>
|
||||
<Icon className="h-5 w-5 text-primary flex-shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="font-medium">{item.title}</div>
|
||||
<div className="text-sm text-muted-foreground">{item.description}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="p-4 space-y-8">
|
||||
{settingsCategories.map((category) => (
|
||||
<div key={category.id}>
|
||||
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-2">
|
||||
{category.title}
|
||||
</h3>
|
||||
<div className="overflow-hidden rounded-xl border border-border shadow-sm">
|
||||
{category.items.map((item, index) => (
|
||||
<SettingsItemMobile
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
onClick={() => navigate(item.href)}
|
||||
isFirst={index === 0}
|
||||
isLast={index === category.items.length - 1}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{import.meta.env.VERSION && (
|
||||
<div className="text-center text-xs text-muted-foreground/60 pt-4">
|
||||
v{import.meta.env.VERSION}
|
||||
@@ -47,4 +43,4 @@ export function Settings() {
|
||||
}
|
||||
}
|
||||
|
||||
export default Settings;
|
||||
export default Settings;
|
||||
@@ -15,7 +15,7 @@ describe('StorageSettings', () => {
|
||||
expect(screen.getByText('Storage')).toBeInTheDocument();
|
||||
|
||||
// Check for description
|
||||
expect(screen.getByText('Export files and manage local data.')).toBeInTheDocument();
|
||||
expect(screen.getByText('Export files and manage local data')).toBeInTheDocument();
|
||||
|
||||
// Check for Persist Data section
|
||||
expect(screen.getByText('Persist Data')).toBeInTheDocument();
|
||||
|
||||
@@ -288,7 +288,7 @@ export function StorageSettings() {
|
||||
{t('storageSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('dataSettingsDescriptionLong')}
|
||||
{t('storageSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -301,7 +301,7 @@ export function StorageSettings() {
|
||||
{t('storageSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('dataSettingsDescriptionLong')}
|
||||
{t('storageSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -308,7 +308,7 @@ export function SystemSettings() {
|
||||
<div className="space-y-3 max-w-xl">
|
||||
{/* Service Worker Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="service-worker" className="border rounded-lg">
|
||||
<AccordionItem value="service-worker">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<h4 className="text-sm font-medium">{t('serviceWorker')}</h4>
|
||||
</AccordionTrigger>
|
||||
@@ -411,7 +411,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Project Template Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="project-template" className="border rounded-lg">
|
||||
<AccordionItem value="project-template">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('projectTemplate')}</h4>
|
||||
@@ -459,7 +459,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* CORS Proxy Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="cors-proxy" className="border rounded-lg">
|
||||
<AccordionItem value="cors-proxy">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('corsProxy')}</h4>
|
||||
@@ -507,7 +507,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Favicon URL Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="favicon-url" className="border rounded-lg">
|
||||
<AccordionItem value="favicon-url">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('faviconUrl')}</h4>
|
||||
@@ -555,7 +555,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* JavaScript CDN Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="esm-url" className="border rounded-lg">
|
||||
<AccordionItem value="esm-url">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('esmUrl')}</h4>
|
||||
@@ -604,7 +604,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Preview Domain Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="preview-domain" className="border rounded-lg">
|
||||
<AccordionItem value="preview-domain">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('previewDomain')}</h4>
|
||||
@@ -652,7 +652,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Showcase Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="showcase" className="border rounded-lg">
|
||||
<AccordionItem value="showcase">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('showcase')}</h4>
|
||||
@@ -746,7 +746,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Sentry DSN Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="sentry-dsn" className="border rounded-lg">
|
||||
<AccordionItem value="sentry-dsn">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('sentryDsn')}</h4>
|
||||
@@ -794,7 +794,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Filesystem Paths Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="filesystem-paths" className="border rounded-lg">
|
||||
<AccordionItem value="filesystem-paths">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('filesystemPaths')}</h4>
|
||||
@@ -1016,7 +1016,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* System Prompt Configuration */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="system-prompt" className="border rounded-lg">
|
||||
<AccordionItem value="system-prompt">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('systemPrompt')}</h4>
|
||||
@@ -1063,7 +1063,7 @@ export function SystemSettings() {
|
||||
|
||||
{/* Terminal */}
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="terminal" className="border rounded-lg">
|
||||
<AccordionItem value="terminal">
|
||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-sm font-medium">{t('terminal')}</h4>
|
||||
|
||||
+2
-1
@@ -81,7 +81,8 @@ export default {
|
||||
borderRadius: {
|
||||
lg: 'var(--radius)',
|
||||
md: 'calc(var(--radius) - 2px)',
|
||||
sm: 'calc(var(--radius) - 4px)'
|
||||
sm: 'calc(var(--radius) - 4px)',
|
||||
xs: '2px'
|
||||
},
|
||||
keyframes: {
|
||||
'accordion-down': {
|
||||
|
||||
Reference in new issue
Block a user