fix: use NODE_URL env var for code browser instead of repo.nodeUrl The tree page was extracting nodeUrl from the repo record (which is null for most repos) and showing "No refs found" when it was missing. Other pages (branches, compare) already use the NODE_URL env var with a localhost fallback. Now the tree page does the same.

Author: Aaron Steven White
Commit 20302e21a7a654c6d065676fe1c1e75a9a098c28
Parent: 126cba7924
Structural diff unavailable

These commits were pushed via plain git push, so no pre-parsed schemas are available. Install git-remote-cospan and re-push via panproto:// to see scope-level changes, breaking change detection, and semantic diffs.

brew install panproto/tap/git-remote-cospan
1 file changed +8 -22
@@ -1,10 +1,13 @@
11 import type { PageServerLoad } from './$types';
2+import { env } from '$env/dynamic/private';
23 import { getRepo } from '$lib/api/repo.js';
34 import { listRefs, getObject } from '$lib/api/node.js';
45 import { getFileSchema, type FileSchemaResponse } from '$lib/api/schema.js';
56 import { createHighlighter } from 'shiki';
67 import type { NodeRef, NodeObject } from '$lib/api/node.js';
78 
9+const DEFAULT_NODE_URL = env.NODE_URL ?? 'http://localhost:3002';
10+
811 // Map file extensions to Shiki language identifiers
912 const extensionToLang: Record<string, string> = {
1013 	ts: 'typescript',
@@ -116,13 +119,12 @@ export const load: PageServerLoad = async ({ params }): Promise<TreePageData> =>
116119 	const repo = await getRepo({ did: params.did, name: params.repo });
117120 	const path = params.path || '';
118121 
119-	// If we have a nodeUrl on the repo, use it to fetch real data.
120-	// For now, we try to list refs and show the tree.
121-	const nodeUrl = (repo as unknown as Record<string, unknown>).nodeUrl as string | undefined;
122+	const nodeUrl = (repo as unknown as Record<string, unknown>).nodeUrl as string | undefined
123+		?? DEFAULT_NODE_URL;
122124 
123125 	// If no path provided, show the refs tree
124126 	if (!path) {
125-		if (nodeUrl) {
127+		{
126128 			try {
127129 				const refList = await listRefs(nodeUrl, params.did, params.repo);
128130 				return {
@@ -141,18 +143,10 @@ export const load: PageServerLoad = async ({ params }): Promise<TreePageData> =>
141143 				};
142144 			}
143145 		}
144-
145-		// No nodeUrl; return empty ref list (placeholder mode)
146-		return {
147-			repo,
148-			path: '',
149-			mode: 'tree',
150-			refs: []
151-		};
152146 	}
153147 
154-	// Path provided: try to fetch the object if we have a nodeUrl
155-	if (nodeUrl) {
148+	// Path provided: try to fetch the object from the node.
149+	{
156150 		try {
157151 			const obj: NodeObject = await getObject(nodeUrl, params.did, params.repo, path);
158152 			const language = detectLanguage(path);
@@ -216,14 +210,6 @@ export const load: PageServerLoad = async ({ params }): Promise<TreePageData> =>
216210 		}
217211 	}
218212 
219-	// No nodeUrl: show placeholder tree with the path as context
220-	return {
221-		repo,
222-		path,
223-		mode: 'tree',
224-		refs: [],
225-		error: 'No node URL configured for this repository. Code browsing is unavailable.'
226-	};
227213 };
228214 
229215 function escapeHtml(text: string): string {
cospan · schematic version control on atproto built on AT Protocol