Skip to content

Commit ec57574

Browse files
Yang YiHeleonai-agent
authored andcommitted
fix: hub download 404, installed skills UI, and navigation
- Fix marketplace_client.py default HUB_URL port 8080 → 8090 - Add Installed tab in MarketplacePage with sub-tabs (成员/Skill/Agent) - Add LibraryItemDetailPage for full-page skill/agent detail view - Remove tab UI from MarketplaceDetailPage, show content flat - Persist tab state in URL search params to survive back-navigation - Fix all back buttons to use navigate(-1) instead of hardcoded routes
1 parent 70dbd8a commit ec57574

6 files changed

Lines changed: 312 additions & 123 deletions

File tree

‎backend/web/services/marketplace_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
logger = logging.getLogger(__name__)
1717

18-
HUB_URL = os.environ.get("MYCEL_HUB_URL", "http://localhost:8080")
18+
HUB_URL = os.environ.get("MYCEL_HUB_URL", "http://localhost:8090")
1919

2020
_hub_client = httpx.Client(timeout=30.0)
2121

‎frontend/app/src/pages/AgentDetailPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export default function AgentDetail() {
196196
<div className="h-full flex flex-col">
197197
{/* Header */}
198198
<div className="flex items-center gap-3 px-4 py-3 border-b shrink-0">
199-
<Button variant="ghost" size="icon" onClick={() => navigate("/members")}>
199+
<Button variant="ghost" size="icon" onClick={() => navigate(-1)}>
200200
<ArrowLeft className="h-4 w-4" />
201201
</Button>
202202
<Bot className="h-5 w-5 text-primary" />
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { useEffect, useState } from "react";
2+
import { useParams, useNavigate } from "react-router-dom";
3+
import { ArrowLeft, Zap, Users, RefreshCw } from "lucide-react";
4+
import { useAppStore } from "@/store/app-store";
5+
import type { ResourceItem } from "@/store/types";
6+
7+
export default function LibraryItemDetailPage() {
8+
const { type, id } = useParams<{ type: string; id: string }>();
9+
const navigate = useNavigate();
10+
const librarySkills = useAppStore((s) => s.librarySkills);
11+
const libraryAgents = useAppStore((s) => s.libraryAgents);
12+
const fetchLibrary = useAppStore((s) => s.fetchLibrary);
13+
const fetchResourceContent = useAppStore((s) => s.fetchResourceContent);
14+
15+
const [item, setItem] = useState<ResourceItem | null>(null);
16+
const [content, setContent] = useState("");
17+
const [loading, setLoading] = useState(true);
18+
19+
useEffect(() => {
20+
if (!type || !id) return;
21+
fetchLibrary(type === "skill" ? "skill" : "agent");
22+
}, [type, id, fetchLibrary]);
23+
24+
useEffect(() => {
25+
if (!type || !id) return;
26+
const list = type === "skill" ? librarySkills : libraryAgents;
27+
const found = list.find((i) => i.id === id);
28+
if (found) setItem(found);
29+
}, [librarySkills, libraryAgents, type, id]);
30+
31+
useEffect(() => {
32+
if (!type || !id) return;
33+
setLoading(true);
34+
fetchResourceContent(type, id)
35+
.then(setContent)
36+
.finally(() => setLoading(false));
37+
}, [type, id, fetchResourceContent]);
38+
39+
const isSkill = type === "skill";
40+
const filename = isSkill ? "SKILL.md" : "agent.md";
41+
42+
if (!item && !loading) {
43+
return (
44+
<div className="flex items-center justify-center h-full">
45+
<span className="text-sm text-muted-foreground">未找到该内容</span>
46+
</div>
47+
);
48+
}
49+
50+
return (
51+
<div className="h-full overflow-y-auto">
52+
<div className="max-w-3xl mx-auto py-6 px-4 md:px-6">
53+
{/* Back */}
54+
<button
55+
onClick={() => navigate(-1)}
56+
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors duration-fast mb-6"
57+
>
58+
<ArrowLeft className="w-3.5 h-3.5" />
59+
返回
60+
</button>
61+
62+
{/* Header */}
63+
<div className="flex items-start gap-4 mb-6">
64+
<div className="flex-1 min-w-0">
65+
<div className="flex items-center gap-2 mb-1">
66+
<div className="w-8 h-8 rounded-lg flex items-center justify-center shrink-0 bg-warning/10">
67+
{isSkill
68+
? <Zap className="w-4 h-4 text-warning" />
69+
: <Users className="w-4 h-4 text-info" />}
70+
</div>
71+
<h1 className="text-xl font-semibold text-foreground">{item?.name ?? id}</h1>
72+
<span className="text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground font-medium">
73+
{type}
74+
</span>
75+
</div>
76+
{item?.desc && (
77+
<p className="text-sm text-muted-foreground mt-2">{item.desc}</p>
78+
)}
79+
</div>
80+
</div>
81+
82+
{/* File content */}
83+
<div className="surface-card p-4">
84+
<div className="flex items-center gap-2 mb-3">
85+
<span className="text-xs font-mono text-muted-foreground px-2 py-0.5 rounded bg-muted">
86+
{filename}
87+
</span>
88+
</div>
89+
{loading ? (
90+
<div className="flex items-center justify-center py-8">
91+
<RefreshCw className="w-4 h-4 animate-spin text-muted-foreground" />
92+
</div>
93+
) : content ? (
94+
<pre className="text-xs text-foreground whitespace-pre-wrap font-mono leading-relaxed max-h-[600px] overflow-y-auto">
95+
{content}
96+
</pre>
97+
) : (
98+
<p className="text-sm text-muted-foreground text-center py-6">暂无内容</p>
99+
)}
100+
</div>
101+
</div>
102+
</div>
103+
);
104+
}

‎frontend/app/src/pages/MarketplaceDetailPage.tsx‎

Lines changed: 34 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export default function MarketplaceDetailPage() {
2222
const fetchVersionSnapshot = useMarketplaceStore((s) => s.fetchVersionSnapshot);
2323
const clearSnapshot = useMarketplaceStore((s) => s.clearSnapshot);
2424
const [installOpen, setInstallOpen] = useState(false);
25-
const [activeTab, setActiveTab] = useState<"overview" | "versions" | "files">("overview");
26-
const tabLabels: Record<string, string> = { overview: "概览", versions: "版本", files: "文件" };
2725

2826
useEffect(() => {
2927
if (id) {
@@ -34,11 +32,11 @@ export default function MarketplaceDetailPage() {
3432
}, [id, fetchDetail, fetchLineage, clearDetail]);
3533

3634
useEffect(() => {
37-
if (activeTab === "files" && detail && detail.versions.length > 0) {
35+
if (detail && detail.versions.length > 0 && (detail.type === "skill" || detail.type === "agent")) {
3836
fetchVersionSnapshot(detail.id, detail.versions[0].version);
3937
}
4038
return () => clearSnapshot();
41-
}, [activeTab, detail?.id, fetchVersionSnapshot, clearSnapshot]);
39+
}, [detail?.id, detail?.type, fetchVersionSnapshot, clearSnapshot]);
4240

4341
if (detailLoading) {
4442
return (
@@ -68,11 +66,11 @@ export default function MarketplaceDetailPage() {
6866
<div className="max-w-3xl mx-auto py-6 px-4 md:px-6">
6967
{/* Back button */}
7068
<button
71-
onClick={() => navigate("/marketplace")}
69+
onClick={() => navigate(-1)}
7270
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors duration-fast mb-6"
7371
>
7472
<ArrowLeft className="w-3.5 h-3.5" />
75-
返回 Marketplace
73+
返回
7674
</button>
7775

7876
{/* Header */}
@@ -108,89 +106,40 @@ export default function MarketplaceDetailPage() {
108106
</div>
109107
)}
110108

111-
{/* Tabs */}
112-
<div className="flex gap-4 border-b border-border mb-6">
113-
{(["overview", "versions", ...(detail.type === "skill" || detail.type === "agent" ? ["files" as const] : [])] as const).map((tab) => (
114-
<button
115-
key={tab}
116-
onClick={() => setActiveTab(tab)}
117-
className={`pb-2 text-sm font-medium transition-colors duration-fast border-b-2 ${
118-
activeTab === tab ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"
119-
}`}
120-
>
121-
{tabLabels[tab] ?? tab}
122-
</button>
123-
))}
124-
</div>
125-
126-
{/* Tab content */}
127-
{activeTab === "overview" && (
128-
<div className="space-y-6">
129-
{/* Lineage */}
130-
<LineageTree
131-
ancestors={lineage.ancestors}
132-
children={lineage.children}
133-
currentName={detail.name}
134-
onNodeClick={(nodeId) => navigate(`/marketplace/${nodeId}`)}
135-
/>
136-
137-
{/* Latest version info */}
138-
{detail.versions.length > 0 && (
139-
<div className="surface-card p-4 space-y-2">
140-
<h3 className="text-sm font-medium text-foreground">最新版本</h3>
141-
<p className="text-xs font-mono text-primary">v{detail.versions[0].version}</p>
142-
{detail.versions[0].release_notes && (
143-
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{detail.versions[0].release_notes}</p>
144-
)}
145-
</div>
146-
)}
147-
</div>
148-
)}
109+
<div className="space-y-6">
110+
{/* Lineage */}
111+
<LineageTree
112+
ancestors={lineage.ancestors}
113+
children={lineage.children}
114+
currentName={detail.name}
115+
onNodeClick={(nodeId) => navigate(`/marketplace/${nodeId}`)}
116+
/>
149117

150-
{activeTab === "versions" && (
151-
<div className="space-y-3">
152-
{detail.versions.map((v) => (
153-
<div key={v.id} className="surface-card p-4">
154-
<div className="flex items-center justify-between mb-1">
155-
<span className="text-sm font-mono font-medium text-foreground">v{v.version}</span>
156-
<span className="text-2xs text-muted-foreground">{new Date(v.created_at).toLocaleDateString()}</span>
118+
{/* Version history */}
119+
{detail.versions.length > 0 && (
120+
<div className="space-y-2">
121+
<h3 className="text-sm font-medium text-foreground">版本历史</h3>
122+
{detail.versions.map((v) => (
123+
<div key={v.id} className="surface-card p-4">
124+
<div className="flex items-center justify-between mb-1">
125+
<span className="text-sm font-mono font-medium text-primary">v{v.version}</span>
126+
<span className="text-2xs text-muted-foreground">{new Date(v.created_at).toLocaleDateString()}</span>
127+
</div>
128+
{v.release_notes && (
129+
<p className="text-xs text-muted-foreground whitespace-pre-wrap">{v.release_notes}</p>
130+
)}
157131
</div>
158-
{v.release_notes && (
159-
<p className="text-xs text-muted-foreground whitespace-pre-wrap">{v.release_notes}</p>
160-
)}
161-
</div>
162-
))}
163-
{detail.versions.length === 0 && (
164-
<p className="text-sm text-muted-foreground text-center py-8">暂无已发布的版本</p>
165-
)}
166-
</div>
167-
)}
168-
169-
{activeTab === "files" && (
170-
<div className="space-y-4">
171-
{/* File tree */}
172-
<div className="surface-card p-4">
173-
<h3 className="text-sm font-medium text-foreground mb-3">文件结构</h3>
174-
<div className="font-mono text-xs text-muted-foreground space-y-1">
175-
<div className="flex items-center gap-2 text-foreground font-medium">
176-
<span>📁</span>
177-
<span>{detail.slug}/</span>
178-
</div>
179-
<div className="flex items-center gap-2 ml-5">
180-
<span>📄</span>
181-
<span className="text-primary">SKILL.md</span>
182-
</div>
183-
<div className="flex items-center gap-2 ml-5">
184-
<span>📄</span>
185-
<span>meta.json</span>
186-
</div>
187-
</div>
132+
))}
188133
</div>
134+
)}
189135

190-
{/* SKILL.md preview */}
136+
{/* File content for skill / agent */}
137+
{(detail.type === "skill" || detail.type === "agent") && (
191138
<div className="surface-card p-4">
192139
<div className="flex items-center gap-2 mb-3">
193-
<span className="text-xs font-mono text-muted-foreground px-2 py-0.5 rounded bg-muted">SKILL.md</span>
140+
<span className="text-xs font-mono text-muted-foreground px-2 py-0.5 rounded bg-muted">
141+
{detail.type === "skill" ? "SKILL.md" : "agent.md"}
142+
</span>
194143
</div>
195144
{snapshotLoading ? (
196145
<div className="flex items-center justify-center py-8">
@@ -204,8 +153,8 @@ export default function MarketplaceDetailPage() {
204153
<p className="text-sm text-muted-foreground text-center py-6">暂无内容</p>
205154
)}
206155
</div>
207-
</div>
208-
)}
156+
)}
157+
</div>
209158
</div>
210159

211160
{/* Install dialog */}

0 commit comments

Comments
 (0)