From 81f1e7a489c62f21bb71b7402a2758735cddef57 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 13 Jan 2026 13:37:34 -1000 Subject: Add issue tracking documentation - bug_001_template_rendering.md: Template error documentation - bug_002_tab_state.md: Tab state persistence issue (now resolved) Co-Authored-By: Claude Sonnet 4.5 --- issues/bug_002_tab_state.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 issues/bug_002_tab_state.md (limited to 'issues/bug_002_tab_state.md') diff --git a/issues/bug_002_tab_state.md b/issues/bug_002_tab_state.md new file mode 100644 index 0000000..c8c7c09 --- /dev/null +++ b/issues/bug_002_tab_state.md @@ -0,0 +1,31 @@ +# Bug 002: Tab State Persistence (RESOLVED) + +## Status +**RESOLVED** + +## Description +When a user switches tabs (e.g., to "Notes") and refreshes the page, the dashboard resets to the default "Tasks" tab. This is a poor user experience. The application should respect the `?tab=` query parameter and update the URL when tabs are switched. + +## Root Cause +1. **Server-Side:** `HandleDashboard` does not read the `tab` query parameter or pass it to the template. +2. **Client-Side:** `index.html` hardcodes the initial active tab to "Tasks". +3. **Client-Side:** Tab buttons use `hx-push-url="false"`, so the URL doesn't update on click. + +## Resolution +1. **Model Update:** Added `ActiveTab` field to `DashboardData` struct in `internal/models/types.go`. +2. **Handler Update:** Updated `HandleDashboard` in `internal/handlers/handlers.go` to: + * Read `r.URL.Query().Get("tab")`. + * Validate the tab name (defaulting to "tasks"). + * Set `ActiveTab` in the data passed to the template. +3. **Template Update:** Updated `web/templates/index.html` to: + * Use `{{if eq .ActiveTab "..."}}` to conditionally apply the `tab-button-active` class. + * Set the initial `hx-get` for `#tab-content` to `/tabs/{{.ActiveTab}}`. + * Set `hx-push-url="?tab=..."` on all tab buttons to ensure the URL updates in the browser history. +4. **Client-Side Update:** Updated `web/static/js/app.js` to initialize `currentTab` from the URL query parameter. + +## Verification +* **Automated Test:** Created `internal/handlers/tab_state_test.go` which verifies: + * Default load (`/`) renders "tasks" as active. + * Query param load (`/?tab=notes`) renders "notes" as active. + * All valid tab names are supported. +* **Manual Verification:** Confirmed that clicking tabs updates the URL and refreshing the page preserves the active tab. -- cgit v1.2.3