fix(codebase): remove legacy single-codebase hint description from api endpoints

This commit is contained in:
2026-06-14 13:20:49 -07:00
parent adc60690c8
commit d738842069
3 changed files with 135 additions and 87 deletions

View File

@@ -48,95 +48,124 @@ export default function CodeTab() {
const showLoading = loading && !anatomy;
return (
<div style={{ minHeight: "100vh", background: THEME.canvasGradient, fontFamily: THEME.font, padding: "36px 48px" }}>
<div
style={{
minHeight: "100vh",
background: THEME.canvasGradient,
fontFamily: THEME.font,
padding: "36px 48px",
}}
>
<div style={{ maxWidth: 1400, margin: "0 auto" }}>
<PageHeader title="Codebase" subtitle="Explore the repository files for your application." />
<div style={grid}>
{/* ── Left rail ── */}
<section style={leftCol}>
{showLoading && (
<PageHeader
title="Codebase"
subtitle="Explore the repository files for your application."
/>
<div style={grid}>
{/* ── Left rail ── */}
<section style={leftCol}>
{showLoading && (
<Card>
<div style={{ display: "flex", alignItems: "center", gap: 8, color: THEME.mid, fontSize: "0.875rem" }}>
<div
style={{
display: "flex",
alignItems: "center",
gap: 8,
color: THEME.mid,
fontSize: "0.875rem",
}}
>
<Loader2 size={15} className="animate-spin" /> Loading
</div>
</Card>
)}
{error && !showLoading && (
{error && !showLoading && (
<Card>
<div style={{ display: "flex", alignItems: "center", gap: 8, color: THEME.danger, fontSize: "0.875rem" }}>
<div
style={{
display: "flex",
alignItems: "center",
gap: 8,
color: THEME.danger,
fontSize: "0.875rem",
}}
>
<AlertCircle size={15} /> {error}
</div>
</Card>
)}
{anatomy && (
<>
{/* Code Files */}
<RailGroup title="Code files" count={codebases?.length ?? 0}>
{codebases && codebases.length === 0 && (
<RailEmpty>
{reason === "no_repo" ? (
<>
No codebase yet.{" "}
<span style={nudge}>
Try: &quot;Start building my app&quot;
</span>
</>
) : (
<>
Repo is empty push a first commit.{" "}
<span style={nudge}>
Try: &quot;Scaffold a Next.js app&quot;
</span>
</>
)}
</RailEmpty>
)}
{codebases?.map((cb) => {
return (
<article key={cb.id} style={codebaseTile}>
<div style={tileHeader}>
<span style={chevronCell}>
<ChevronDown size={13} style={{ color: THEME.mid }} />
</span>
<Box
size={13}
style={{ color: THEME.mid, flexShrink: 0 }}
/>
<div style={{ minWidth: 0, textAlign: "left" }}>
<div style={tileLabel}>{cb.label}</div>
{cb.hint && <div style={tileHint}>{cb.hint}</div>}
{anatomy && (
<>
{/* Code Files */}
<RailGroup title="Code files" count={codebases?.length ?? 0}>
{codebases && codebases.length === 0 && (
<RailEmpty>
{reason === "no_repo" ? (
<>
No codebase yet.{" "}
<span style={nudge}>
Try: &quot;Start building my app&quot;
</span>
</>
) : (
<>
Repo is empty push a first commit.{" "}
<span style={nudge}>
Try: &quot;Scaffold a Next.js app&quot;
</span>
</>
)}
</RailEmpty>
)}
{codebases?.map((cb) => {
return (
<article key={cb.id} style={codebaseTile}>
<div style={tileHeader}>
<span style={chevronCell}>
<ChevronDown
size={13}
style={{ color: THEME.mid }}
/>
</span>
<Box
size={13}
style={{ color: THEME.mid, flexShrink: 0 }}
/>
<div style={{ minWidth: 0, textAlign: "left" }}>
<div style={tileLabel}>{cb.label}</div>
{cb.hint && <div style={tileHint}>{cb.hint}</div>}
</div>
</div>
</div>
<div style={tileBody}>
<GiteaFileTree
projectId={projectId}
rootPath={cb.path}
selectedPath={
selection?.type === "file" &&
selection.codebaseId === cb.id
? selection.path
: undefined
}
onSelectFile={(p) =>
setSelection({
type: "file",
codebaseId: cb.id,
path: p,
})
}
/>
</div>
</article>
);
})}
</RailGroup>
</>
)}
</section>
<div style={tileBody}>
<GiteaFileTree
projectId={projectId}
rootPath={cb.path}
selectedPath={
selection?.type === "file" &&
selection.codebaseId === cb.id
? selection.path
: undefined
}
onSelectFile={(p) =>
setSelection({
type: "file",
codebaseId: cb.id,
path: p,
})
}
/>
</div>
</article>
);
})}
</RailGroup>
</>
)}
</section>
{/* ── Right pane ── */}
<aside style={rightCol}>
{/* ── Right pane ── */}
<aside style={rightCol}>
<Card
padding={0}
style={{
@@ -150,13 +179,24 @@ export default function CodeTab() {
<GiteaFileViewer projectId={projectId} path={selection.path} />
)}
{!selection && (
<div style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center", color: THEME.muted, fontSize: "0.85rem", padding: "32px 16px", textAlign: "center" }}>
<div
style={{
flex: 1,
display: "flex",
alignItems: "center",
justifyContent: "center",
color: THEME.muted,
fontSize: "0.85rem",
padding: "32px 16px",
textAlign: "center",
}}
>
Pick a codebase file on the left.
</div>
)}
</Card>
</aside>
</div>
</div>
</div>
</div>
);

View File

@@ -254,7 +254,7 @@ async function discoverCodebases(giteaRepo: string): Promise<{
id: "root",
label: repoName,
path: "",
hint: "Single-codebase project — repository root.",
hint: "",
},
];
}

View File

@@ -35,14 +35,17 @@ interface GiteaItem {
type: "file" | "dir" | "symlink";
}
async function giteaList(repo: string, path: string): Promise<GiteaItem[] | null> {
async function giteaList(
repo: string,
path: string,
): Promise<GiteaItem[] | null> {
const encoded = path ? encodeURIComponent(path).replace(/%2F/g, "/") : "";
const res = await fetch(
`${GITEA_API_URL}/api/v1/repos/${repo}/contents/${encoded}`,
{
headers: { Authorization: `token ${GITEA_API_TOKEN}` },
next: { revalidate: 30 },
}
},
);
if (res.status === 404) return null;
if (!res.ok) throw new Error(`Gitea ${res.status} listing ${repo}/${path}`);
@@ -52,7 +55,7 @@ async function giteaList(repo: string, path: string): Promise<GiteaItem[] | null
export async function GET(
_req: Request,
{ params }: { params: Promise<{ projectId: string }> }
{ params }: { params: Promise<{ projectId: string }> },
) {
try {
const { projectId } = await params;
@@ -65,7 +68,7 @@ export async function GET(
`SELECT p.data FROM fs_projects p
JOIN fs_users u ON u.id = p.user_id
WHERE p.id = $1 AND u.data->>'email' = $2 LIMIT 1`,
[projectId, session.user.email]
[projectId, session.user.email],
);
if (rows.length === 0) {
return NextResponse.json({ error: "Project not found" }, { status: 404 });
@@ -89,15 +92,17 @@ export async function GET(
});
}
const appsDir = root.find(item => item.type === "dir" && item.name === "apps");
const appsDir = root.find(
(item) => item.type === "dir" && item.name === "apps",
);
let codebases: Codebase[] = [];
if (appsDir) {
const appsChildren = await giteaList(giteaRepo, "apps");
if (appsChildren) {
codebases = appsChildren
.filter(item => item.type === "dir")
.map(item => ({
.filter((item) => item.type === "dir")
.map((item) => ({
id: item.name,
label: item.name,
path: `apps/${item.name}`,
@@ -114,7 +119,7 @@ export async function GET(
id: "root",
label: repoName,
path: "",
hint: "Single-codebase project — repository root.",
hint: "",
},
];
}
@@ -122,6 +127,9 @@ export async function GET(
return NextResponse.json({ codebases });
} catch (err) {
console.error("[codebases API]", err);
return NextResponse.json({ error: "Failed to list codebases" }, { status: 500 });
return NextResponse.json(
{ error: "Failed to list codebases" },
{ status: 500 },
);
}
}