Skip to content

Commit d3d3f30

Browse files
committed
fix(api): return full command/mcp data and persist theme setting
1 parent b2259ae commit d3d3f30

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

bin/serve.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,16 @@ def handle_delete_skill(self, data):
425425
self.send_json({'success': False, 'error': str(e)})
426426

427427
# Commands handlers
428+
def _parse_frontmatter(self, content):
429+
"""解析 frontmatter 中的 description"""
430+
import re
431+
match = re.match(r'^---\s*\n([\s\S]*?)\n---', content)
432+
if match:
433+
for line in match.group(1).split('\n'):
434+
if line.startswith('description:'):
435+
return line[12:].strip()
436+
return None
437+
428438
def handle_list_commands(self):
429439
commands_dir = os.path.join(FACTORY_DIR, 'commands')
430440
commands = []
@@ -434,7 +444,15 @@ def handle_list_commands(self):
434444
if entry.endswith('.md'):
435445
full_path = os.path.join(real_dir, entry)
436446
if os.path.isfile(full_path):
437-
commands.append({'name': entry[:-3], 'path': full_path})
447+
with open(full_path, 'r', encoding='utf-8') as f:
448+
content = f.read()
449+
desc = self._parse_frontmatter(content)
450+
commands.append({
451+
'name': entry[:-3],
452+
'path': full_path,
453+
'description': desc,
454+
'content': content
455+
})
438456
except:
439457
pass
440458
self.send_json(commands)
@@ -546,12 +564,8 @@ def handle_list_mcp(self):
546564
config = json.load(f)
547565
if 'mcpServers' in config:
548566
for name, server in config['mcpServers'].items():
549-
servers.append({
550-
'name': name,
551-
'command': server.get('command', ''),
552-
'args': server.get('args', []),
553-
'env': server.get('env', {})
554-
})
567+
item = {'name': name, **server}
568+
servers.append(item)
555569
except:
556570
pass
557571
self.send_json(servers)

web/src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ const tabs: { id: Tab; label: string; icon: typeof Key }[] = [
2121
export default function App() {
2222
const [activeTab, setActiveTab] = useState<Tab>('keys');
2323
const [mounted, setMounted] = useState(false);
24-
const [theme, setTheme] = useState<'light' | 'dark'>('light');
24+
const [theme, setTheme] = useState<'light' | 'dark'>(() => {
25+
if (typeof window !== 'undefined') {
26+
return (localStorage.getItem('oroio-theme') as 'light' | 'dark') || 'light';
27+
}
28+
return 'light';
29+
});
2530
const [fakePid] = useState(() => Math.floor(Math.random() * 9000) + 1000);
2631
const [fakeMemory] = useState(() => Math.floor(Math.random() * 50) + 20);
2732

@@ -44,6 +49,7 @@ export default function App() {
4449
}, []);
4550

4651
useEffect(() => {
52+
localStorage.setItem('oroio-theme', theme);
4753
if (theme === 'dark') {
4854
document.documentElement.classList.add('dark');
4955
} else {

0 commit comments

Comments
 (0)