Skip to content

feat(dashboard): unify upstream edit/create Fetch button UX#228

Merged
Menci merged 8 commits into
Menci:mainfrom
yyyr-p:worktree-upstream-edit-fetch-models
Jul 16, 2026
Merged

feat(dashboard): unify upstream edit/create Fetch button UX#228
Menci merged 8 commits into
Menci:mainfrom
yyyr-p:worktree-upstream-edit-fetch-models

Conversation

@yyyr-p

@yyyr-p yyyr-p commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix getUpstream handler to include modelsCache in the initial edit-page load. Previously only list/create/update went through serializeForResponse (which attaches modelsCache + codex_quota); getUpstream inlined a projection without them, so the Models Cache panel stayed empty until the first Save. Fixed by parametrizing serializeForResponse over the base serializer and routing getUpstream through it with upstreamRecordToFullJson.
  • Expose the per-provider Fetch button in edit mode on Custom + Ollama panels (previously only visible in create). Operators can now preview a re-fetch of the in-flight form config (baseUrl / apiKey) before saving. In edit mode an untyped apiKey falls back to the stored secret, matching how save() treats an empty apiKey via backend patch-omit semantics.
  • Turn ModelsCacheStatus into an info-only panel (no button, no emit). The per-provider Fetch button is now the single re-fetch entry point; the cache panel is a passive reflection of the SWR row.
  • Payload-shape consolidation: buildOllamaConfig / buildAzureConfig / buildListModelsPreviewConfig now live in customConfig.ts alongside buildCustomConfigCore, so form-draft-to-wire-shape projection has one home. applyListModelsResult closure factors out the custom-vs-projected fetch-result dispatch that used to be duplicated between listDraftModels and fetchUpstreamModels.
  • Peer-conformance sweeps on comments: dropped caller names, aligned Ollama-panel comment density with sibling per-provider panels.

Test plan

  • `pnpm run typecheck` — passes across all packages
  • `pnpm run lint` — clean
  • `pnpm run test` — 3994/3994 passed
  • Manual E2E via Chrome DevTools on `pnpm run dev:node`:
    • Created a Custom upstream, opened edit page
    • Confirmed Models Cache section renders immediately on initial edit-page load (no Save needed)
    • Confirmed Fetch button visible in edit mode
    • Confirmed Fetch POST payload carries `record.id` (non-empty → backend force-refresh SWR) and `config.apiKey` auto-populated from stored secret when field left blank
    • Confirmed fetch errors render inline under the Fetch button (correct `fetchError` slot)

yyyr-p added 8 commits July 13, 2026 05:29
- fix: getUpstream now returns modelsCache (was missing from single-record
  GET, only present in list/create/update — the Models Cache section in
  the edit page never appeared until a save had happened)
- Fetch button in Custom/Ollama config panels is no longer create-only;
  edit mode gets the same in-flight preview UX as new upstream
- listDraftModels fills apiKey from stored secret when the operator
  didn't retype it (edit mode), matching save()'s "empty means keep"
  semantics so the preview doesn't hit an unauthenticated upstream
- listDraftModels reloads the store + reflects fresh modelsCache back
  into draft on success, replacing the removed Refresh now button
- ModelsCacheStatus is now a passive info panel (last fetched / last
  error) with no button — Fetch owns the re-fetch action
- unify fetchedOllamaModels into upstreamModels so autoForActive doesn't
  branch on isCreate for ollama
…ializer

getUpstream inlined the same modelsCache + codexQuota projection
serializeForResponse already owned, differing only in the redacted-vs-
full serializer choice. Widen the helper to take the base serializer as
an argument (defaulting to upstreamRecordToJson so list/create/update
callers stay put) and let getUpstream pass upstreamRecordToFullJson.
Response envelope is byte-identical.
…stomConfig

listDraftModels open-coded the per-kind builder dispatch and the
edit-mode stored-secret fallback, mixing form-draft-to-wire-shape
policy into a Vue setup function whose primary job is UI orchestration.
Move both into customConfig.ts alongside buildCustomConfigCore: the new
buildListModelsPreviewConfig handles the dispatch and the fallback, and
buildOllamaConfig moves next to it so save() and the preview share one
wire-shape projection for ollama.
…lt dispatch

listDraftModels and fetchUpstreamModels both branched on draft.kind to
route the response into fetchedRaw (custom) or upstreamModels (else).
Fold the two identical tails into one closure so a future kind or slot
change only lives in one place.
- drop stale 'operator-driven refresh' caller reference in fetchUpstreamModels
- align OllamaConfigPanel top comment + fetchStatus JSDoc with sibling panels
Three comment-only edits on UpstreamEditPage.vue after the
applyListModelsResult extract-refactor:

- Drop the comment above applyListModelsResult: the routing rationale
  is already carried by the ListModelsResult type comment directly
  above the helper and by the autoForActive comment further down.
- Trim the fetchUpstreamModels comment: drop the custom-vs-projected
  routing paragraph (the extracted helper now owns that routing) and
  the trailing "surfaces error on upstreamModelsError" line (pure
  restatement of the adjacent assignment).
- Shrink the fetchedRaw declaration comment to a 3-line role hint
  pointing at customAutoModelsFromDraft; the why-two-refs story stays
  discoverable via the autoForActive comment.
Round 1 moved buildOllamaConfig out of UpstreamEditPage.vue into the
wire-shape module next to buildCustomConfigCore; Azure's counterpart
stayed local. Move it too so the two-of-three post-Round-1 split
collapses onto one pattern — every editable-provider save-shape
projection lives in customConfig.ts, UpstreamEditPage only dispatches.
Convention: comments never reference callers. Rewrite the projection
comment to explain the baseSerialize parameter caller-agnostically —
same WHY, no enumeration of consumer sites.
@yyyr-p yyyr-p changed the title Unify upstream edit/create Fetch button UX feat(dashboard): unify upstream edit/create Fetch button UX Jul 16, 2026
@Menci Menci merged commit 7e10c5f into Menci:main Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants