---
id: w6/m3/t007
title: Simplify — /simplify over the code this milestone changed
worker: worker6
status: done
estimate: 20m
depends_on: [w6/m3/t006]
---

## Closeout

Ran `/simplify`'s 4-agent pass (reuse, simplification, efficiency, altitude) over the full diff. Applied:

- Extracted the `graphQLErrorMessage()` helper (triplicated verbatim across `use-create-workspace.ts`/`use-rename-workspace.ts`/`use-delete-workspace.ts`) to `src/features/workspaces/lib/graphql-error.ts`.
- Extracted the duplicated workspace-name DNS-label regex to `WORKSPACE_NAME_RE` in `types.ts`, used by both `new.workspace.tsx` and `workspace-details-card.tsx`.
- Collapsed the duplicated `ownerId`-filter ternary in `local-bex.mjs` into one `byOwner()` helper.
- Gated `useWorkspaces()`'s query with `skip: !useIsAuthenticated()` — `WorkspaceProvider` is mounted globally (see t001), so without this every public auth page fired a real `workspaces` query pre-login.
- `skip`ped `useServices`/`useDatabases` until `currentWorkspaceId` resolves (was firing once with a stale/null `ownerId`, then again once the real one loaded); kept `loading` true across that window to avoid a flash of the empty state.
- `/new/workspace`'s submit switches + navigates from `createWorkspace`'s own response instead of awaiting a `refetch()` first.

Declined (documented as follow-ups in the milestone README, not silently dropped): moving `WorkspaceProvider` into a dedicated pathless authenticated layout route instead of the app root, re-running real `yarn codegen` against a live schema instead of the hand-authored `definitions.ts` additions, and moving `ownerId` scoping into the Apollo Link chain instead of a per-hook variable — each reshapes code well outside this diff (every existing authenticated route, or every existing query hook) for a marginal gain over what's already correct.

Dashboard `yarn typecheck`/`yarn lint`/`yarn test` all green after the fixes (489 tests passing).

## Objective

Run `/simplify` over the milestone's dashboard diff (workspace context, dropdown, routes, GraphQL documents): reuse/simplification/efficiency, behavior-preserving. Watch for per-route re-derivation of the selected workspace instead of consuming the one context.

## Context

- Changed areas: `dashboard/src/{components,routes,graphql}`.

## Steps

1. `/simplify` scoped to the milestone's changed files.
2. Apply findings; re-run dashboard checks (lint/typecheck/tests per `dashboard/CLAUDE.md`).

## Files

- `dashboard/src/`

## Acceptance criteria

- [ ] Findings applied or explicitly declined with reasons
- [ ] Dashboard lint/typecheck/tests green

## Out of scope

- Bug hunting (`/code-review`'s job).
