Skip to content

Commit

Permalink
feat: add shinkai desktop version in settings (#335)
Browse files Browse the repository at this point in the history
* fix: eslint

* add shinkai desktop version
  • Loading branch information
paulclindo authored Jun 14, 2024
1 parent 9116657 commit 514d83c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 27 deletions.
60 changes: 49 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"root": true,
"extends": ["eslint:recommended", "plugin:react/recommended"],
"ignorePatterns": ["**/*"],
"plugins": ["@nx", "simple-import-sort"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"ignorePatterns": [
"**/*"
],
"plugins": [
"@nx",
"simple-import-sort"
],
"rules": {
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
Expand All @@ -13,7 +22,12 @@
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
Expand All @@ -23,27 +37,51 @@
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
"onlyDependOnLibsWithTags": [
"*"
]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"files": [
"*.ts",
"*.tsx"
],
"extends": [
"plugin:@nx/typescript"
],
"rules": {
"react/no-unknown-property": ["error", { "ignore": ["cmdk-input-wrapper"] }]
"react/no-unknown-property": [
"error",
{
"ignore": [
"cmdk-input-wrapper"
]
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"files": [
"*.js",
"*.jsx"
],
"extends": [
"plugin:@nx/javascript"
],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"files": [
"*.spec.ts",
"*.spec.tsx",
"*.spec.js",
"*.spec.jsx"
],
"env": {
"jest": true
},
Expand Down
14 changes: 7 additions & 7 deletions apps/shinkai-desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ initSyncStorage();

function App() {
return (
<AnalyticsProvider>
<QueryProvider>
<ErrorBoundary FallbackComponent={FullPageErrorFallback}>
<ErrorBoundary FallbackComponent={FullPageErrorFallback}>
<AnalyticsProvider>
<QueryProvider>
<Router>
<AppRoutes />
</Router>
</ErrorBoundary>
<Toaster />
</QueryProvider>
</AnalyticsProvider>
<Toaster />
</QueryProvider>
</AnalyticsProvider>
</ErrorBoundary>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ export const OllamaModels = () => {
installedOllamaModels.models.forEach((modelResponse) => {
installedOllamaModelsMap.set(modelResponse.name, modelResponse);
});
}, [installedOllamaModels]);
}, [installedOllamaModels?.models, installedOllamaModelsMap]);

const modelList = useMemo(() => {
return OLLAMA_MODELS.sort((model) =>
installedOllamaModelsMap.has(model.fullName) ? -1 : 1,
);
}, [installedOllamaModelsMap]);

if (!isShinkaiNodeRunning) {
return (
Expand All @@ -143,12 +149,6 @@ export const OllamaModels = () => {
);
}

const modelList = useMemo(() => {
return OLLAMA_MODELS.sort((model) =>
installedOllamaModelsMap.has(model.fullName) ? -1 : 1,
);
}, [installedOllamaModelsMap]);

return (
<ScrollArea className="h-full flex-1 rounded-md">
<Table className="w-full border-collapse text-[13px]">
Expand Down
19 changes: 17 additions & 2 deletions apps/shinkai-desktop/src/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import {
} from '@shinkai_network/shinkai-ui';
import { ExportIcon, QrIcon } from '@shinkai_network/shinkai-ui/assets';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { getVersion } from '@tauri-apps/api/app';
import { motion } from 'framer-motion';
import { BarChart2, CodesandboxIcon, ExternalLinkIcon } from 'lucide-react';
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';
Expand Down Expand Up @@ -74,6 +75,8 @@ const SettingsPage = () => {
node_address: auth?.node_address ?? '',
});

const [appVersion, setAppVersion] = useState('');

const form = useForm<FormSchemaType>({
resolver: zodResolver(formSchema),
defaultValues: {
Expand All @@ -89,6 +92,12 @@ const SettingsPage = () => {
name: 'defaultAgentId',
});

useEffect(() => {
(async () => {
setAppVersion(await getVersion());
})();
}, []);

const { agents } = useAgents({
nodeAddress: auth?.node_address ?? '',
sender: auth?.shinkai_identity ?? '',
Expand Down Expand Up @@ -277,7 +286,7 @@ const SettingsPage = () => {
Save
</MotionButton>
<Button
className="min-w-10 h-10 rounded-lg text-sm"
className="h-10 min-w-10 rounded-lg text-sm"
onClick={() => {
form.setValue(
'shinkaiIdentity',
Expand Down Expand Up @@ -378,6 +387,12 @@ const SettingsPage = () => {
<p className="text-smm text-white">Galxe Validation</p>
</Button>
</div>
<div>
<p className="text-gray-80 text-right text-xs">
Shinkai Desktop Version:{' '}
<span className="font-bold">{appVersion}</span>
</p>
</div>
</div>
</SimpleLayout>
);
Expand Down

0 comments on commit 514d83c

Please sign in to comment.