Compare commits

..
Author SHA1 Message Date
lemonknowsall 029f3f6c58 remove unused 2025-11-24 13:36:24 -08:00
lemonknowsall 1f685296de animate logo spin 2025-11-24 13:20:37 -08:00
lemonknowsall e0accea7ab chat input singleton 2025-11-24 12:55:59 -08:00
12 changed files with 157 additions and 463 deletions

No files matched your search

+11 -33
View File
@@ -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"
}
+25 -51
View File
@@ -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}
+10 -27
View File
@@ -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 () => {
+78 -185
View File
@@ -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>
);
-5
View File
@@ -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 */
-1
View File
@@ -281,7 +281,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.",
-1
View File
@@ -267,7 +267,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.",
-1
View File
@@ -267,7 +267,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",
-1
View File
@@ -277,7 +277,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.",
-1
View File
@@ -267,7 +267,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",
-1
View File
@@ -277,7 +277,6 @@
"noModelsFound": "未找到模型。",
"tryCustomModel": "尝试使用自定义模型。",
"recentlyUsed": "最近使用",
"availableModels": "可用模型",
"errorLoadingModels": "加载模型时出错",
"apiAuthenticationFailed": "API身份验证失败",
"invalidApiKey": "{{provider}}的API密钥无效。请在设置中检查您的API密钥。",
+33 -156
View File
@@ -4,8 +4,6 @@ import { useTranslation } from 'react-i18next';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useAIProjectId } from '@/hooks/useAIProjectId';
import { useFS } from '@/hooks/useFS';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useIsMobile } from '@/hooks/useIsMobile';
import { useAISettings } from '@/hooks/useAISettings';
import { useAppContext } from '@/hooks/useAppContext';
import { AppLayout } from '@/components/AppLayout';
@@ -16,11 +14,7 @@ import { Quilly } from '@/components/Quilly';
import { DotAI } from '@/lib/DotAI';
import type { AIMessage } from '@/lib/SessionManager';
import { buildMessageContent } from '@/lib/buildMessageContent';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { ModelSelector } from '@/components/ModelSelector';
import { FileAttachment } from '@/components/ui/file-attachment';
import { ArrowUp } from 'lucide-react';
import { ChatInput } from '@/components/Shakespeare/ChatInput';
import { useSeoMeta } from '@unhead/react';
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
import { AppShowcase } from '@/components/AppShowcase';
@@ -29,9 +23,7 @@ import { useToast } from '@/hooks/useToast';
export default function Index() {
const { t } = useTranslation();
const { toast } = useToast();
const [prompt, setPrompt] = useState('');
const [isCreating, setIsCreating] = useState(false);
const [storedPrompt, setStoredPrompt] = useLocalStorage('shakespeare-draft-prompt', '');
const [showOnboarding, setShowOnboarding] = useState(false);
const [showAct1Dialog, setShowAct1Dialog] = useState(false);
const [showGiftCardDialog, setShowGiftCardDialog] = useState(false);
@@ -48,10 +40,9 @@ export default function Index() {
// Initialize with first recently used model if available, otherwise empty
return settings.recentlyUsedModels?.[0] || '';
});
const isMobile = useIsMobile();
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
const [isDragOver, setIsDragOver] = useState(false);
const [quillyError, setQuillyError] = useState<Error | null>(null);
const [isModelSelectorOpen, setIsModelSelectorOpen] = useState(false);
// Check if any providers are configured
const hasProvidersConfigured = settings.providers.length > 0;
@@ -67,12 +58,6 @@ export default function Index() {
description: 'Build custom apps with AI assistance using Shakespeare, an AI-powered development environment.',
});
// Restore prompt from local storage on mount
useEffect(() => {
if (storedPrompt) {
setPrompt(storedPrompt);
}
}, [storedPrompt]);
// Check for Act 1 users and show welcome dialog
useEffect(() => {
@@ -106,21 +91,6 @@ export default function Index() {
}
}, [location, navigate]);
// Sync prompt with local storage
const handlePromptChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const newPrompt = e.target.value;
setPrompt(newPrompt);
setStoredPrompt(newPrompt);
};
const handleFileSelect = (file: File) => {
setAttachedFiles(prev => [...prev, file]);
};
const handleFileRemove = (fileToRemove: File) => {
setAttachedFiles(prev => prev.filter(file => file !== fileToRemove));
};
// Drag and drop handlers
const handleDragEnter = (e: React.DragEvent) => {
e.preventDefault();
@@ -154,41 +124,10 @@ export default function Index() {
e.preventDefault();
e.stopPropagation();
setIsDragOver(false);
if (isCreating || isGeneratingId || !providerModel.trim()) return;
const files = Array.from(e.dataTransfer.files);
if (files.length === 0) return;
// Add all files without validation
setAttachedFiles(prev => [...prev, ...files]);
};
// Handle keyboard shortcuts (physical keyboards only)
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter') {
// On mobile devices, always allow Enter to create new lines
// since there's no Shift key available for multi-line input
if (isMobile) {
return;
}
if (e.shiftKey) {
// Shift+Enter on desktop: Allow new line (default behavior)
return;
}
// Enter without Shift on desktop: Submit only if no newlines exist in prompt and model is selected
if (!prompt.includes('\n') && providerModel.trim()) {
e.preventDefault();
handleCreateProject();
}
// If prompt contains newlines or no model selected, allow Enter to create new line (default behavior)
}
};
// Handle textarea click - show onboarding if no providers configured
const handleTextareaClick = () => {
// Handle textarea focus - show onboarding if no providers configured
const handleTextareaFocus = () => {
if (!hasProvidersConfigured) {
setShowOnboarding(true);
}
@@ -200,10 +139,7 @@ export default function Index() {
};
const handleQuillyNewChat = () => {
// Clear current prompt and start fresh
setPrompt('');
setStoredPrompt('');
setAttachedFiles([]);
// Clear error - ChatInput manages its own state
setQuillyError(null);
};
@@ -215,23 +151,21 @@ export default function Index() {
setQuillyError(null);
};
const handleCreateProject = async () => {
if (!prompt.trim() || !providerModel.trim()) return;
// Clear stored prompt when creating project
setStoredPrompt('');
const handleSend = async (input: string, files: File[]) => {
if (!input.trim() && files.length === 0) return;
if (!providerModel.trim()) return;
setIsCreating(true);
try {
// Use AI to generate project ID
const projectId = await generateProjectId(providerModel, prompt.trim());
const projectId = await generateProjectId(providerModel, input.trim());
// Add model to recently used when creating project with AI
addRecentlyUsedModel(providerModel.trim());
// Create project with AI-generated ID and handle template update errors
const project = await projectsManager.createProject(
prompt.trim(),
input.trim(),
config.projectTemplate,
projectId,
() => {
@@ -247,8 +181,8 @@ export default function Index() {
// Build message content from input and attached files
// Images are converted to base64-encoded data URLs
const messageContent = await buildMessageContent(
prompt.trim(),
attachedFiles,
input.trim(),
files,
fs,
undefined
);
@@ -263,9 +197,6 @@ export default function Index() {
};
await dotAI.setHistory(sessionName, [initialMessage]);
// Clear attached files after successful creation
setAttachedFiles([]);
// Navigate to the project with autostart parameter and model
const searchParams = new URLSearchParams({
autostart: 'true',
@@ -289,7 +220,7 @@ export default function Index() {
<div className="max-w-4xl mx-auto">
<div className="text-center mb-8 md:mb-12">
<div className="mb-4 md:mb-6">
<ShakespeareLogo className="w-20 h-20 md:w-24 md:h-24 mx-auto" />
<ShakespeareLogo className={`w-20 h-20 md:w-24 md:h-24 mx-auto transition-transform duration-300 ${isCreating || isGeneratingId ? 'animate-spin' : ''}`} />
</div>
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
{t('buildNostrApps')}
@@ -313,84 +244,30 @@ export default function Index() {
</div>
)}
{/* Chat Input Container - matching the ChatPane style */}
<div
className={`relative rounded-2xl border border-input bg-background shadow-sm focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 transition-all ${isDragOver ? 'border-primary bg-primary/5 ring-2 ring-primary/20' : ''
}`}
{/* Chat Input */}
<ChatInput
isLoading={isCreating || isGeneratingId}
isConfigured={hasProvidersConfigured}
providerModel={providerModel}
onProviderModelChange={setProviderModel}
onSend={handleSend}
onStop={() => {
// No-op for Index page - project creation can't be stopped
}}
onFocus={handleTextareaFocus}
onFirstInteraction={() => {
// No-op for Index page
}}
isModelSelectorOpen={isModelSelectorOpen}
onModelSelectorOpenChange={setIsModelSelectorOpen}
contextUsagePercentage={0}
totalCost={0}
isDragOver={isDragOver}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
>
<Textarea
placeholder={
!hasProvidersConfigured
? t('examplePrompt')
: !providerModel.trim()
? t('selectModelToDescribe')
: t('examplePrompt')
}
value={prompt}
onChange={handlePromptChange}
onKeyDown={handleKeyDown}
onClick={handleTextareaClick}
className="min-h-[120px] max-h-64 resize-none border-0 bg-transparent px-4 py-3 pb-16 text-sm focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground"
disabled={isCreating || isGeneratingId || (hasProvidersConfigured && !providerModel.trim())}
rows={4}
style={{
height: 'auto',
minHeight: '120px'
}}
onInput={(e) => {
const target = e.target as HTMLTextAreaElement;
target.style.height = 'auto';
target.style.height = Math.min(target.scrollHeight, 256) + 'px';
}}
/>
{/* Bottom Controls Row */}
<div className="absolute bottom-3 left-3 right-3 flex items-center justify-end gap-4 overflow-hidden">
{/* File Attachment */}
<FileAttachment
className="mr-auto"
onFileSelect={handleFileSelect}
onFileRemove={handleFileRemove}
selectedFiles={attachedFiles}
disabled={isCreating || isGeneratingId}
multiple={true}
/>
{/* Model Selector - always show to allow configuration */}
<div className="overflow-hidden">
<ModelSelector
value={providerModel}
onChange={setProviderModel}
className="w-full"
disabled={isCreating || isGeneratingId}
placeholder={t('chooseModel')}
/>
</div>
{/* Create Project Button */}
<Button
onClick={handleCreateProject}
disabled={
!prompt.trim() ||
isCreating ||
isGeneratingId ||
(hasProvidersConfigured && !providerModel.trim())
}
size="sm"
className="size-8 [&_svg]:size-5 rounded-full p-0"
>
{isCreating || isGeneratingId ? (
<div className="animate-spin rounded-full h-3 w-3 border-b-2 border-white" />
) : (
<ArrowUp />
)}
</Button>
</div>
</div>
/>
</div>
</div>