Skip to content

Commit e4caae3

Browse files
shantanu patilclaude
authored andcommitted
fix: Explorer fetch failure (missing language param) + add Explore nav button
- Fix 422 error on /explore by adding required `language` query param to wiki_cache fetch - Add "Explore" button to wiki page toolbar for navigation to Visual Explorer - Integrate structured diagram data prompt into wiki page generation so new wikis produce explorable data - Preserve language/type params in back-navigation links Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f7951a commit e4caae3

4 files changed

Lines changed: 237 additions & 471 deletions

File tree

package-lock.json

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/[owner]/[repo]/explore/page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default function ExplorePage() {
5353
const owner = params.owner as string;
5454
const repo = params.repo as string;
5555
const repoType = (searchParams.get('type') || 'github') as 'github' | 'gitlab' | 'bitbucket';
56+
const language = searchParams.get('language') || 'en';
5657

5758
// State from URL or defaults
5859
const [selectedView, setSelectedView] = useState<ExplorerView>(
@@ -80,6 +81,7 @@ export default function ExplorePage() {
8081
owner,
8182
repo,
8283
repo_type: repoType,
84+
language,
8385
});
8486
const response = await fetch(`/api/wiki_cache?${cacheParams.toString()}`);
8587
if (!response.ok) {
@@ -114,7 +116,7 @@ export default function ExplorePage() {
114116
}
115117

116118
fetchWikiData();
117-
}, [owner, repo, repoType]);
119+
}, [owner, repo, repoType, language]);
118120

119121
// Merge all diagram data for the selected view into one DiagramData
120122
const mergedDiagram = useMemo<DiagramData | null>(() => {
@@ -176,8 +178,11 @@ export default function ExplorePage() {
176178
setSelectedDepth(depth);
177179
}, []);
178180

179-
// Build back link
180-
const backHref = `/${owner}/${repo}${searchParams.get('type') ? `?type=${repoType}` : ''}`;
181+
// Build back link (preserve type and language params)
182+
const backParams = new URLSearchParams();
183+
if (searchParams.get('type')) backParams.set('type', repoType);
184+
if (searchParams.get('language')) backParams.set('language', language);
185+
const backHref = `/${owner}/${repo}${backParams.toString() ? `?${backParams.toString()}` : ''}`;
181186

182187
// No diagram data state
183188
const hasNoDiagramData = !isLoading && !error && allDiagrams.length === 0;

src/app/[owner]/[repo]/page.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,24 @@ Based ONLY on the content of the \`[RELEVANT_SOURCE_FILES]\`:
641641
- Use autonumber directive to add sequence numbers to messages
642642
- NEVER use flowchart-style labels like A--|label|-->B. Always use a colon for labels: A->>B: My Label
643643
644+
* **Structured Diagram Data:** When you generate a Mermaid diagram, you MUST ALSO produce a structured JSON block IMMEDIATELY BEFORE the corresponding Mermaid code fence. Wrap the JSON in HTML comment markers exactly like this:
645+
\`\`\`
646+
<!-- DIAGRAM_DATA_START -->
647+
{
648+
"nodes": [
649+
{"id": "A", "label": "Frontend App", "technology": "React", "files": ["src/App.tsx"], "description": "Main SPA entry point", "depth": 0},
650+
{"id": "B", "label": "API Server", "technology": "Express", "files": ["server/index.js"], "description": "REST API backend", "depth": 0}
651+
],
652+
"edges": [
653+
{"source": "A", "target": "B", "label": "HTTP requests", "type": "api_call"}
654+
],
655+
"mermaidSource": "graph TD\\n A[Frontend App] --> B[API Server]",
656+
"diagramType": "flowchart"
657+
}
658+
<!-- DIAGRAM_DATA_END -->
659+
\`\`\`
660+
Rules: "nodes[].id" must match the Mermaid node IDs. "edges[].type" must be "dependency", "data_flow", or "api_call". "diagramType" must be "flowchart", "sequence", "class", or "er". "mermaidSource" must contain the exact Mermaid source. If a diagram has no meaningful structured metadata, you may omit the JSON block.
661+
644662
4. **Tables:**
645663
* Use Markdown tables to summarize information such as:
646664
* Key features or components and their descriptions.
@@ -2176,6 +2194,19 @@ IMPORTANT:
21762194
<span className="hidden sm:inline">Graph</span>
21772195
</button>
21782196
)}
2197+
{/* Visual Explorer button */}
2198+
{!isLoading && wikiStructure && (
2199+
<Link
2200+
href={`/${owner}/${repo}/explore${repoType !== 'github' ? `?type=${repoType}` : ''}${language !== 'en' ? `${repoType !== 'github' ? '&' : '?'}language=${language}` : ''}`}
2201+
className="inline-flex items-center gap-2 rounded-md border border-input bg-background px-3 py-1.5 text-sm text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground"
2202+
title="Interactive Visual Explorer"
2203+
>
2204+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
2205+
<path strokeLinecap="round" strokeLinejoin="round" d="M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z" />
2206+
</svg>
2207+
<span className="hidden sm:inline">Explore</span>
2208+
</Link>
2209+
)}
21792210
{/* Reading mode toggle button */}
21802211
{!isLoading && wikiStructure && (
21812212
<button

0 commit comments

Comments
 (0)