summaryrefslogtreecommitdiff
path: root/internal/handlers
AgeCommit message (Collapse)Author
4 daysfeat(widget): add recurrence lookup endpoint (GET /api/widget/recurrence)Peter Stone
4 daysfeat(widget): capture and forward RecurringEventID for calendar eventsPeter Stone
4 daysfeat(widget): add POST /api/widget/add for quick-addPeter Stone
4 daysfeat(widget): add DueDate field for doot tasks to the widget APIPeter Stone
4 daysfeat(widget): forward IsOverdue from TimelineItem to WidgetItem APIPeter Stone
4 daysfix(timeline): include overdue native tasks in timeline and widgetPeter Stone
GetNativeTasksByDateRange's SQL bound (due_date >= start) excluded any task overdue from a previous day before ComputeDaySection ever got a chance to mark it IsOverdue, so both the web Timeline view and the widget API (which both call BuildTimeline with start = today) silently dropped overdue tasks entirely -- only the Tasks tab (unbounded GetNativeTasks) showed them. Added GetOverdueNativeTasks and folded its results into BuildTimeline alongside the ranged fetch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD
4 daysfix(calendar): split comma-joined GOOGLE_CALENDAR_ID before usePeter Stone
fetchCalendarEvents falls back to config.GoogleCalendarID whenever no source_configs rows exist yet for the gcal source -- which is the current live state (0 rows). GoogleCalendarID is a single env var that itself holds a comma-separated list of calendar IDs, but the whole joined string was being wrapped in a single-element []string{...} and passed straight to SetCalendarIDs. Google's API takes one calendarId per call, so every fetch failed with '404 Not Found' on the literal comma-joined string -- confirmed live in production logs. This broke all calendar events, in both the web dashboard and the widget, silently. Now splits on commas and trims whitespace before use.
4 daysfix(widget): pin all-day calendar events to the top instead of losing themPeter Stone
WidgetItem.isAllDay was carried by the client's data model but nothing ever read it. All-day events had no Start at all, so they fell into the same floating-task queue as ordinary untimed tasks; if enough tasks were ahead of one in the queue, SlotPacker could assign it an hour slot past the visible grid range entirely -- not merely unpinned, actually invisible. Server: TimelineItemToWidgetItem now populates Start for all-day CALENDAR EVENTS specifically (their real event date), while leaving undated doot/gtask tasks -- also flagged IsAllDay as a "no specific time" fallback, a different concept -- on the existing nil-Start floating behavior. Client: all-day events are filtered out of the hourly grid/floating-task pipeline entirely, bucketed by day using the new Start date, and rendered in a new pinned AllDayRow section right after the TODAY/TOMORROW headers.
4 daysfix(widget): surface unmatched task IDs instead of silently no-oppingPeter Stone
CompleteNativeTask/UncompleteNativeTask/RescheduleNativeTask ran a plain UPDATE ... WHERE id = ? and returned whatever error Exec gave back -- which is nil even when 0 rows match, since that's not a SQL error. A stale or wrong id from the widget looked identical to a real completion: HTTP 200, nothing changed in the database. Real incident: 1 of 3 widget completeTask taps silently no-opped this way. Now checks RowsAffected() and returns ErrNativeTaskNotFound (mirrors the existing pattern in sqlite.go's ApproveAgentSession/DenyAgentSession). HandleWidgetComplete and HandleWidgetReschedule surface this as 404 instead of a fake 200, so the widget can tell 'nothing changed' apart from 'it worked.'
10 daysfeat: remove Todoist integration entirelyDoot Agent
Native tasks (native_tasks table) fully replace Todoist. All Todoist API code, store functions, handlers, routes, templates, and tests have been removed. Migration 021 drops the now-unused tasks cache table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
11 daysMerge deploy/master (gateway/proxy fixes) with doot-native task completion fixPeter Stone
Reconciles diverged histories: deploy/master had gateway proxy Host-header and publicPaths fixes that were never synced back to local/github; this branch had the native-task Tasks-tab/completion fix. Merging both.
11 daysfix: native tasks missing from Tasks tab and blank title on completionDoot Agent
Bug 1: BuildUnifiedAtomList never called GetNativeTasks(), so doot-sourced tasks were absent from the web Tasks tab. Added GetNativeTasks() fetch and NativeTaskToAtom conversion (new model helper, SourceDoot constant). Bug 2: handleAtomToggle called getAtomDetails after CompleteNativeTask, but GetNativeTasks filters WHERE completed=0, so the task was already gone and the title came back blank. Moved getAtomDetails call to before the completion switch so all sources (including doot) capture title/dueDate first. Also fixed widget_test.go compile error: TestHandleWidgetComplete_NonTodoist called HandleWidgetComplete as a package-level function but it is a method on *Handler. Rewrote the file as package handlers (internal) and construct &Handler{} directly. Regression tests added for both bugs in atoms_test.go and handlers_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
11 daysfix(proxy): set Host header to upstream target to satisfy loopback MCP ↵Peter Stone
DNS-rebinding check mcp.NewStreamableHTTPHandler rejects requests where the server is bound to loopback but the Host header is not (DNS-rebinding protection). Requests proxied through doot arrived at claudomator with Host: doot.terst.org, triggering a 403. Set req.Host = target.Host in the ReverseProxy Director so upstream services see the target host (e.g. 127.0.0.1:8484) rather than the original public hostname.
2026-06-29fix: calendar/meals sync, tomorrow flat layout, /health endpointPeter Stone
- Calendar: fall back to GOOGLE_CALENDAR_ID config when no source_configs synced yet (fixes blank calendar after fresh deploy) - Meals: call fetchMeals in HandleTimeline so PlanToEat cache refreshes on every timeline load, not just during manual refresh - Tomorrow section: replace calendar-grid with flat chronological list matching widget layout (time label | source bar | title) - Add /health endpoint (no auth required) for deploy health checks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29feat: reschedule tasks from widget bottom sheetPeter Stone
Tapping a doot task shows a date picker. On confirm, POSTs to /api/widget/reschedule, updates due_date in native_tasks, refreshes widget. Reschedule button only shows for source="doot" tasks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29feat: make Todoist optional, guard nil client callsPeter Stone
TODOIST_API_KEY is no longer required — native task management works without it. Guards nil todoistClient in handleAtomToggle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29feat: native task management + Todoist migrationPeter Stone
Adds doot-owned task storage (native_tasks table) so tasks can be managed without Todoist. CompleteTask for 'doot' source just updates the DB — no external API call, no token dependency. Migration path: POST /settings/import-from-todoist — copies Todoist cache → native_tasks Then remove TODOIST_TOKEN from .env to disable Todoist Changes: - migration 020: native_tasks table - store: GetNativeTasks, GetNativeTasksByDateRange, GetUndatedNativeTasks, CreateNativeTask, CompleteNativeTask, UncompleteNativeTask, UpdateNativeTask, ImportFromTodoist - timeline: native tasks appear as source="doot" (teal) - handleAtomToggle: "doot" case — no external API needed - HandleWidgetComplete: method on Handler, handles "doot" natively - HandleUnifiedAdd: "doot" source creates in native_tasks - widget: "doot" tasks are completable, teal color indicator Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29feat: add standalone task detail page for Android widget deep-linksPeter Stone
Adds GET /task?id=xxx&source=xxx route that renders a full mobile-friendly task detail page (session-protected). Widget task rows now open this page when tapped. HandleUpdateTask redirects back to the page after a non-HTMX save. Android: threads serverUrl through composable chain to TaskRow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29fix: widget doubling (hourEnd), transparent bg, tomorrow items, larger textPeter Stone
2026-06-29fix: widget handler timezone, auth guard, and type switch clarityPeter Stone
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29feat: add widget HTTP handlers with bearer token authPeter Stone
Implements WidgetAuthMiddleware (static bearer token), TimelineItemToWidgetItem (conversion helper), HandleWidgetGet (today's items as JSON), and HandleWidgetComplete (proxies task completion to Todoist). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15feat: service gateway framework + playground demoPeter Stone
Formalizes doot as an authenticated reverse proxy for arbitrary upstream services. Any local HTTP service can now be registered behind doot's existing auth + SSL layer with 3 lines of config. - Rename NewClaudomatorProxy → NewServiceProxy (generic) - Replace hard-coded claudomator proxy block with serviceMount slice loop - Add PlaygroundURL config (PLAYGROUND_URL env var) - Add playground/web/server.py: stdlib Python status page on port 9090 - Document pattern in .agent/design.md; update .env.example To add a new service: set its URL env var, add a config field, append one mount entry in main.go. Claudomator's GitHub webhook bypass is expressed as webhookPaths on its mount. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03fix: add CSRF and WebSocket origin protection to Claudomator proxyPeter Stone
Token-based CSRF is impractical for a reverse proxy whose UI doesn't know Doot's session tokens, so state-changing requests to /claudomator/* are now validated against the configured WebAuthn origin via Origin/Referer header. WebSocket upgrades reject mismatched or missing Origin headers before hijacking the connection. Both checks are no-ops when WebAuthnOrigin is unset (local dev). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03feat: synchronize background image rotation across sessionsPeter Stone
Server seeds bg URL from a 5-minute time bucket so all open sessions show the same image simultaneously. Client-side JS rotates in sync and prefetches the next image on the same interval. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25feat: add Claudomator stories as atom source in Doot tasks tabClaude Agent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25feat: gate Claudomator UI behind Doot session auth via reverse proxyDoot Agent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23fix: support multiple enabled Google Task lists and CalendarsPeter Stone
- Update Google API interfaces with setters for list/calendar IDs - Update fetchCalendarEvents and fetchGoogleTasks to use enabled IDs from source_configs - Update timeline logic tests to reflect interface changes and seed config data - Ensure dashboard respects user-selected lists from settings
2026-03-23feat: unify Google Tasks with main system via caching and integrated UIPeter Stone
- Implement SQLite caching layer for Google Tasks - Integrate Google Tasks into unified Atoms loop (showing in Tasks tab) - Update Planning tab to include cached Google Tasks - Enhance Quick Add form with Todoist project selector - Remove orphaned HandleTasksTab/HandleRefreshTab methods - Update tests to reflect new BuildTimeline signature and data structures
2026-03-23feat: complete Agent Context API Phase 2 & 3 (Write/Create/Management)Peter Stone
- Implement write operations (complete, uncomplete, update due date, update task) - Implement create operations (create task, add shopping item) - Add Trusted Agents management UI in Settings with revocation support - Fix SQLite timestamp scanning bug for completed tasks - Add comprehensive unit tests for all new agent endpoints - Update worklog and feature documentation
2026-03-23fix: parse Todoist local datetimes, show near-future tasks, add undated ↵Peter Stone
tasks to timeline - parseDueDate: handle date field containing "YYYY-MM-DDTHH:MM:SS" (local time, no tz offset) — Todoist REST API v1 uses this format for recurring tasks with a set time, causing due dates to silently parse as nil - IsFuture threshold: widen from tomorrow to 7 days out so tasks due this week show in the main tasks section with dates visible (not collapsed) - BuildTimeline: include undated Todoist tasks in the Today section (mirrors existing Google Tasks behavior) - GetUndatedTasks: new store method for tasks with due_date IS NULL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22chore: unify and centralize agent configuration in .agent/Peter Stone
2026-03-21feat: Phase 1 — remove bug feature and dead codePeter Stone
- Delete Bug struct, BugToAtom, SourceBug, TypeBug, TypeNote - Remove bug store methods (SaveBug, GetBugs, ResolveBug, etc.) - Remove HandleGetBugs, HandleReportBug, bug branches in handlers - Remove bug routes, bugs.html template, bug UI from index.html - Remove AddMealToPlanner stub + interface method - Migration 018: DROP TABLE IF EXISTS bugs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19refactor: RF-04/08 migrate inline HTML to templates, standardize form parsingClaude Agent
RF-04: Already complete in codebase (handlers use HTMLResponse + partials). RF-08: Migrate single-required-field handlers from Pattern A/B to Pattern C (requireFormValue). Affected: HandleCompleteTask, HandleCompleteCard, HandleReportBug, HandleCreateTask in handlers.go; HandleToggleFeature, HandleCreateFeature in settings.go. Reduces 6-8 lines of boilerplate to 2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19test: add coverage for planning tab, meals, Google Tasks, bug handlers, ↵Agent
completed task parsing - HandleTabPlanning: happy-path test verifying tasks/cards land in correct sections (scheduled/unscheduled/upcoming); boundary test confirming a task due exactly at midnight of tomorrow lands in Upcoming, not Scheduled - HandleTabMeals: grouping test verifying two meals sharing date+mealType produce one CombinedMeal with both recipe names merged - Google Tasks GetTasksByDateRange: four boundary tests (start inclusive, end exclusive, no-due-date always included, out-of-range excluded) using redirectingTransport mock server pattern - HandleGetBugs: data assertions verifying bug list and empty-list cases - HandleReportBug: success test verifying bug is saved and bugs template is re-rendered - GetCompletedTasks: timestamp parsing test ensuring CompletedAt is not zero when inserted with a known "2006-01-02 15:04:05" string Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18refactor: RF-03/06 extract groupMeals helper, eliminate ↵Claude
convertSyncItemToTask wrapper RF-03: Extract shared groupMeals helper into internal/handlers/meals.go. Both HandleTabMeals and BuildTimeline now call groupMeals instead of duplicating the date+mealType grouping algorithm inline. CombinedMeal gains ID and Meals fields to carry the first-meal ID and original records needed by BuildTimeline when constructing TimelineItems. RF-06: Add api.ConvertSyncItemToTask for single-item conversion. ConvertSyncItemsToTasks now delegates to it, eliminating duplication. The Handler.convertSyncItemToTask wrapper (which allocated a one-element slice just to unwrap it) is deleted; its caller uses api.ConvertSyncItemToTask directly. Covered by TestConvertSyncItemToTask in internal/api/todoist_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18chore: autocommit uncommitted changesClaudomator Agent
2026-03-04feat: sync log, cache clear endpoint, Todoist projects from cached tasksPeter Stone
- migration 016: sync_log table - store: AddSyncLogEntry, GetRecentSyncLog, InvalidateAllCaches, GetProjectsFromTasks - settings: HandleClearCache (POST /settings/clear-cache), SyncLog in page data - settings: use GetProjectsFromTasks instead of deprecated Todoist REST /projects - handlers: populate atom projects from store - agent: log warning on registration failure instead of silently swallowing - google_tasks: simplify URL literal - tests: sync log CRUD, clear cache handler, settings page includes sync log, sync sources adds log entry, incremental sync paths, task completion response/headers, calendar cache fallback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17Add calendar cache layer, incremental sync tests, completion assertionsPeter Stone
- Google Calendar events now cached via CacheFetcher pattern with stale-cache fallback on API errors (new migration 015, store methods, fetchCalendarEvents handler, BuildTimeline reads from store) - Todoist incremental sync path covered by 5 new tests - Task completion tests assert response body, headers, and template data Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07Add no-cache header tests, update SESSION_STATE with audit resultsPeter Stone
- Added TestHTMLResponse_SetsNoCacheHeaders and TestJSONResponse_SetsNoCacheHeaders - Rewrote SESSION_STATE.md with verified test coverage per completed item - Documented known gaps (Google API client unit tests, WebAuthn env vars) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07Fix passkey registration showing broken UI when WebAuthn not configuredPeter Stone
Root cause: WEBAUTHN_RP_ID and WEBAUTHN_ORIGIN env vars not set in production, so WebAuthn is nil and all passkey endpoints return 404. The settings page was unconditionally showing the passkey registration card, leading to confusing "Failed to start registration" errors. Fix: Pass WebAuthnEnabled flag from main.go through Handler to the settings template, which now conditionally renders the passkey card only when WebAuthn is properly configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07Add build version footer, deploy ldflags, template test helper, and logs scriptPeter Stone
- Display build commit hash in unobtrusive footer overlay - Inject buildCommit/buildTime via ldflags in deploy.sh - Add assertTemplateContains test helper, refactor existing template tests - Add scripts/logs for fetching production journalctl via SSH Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07Fix timeline task completion replacing view, fix passkey registration CSRFPeter Stone
- Fix checkboxes in timeline calendar grid targeting #tab-content (replaced entire view). Now target closest .untimed-item/.calendar-event with outerHTML - Fix passkey registration 403 by passing CSRFToken from settings handler and exposing it via meta tag for JS to read - Add TDD workflow requirement to CLAUDE.md - Tests written first (red-green): template content assertions for checkbox targets and CSRF token presence, handler data struct verification Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06Fix missing settings button, disappeared events, and tab refresh bugPeter Stone
- Add settings gear icon link to dashboard header - Fix GetTasksByDateRange/GetCardsByDateRange to include overdue items (changed from BETWEEN to <= end, filter completed tasks) - Fix refresh replacing active tab with tasks tab by using htmx.trigger(body, 'refresh-tasks') instead of innerHTML+htmx.process - Add refresh-tasks hx-trigger to meals, shopping, conditions tabs - Add tests for overdue inclusion/exclusion, settings link, template data Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05Extract shopping handlers to dedicated filePeter Stone
Moved 8 shopping-related handlers from handlers.go to shopping.go: - HandleTabShopping - HandleShoppingQuickAdd - HandleShoppingToggle - HandleShoppingMode - HandleShoppingModeToggle - HandleShoppingModeComplete - HandleGetShoppingLists - aggregateShoppingLists handlers.go: 1633 → 1232 lines (24% reduction) shopping.go: 415 lines (new) All tests passing. No behavioral changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03Add comprehensive test coverage across packagesPeter Stone
New test files: - api/http_test.go: HTTP client and error handling tests - config/config_test.go: Configuration loading and validation tests - middleware/security_test.go: Security middleware tests - models/atom_test.go: Atom model and conversion tests Expanded test coverage: - api/todoist_test.go: Todoist API client tests - api/trello_test.go: Trello API client tests - auth/auth_test.go: Authentication and CSRF tests - handlers/timeline_logic_test.go: Timeline building logic tests - store/sqlite_test.go: SQLite store operations tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03Refactor template rendering with Renderer interface for testabilityPeter Stone
Introduce a Renderer interface to abstract template rendering, enabling tests to use MockRenderer instead of requiring real template files. Changes: - Add renderer.go with Renderer interface, TemplateRenderer, and MockRenderer - Update Handler struct to use Renderer instead of *template.Template - Update HTMLResponse() to accept Renderer interface - Replace all h.templates.ExecuteTemplate() calls with h.renderer.Render() - Update all tests to use MockRenderer, removing template file dependencies This eliminates 15+ tests that previously skipped with "Templates not available" and improves test isolation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01Improve shopping mode and flatten nav barPeter Stone
Shopping mode: - Click to complete items (deletes user items, hides external items) - Add print button with compact two-column print layout - Fix CSRF token for HTMX requests - Fix input clearing with proper htmx:afterRequest handler - Remove "Quick Add" store option, require valid store Navigation: - Replace dropdown menu with flat nav showing all tabs - Remove unused dropdown JS Tests: - Add TestHandleShoppingModeComplete for user and external items Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01Improve timeline view with dynamic bounds, now line, and overlap handlingPeter Stone
- Add dynamic calendar clipping: show 1 hour before/after events instead of hardcoded 6am-10pm - Add "NOW" line indicator showing current time position - Improve time label readability with larger font and better contrast - Add overlap detection with column-based indentation for concurrent events - Apply calendar view to Tomorrow section (matching Today's layout) - Fix auto-refresh switching to tasks tab (default was 'tasks' instead of 'timeline') Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31Fix timeline calendar view and shopping UI bugs (#56, #65-73)Peter Stone
- #56: Add overflow-hidden to card/panel classes to prevent content overflow - #65: Fix Google Tasks not showing by including tasks without due dates - #66: Add no-cache headers to prevent stale template responses - #67: Increase dropdown z-index to 100 for proper layering - #69: Implement calendar-style Today section with hourly grid (6am-10pm), duration-based event heights, and compact overdue/all-day section - #70: Only reset shopping-mode form on successful submission - #71: Remove checkboxes from shopping tab (only show in shopping mode) - #72: Add inline add-item input at end of each store section - #73: Add Grouped/Flat view toggle for shopping list Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31Add feature toggles system with settings UI (#74)Peter Stone
- Add feature_toggles table (migration 012) - Add source_config table for future source selection (migration 013) - Create settings page at /settings with: - Feature toggle management (enable/disable/create/delete) - Data source configuration (sync and toggle boards/calendars) - Add store methods for feature toggles and source config - Add GetCalendarList and GetTaskLists to Google API clients - Document feature toggle workflow in DESIGN.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>