refactor(web): use head.shortName for default branch

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

Now that Repository.head returns a GitRef instead of GitCommit, we can
use the ref name directly instead of hash-matching against the refs
list.

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

Change summary

webui2/src/__generated__/graphql.ts | 17 ++++++++++++-----
webui2/src/routes/$repo.tsx         |  4 ++--
webui2/src/routes/$repo/index.tsx   |  5 +----
3 files changed, 15 insertions(+), 11 deletions(-)

Detailed changes

webui2/src/__generated__/graphql.ts 🔗

@@ -731,6 +731,8 @@ export enum GitObjectType {
 /** A git branch or tag reference. */
 export type GitRef = {
   __typename?: 'GitRef';
+  /** Git commit the reference points to. */
+  commit: GitCommit;
   /** Commit hash the reference points to. */
   hash: Scalars['String']['output'];
   /** Full reference name, e.g. refs/heads/main or refs/tags/v1.0. */
@@ -748,10 +750,12 @@ export type GitRefConnection = {
   totalCount: Scalars['Int']['output'];
 };
 
-/** The kind of git reference: a branch or a tag. */
+/** The kind of git reference: a branch, a tag, or a detached commit. */
 export enum GitRefType {
   /** A local branch (refs/heads/*). */
   Branch = 'BRANCH',
+  /** A detached HEAD pointing directly at a commit. */
+  Commit = 'COMMIT',
   /** An annotated or lightweight tag (refs/tags/*). */
   Tag = 'TAG'
 }
@@ -1006,11 +1010,11 @@ export type Repository = {
    */
   commits: GitCommitConnection;
   /**
-   * The commit pointed to by HEAD in the git repository.
-   * Null if HEAD cannot be resolved to a commit, for example in an empty or unborn
+   * The reference pointed to by HEAD in the git repository.
+   * Null if HEAD cannot be resolved, for example in an empty or unborn
    * repository, or if HEAD is missing or invalid.
    */
-  head?: Maybe<GitCommit>;
+  head?: Maybe<GitRef>;
   /** Look up an identity by id prefix. Returns null if no identity matches the prefix. */
   identity?: Maybe<Identity>;
   /**
@@ -1021,7 +1025,10 @@ export type Repository = {
   lastCommits: Array<GitLastCommit>;
   /** The name of the repository. Null for the default (unnamed) repository in a single-repo setup. */
   name?: Maybe<Scalars['String']['output']>;
-  /** All branches and tags, optionally filtered by type. */
+  /**
+   * All branches and tags, optionally filtered by type. BRANCH and TAG are
+   * the only accepted filter values; passing COMMIT returns an error.
+   */
   refs: GitRefConnection;
   /** Directory listing at path under ref. An empty path returns the root tree. */
   tree: Array<GitTreeEntry>;

webui2/src/routes/$repo.tsx 🔗

@@ -8,7 +8,7 @@ export const REFS_QUERY = gql`
     repository(ref: $repo) {
       name
       head {
-        hash
+        shortName
       }
       refs {
         nodes {
@@ -25,7 +25,7 @@ export const REFS_QUERY = gql`
 export interface RefsQueryData {
   repository: {
     name: string;
-    head: { hash: string } | null;
+    head: { shortName: string } | null;
     refs: { nodes: GitRef[] } | null;
   } | null;
 }

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

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