Skip to content

(CODUX-125) Add update-status hook for the title bar - #2769

Merged
numnx merged 1 commit into
feature/CODUX-199-fix-update-buttonfrom
task/feature-codux-199-fix-update-button-t01-codex-mrcz6y7o
Jul 9, 2026
Merged

(CODUX-125) Add update-status hook for the title bar#2769
numnx merged 1 commit into
feature/CODUX-199-fix-update-buttonfrom
task/feature-codux-199-fix-update-button-t01-codex-mrcz6y7o

Conversation

@numnx

@numnx numnx commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

🧩 Task: Add update-status hook for the title bar

Automated task PR opened by Code UX for T01.

📋 Summary

Sprint: Sprint 199 · Fix Update Button · Task: T01

Fix the Electron title-bar Update button so it reflects real update availability: surface the update affordance only when a newer version exists (driven by the existing /api/system/update-status pipeline) instead of being hardcoded to always show, and communicate the available version.

🤖 Model & Provider

Provider Codex CLI
Model gpt-5.5

⏱️ Timing

Started 2026-07-09 03:57:16 UTC
Finished 2026-07-09 04:01:00 UTC
Duration 3m 44s

📊 Token Usage

Metric Value
Input tokens 64,542
Cached input tokens 721,664
Output tokens 6,881
Total tokens 793,087
Invocations 1
Tool calls 38
Active time 3m 4s

Included usage estimate (subscription/local login): $0.89

✅ QA Review

⏳ QA review runs after this PR is opened. Check the task card in the dashboard for the outcome once it lands.

📝 Full Task Prompt
## Objective
Add a small, testable Preact hook that loads Code UX update availability once on mount from the existing `/api/system/update-status` endpoint and exposes whether an update is available plus the latest version, so the title bar can render the Update button conditionally.

## Scope
- Create `dashboard/src/v2/hooks/use-update-status.ts`
- Create `tests/dashboard/hooks/use-update-status.test.tsx`
- Reuse the existing client helper `fetchUpdateStatus` and `UpdateStatus` type from `dashboard/src/v2/lib/system-api.ts` (do not redefine the contract)
- Follow the existing hook style in `dashboard/src/v2/hooks/` (e.g. `use-notifications.ts`, `use-project-git-status.ts`)

## Implementation Requirements
1. Export `useUpdateStatus()` returning a typed object, e.g. `{ status: UpdateStatus | null; updateAvailable: boolean; latestVersion: string | null }`, initialized to a not-yet-loaded state.
2. On mount, call `fetchUpdateStatus()` inside a `useEffect`; store the resolved `UpdateStatus` in state via `useState`. Use a `cancelled` guard in the effect cleanup so state is not set after unmount.
3. Derive `updateAvailable` strictly from `status?.updateAvailable === true` and `latestVersion` from `status?.latestVersion ?? null`; treat a fetch rejection as no update available (catch the error, leave `updateAvailable` false, do not throw).
4. Keep the hook side-effect free beyond the single fetch; do not add polling, intervals, or new API routes.
5. In the test file (add the `@vitest-environment jsdom` pragma at the top), mock `../../dashboard/src/v2/lib/system-api` (or the correct relative path) with `vi.mock`, render the hook via `@testing-library/preact` `renderHook`, and assert: (a) update-available payload yields `updateAvailable: true` with the latest version, (b) up-to-date payload yields `updateAvailable: false`, (c) a rejected fetch yields `updateAvailable: false` and does not throw.

## Constraints
- Do not introduce a new HTTP route, new client protocol shape, or a new copy of `UpdateStatus`; reuse `system-api.ts`.
- Do not change `fetchUpdateStatus` behavior or the server route.
- The hook must be safe to import in the Electron-rendered dashboard bundle (no Node-only APIs).

## Verification
- `pnpm test tests/dashboard/hooks/use-update-status.test.tsx` passes.
- `pnpm run typecheck:dashboard` passes.
- Confirm the three test cases (available / up-to-date / fetch error) behave as specified.
🌿 Branch Info

Base: feature/CODUX-199-fix-update-button
Head: task/feature-codux-199-fix-update-button-t01-codex-mrcz6y7o


🤖 Generated by Code UX

@numnx
numnx merged commit f269a8c into feature/CODUX-199-fix-update-button Jul 9, 2026
6 checks passed
@numnx
numnx deleted the task/feature-codux-199-fix-update-button-t01-codex-mrcz6y7o branch July 9, 2026 04:03
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.

1 participant