refactor(web): use Repository.head to find default branch

Quentin Gliech and Claude Opus 4.6 (1M context) created

Replace GitRef.isDefault (removed in #1551) with hash matching against
Repository.head to determine the default branch for the tree redirect.
Falls back to the first ref or "master" if no match is found.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Change summary

webui2/src/components/code/ref-selector.stories.tsx | 14 +++++++-------
webui2/src/routes/$repo.tsx                         |  5 ++++-
webui2/src/routes/$repo/index.tsx                   |  5 +++--
3 files changed, 14 insertions(+), 10 deletions(-)

Detailed changes

webui2/src/components/code/ref-selector.stories.tsx 🔗

@@ -14,13 +14,13 @@ export default meta;
 type Story = StoryObj<typeof meta>;
 
 const sampleRefs = [
-  { name: "refs/heads/main", shortName: "main", type: GitRefType.Branch, hash: "abc1", isDefault: true },
-  { name: "refs/heads/develop", shortName: "develop", type: GitRefType.Branch, hash: "abc2", isDefault: false },
-  { name: "refs/heads/feature/auth", shortName: "feature/auth", type: GitRefType.Branch, hash: "abc3", isDefault: false },
-  { name: "refs/heads/fix/login", shortName: "fix/login", type: GitRefType.Branch, hash: "abc4", isDefault: false },
-  { name: "refs/tags/v1.0.0", shortName: "v1.0.0", type: GitRefType.Tag, hash: "abc5", isDefault: false },
-  { name: "refs/tags/v1.1.0", shortName: "v1.1.0", type: GitRefType.Tag, hash: "abc6", isDefault: false },
-  { name: "refs/tags/v2.0.0-rc1", shortName: "v2.0.0-rc1", type: GitRefType.Tag, hash: "abc7", isDefault: false },
+  { name: "refs/heads/main", shortName: "main", type: GitRefType.Branch, hash: "abc1" },
+  { name: "refs/heads/develop", shortName: "develop", type: GitRefType.Branch, hash: "abc2" },
+  { name: "refs/heads/feature/auth", shortName: "feature/auth", type: GitRefType.Branch, hash: "abc3" },
+  { name: "refs/heads/fix/login", shortName: "fix/login", type: GitRefType.Branch, hash: "abc4" },
+  { name: "refs/tags/v1.0.0", shortName: "v1.0.0", type: GitRefType.Tag, hash: "abc5" },
+  { name: "refs/tags/v1.1.0", shortName: "v1.1.0", type: GitRefType.Tag, hash: "abc6" },
+  { name: "refs/tags/v2.0.0-rc1", shortName: "v2.0.0-rc1", type: GitRefType.Tag, hash: "abc7" },
 ];
 
 export const Default: Story = {

webui2/src/routes/$repo.tsx 🔗

@@ -7,13 +7,15 @@ export const REFS_QUERY = gql`
   query CodePageRefs($repo: String) {
     repository(ref: $repo) {
       name
+      head {
+        hash
+      }
       refs {
         nodes {
           name
           shortName
           type
           hash
-          isDefault
         }
       }
     }
@@ -23,6 +25,7 @@ export const REFS_QUERY = gql`
 export interface RefsQueryData {
   repository: {
     name: string;
+    head: { hash: string } | null;
     refs: { nodes: GitRef[] } | null;
   } | null;
 }

webui2/src/routes/$repo/index.tsx 🔗

@@ -14,8 +14,9 @@ export const Route = createFileRoute("/$repo/")({
       variables: { repo: ref },
     });
     const refs = data?.repository?.refs?.nodes ?? [];
-    const defaultRef = refs.find((r) => r.isDefault) ?? refs[0];
-    const refName = defaultRef?.shortName ?? "master";
+    const headHash = data?.repository?.head?.hash;
+    const defaultRef = headHash ? refs.find((r) => r.hash === headHash) : undefined;
+    const refName = defaultRef?.shortName ?? refs[0]?.shortName ?? "master";
 
     throw redirect({
       to: "/$repo/tree/$ref/$",