Commit Graph

96 Commits

Author SHA1 Message Date
joakim 0d57aed8ce version bump 2026-02-25 23:07:44 +01:00
joakim 393b7a144a fix: use Modifier.Set() to maintain AttributeOrder invariant in API handlers
API handlers were populating SetAttributes directly without appending to
AttributeOrder. Since Apply() only iterates AttributeOrder, all updates
via PUT/POST were silently dropped — causing edits to revert and tasks
to disappear on reload.

Adds Modifier.Set() helper, safety net in Apply()/ApplyToNew(), adds
description and status to applyNonDateAttribute, and fixes the
recurrence->recur key mismatch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:42:57 +01:00
joakim 201f32d095 Merge branch 'worktree-web-ui' 2026-02-25 22:39:32 +01:00
joakim e86d063912 fix: show Set... placeholder for scheduled/wait/until date fields
Also fix selectedTask going stale after store updates by syncing
it from the store subscription instead of manual patching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:39:18 +01:00
joakim 10421b0ec6 feat: add hard delete flag and opal clean command
Add --hard flag to `opal delete` for permanent removal and a new
`opal clean` command to bulk-purge soft-deleted tasks with optional
--older duration filter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:30:50 +01:00
joakim 08123aa3c5 fix: shell autocomplete bypasses preprocessing and completes attribute values
Bypass Execute() preprocessing for __complete/__completeNoDesc so Cobra's
built-in completion handles shell TAB without creating tasks. Add root
ValidArgsFunction for flexible syntax (e.g. "opal 1 de<TAB>" → delete),
attribute value completions (status:pending, priority:H, date synonyms),
and NoSpace directive on key: completions to avoid trailing space.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:05:15 +01:00
joakim 6c28e4d24a fix: Hide waiting tasks from reports as default behaviour 2026-02-25 21:46:50 +01:00
joakim 9973631df0 refactor: deduplicate engine internals, replace bubble sorts, remove dead code
Extract shared code that was duplicated across functions:
- taskJSON struct (MarshalJSON/UnmarshalJSON) to package-level type
- scanTask(scanner) helper for GetTask/GetTasks (~70 identical lines)
- monthNames map for parseMonthName/parseDayAndMonth
- applyNonDateAttribute helper for Apply/ApplyToNew
- resolveDisplayID calls replace inline loops in FormatTaskListWithFormat

Replace O(n²) bubble sorts with sort.Slice in all four report sort
functions (sortByUrgency, NewestReport, NextReport, OldestReport).

Remove dead code: formatTimeWithColor (unused, also used time.Now()
instead of timeNow()), getCurrentTimestamp (unnecessary wrapper).

Remove ~20 comments that restated the next line of code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 01:46:46 +01:00
joakim a11f452d3b fix: break sync feedback loop, respect timestamps, surface errors
- Add migration v2: source column on change_log to distinguish local
  vs sync-originated entries, preventing the echo loop where synced
  tasks get re-pushed as local changes
- PushChanges handler now skips save when server version is newer
- Client PushChanges/pushQueuedChanges collect and report marshal errors
  instead of silently dropping them
- De-duplicate getLocalChanges/getLastSyncTime into exported sync
  package functions
- Fix logConflict winner detection via pointer identity instead of
  fragile UUID+timestamp comparison
- Fix sync down to actually parse, save, and tag-sync pulled changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 01:11:04 +01:00
joakim 0e3750e755 fix: resolve all 15 svelte-check type errors
- Type headers as Record<string, string> in apiRequest (client.js)
- Annotate SyncResult on result object, cast catch vars to any (sync.js)
- Widen sync.push param to Partial<Task>[] (endpoints.js)
- Fix parse() return type to reflect {task?: Task} shape (endpoints.js)
- Narrow add() param from Partial<Task> to Task (tasks.js)
- Cast parseAndCreate result to Task (tasks.js)
- Type tasksByProject grouped object as Record<string, Task[]> (tasks.js)

svelte-check now reports 0 errors and 0 warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 01:09:18 +01:00
joakim 8693681660 refactor: clean up opal-web duplication, dead code, and comment noise
- Deduplicate API_BASE (was defined in both client.js and endpoints.js)
- Extract EMPTY_STATE and persist() helper in auth store (DRY)
- Extract updateByUuid() in tasks store, normalize to .map() pattern
- Remove unused getQueueSize(), Select.svelte, and lib/index.js
- Modernize uuid.js to prefer crypto.randomUUID()
- Strip ~60 redundant comments that restated self-evident code

No behavior changes. Build passes, pre-existing type errors unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 01:03:08 +01:00
joakim 41a12fe7a9 fix: human readable timestamps 2026-02-21 00:20:32 +01:00
joakim acab4333a7 Updated interaction between custom CLI syntax and Cobra flags 2026-02-19 18:31:30 +01:00
joakim cd77443a07 Merge branch 'feat/web-tier1-features' 2026-02-19 18:01:46 +01:00
joakim b7e0d434ba fix: restore fly transition on Toast, clean up debug logs
Add fly transition back to Toast component and move cleanup from
onDestroy to onMount return for SSR safety. Remove debug console.logs
from page orchestrator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:47:51 +01:00
joakim 04fa9222d8 test: add comprehensive tests for new UX features and fix ISO date timezone bug
Add 33 new test functions covering annotations, undo system, history
formatting, relative date display, and weekday parsing pipeline. Fix ISO
date parsing to use ParseInLocation instead of Parse to respect the
parser's timezone context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:42:49 +01:00
joakim 5301fbf706 fix: use onMount return for cleanup instead of onDestroy
onDestroy runs during SSR in Svelte 5, causing document reference
errors. The onMount return function only runs on client teardown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:35:18 +01:00
joakim 4b35753fc7 fix: move scroll lock to afterUpdate to avoid SSR document access
The $: reactive block runs during SSR component init. Use afterUpdate
with a mounted guard instead so document is only accessed client-side.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:30:20 +01:00
joakim f5a5323c15 fix: guard BottomSheet document access for SSR compatibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:25:20 +01:00
joakim 0ff0db642a fix: resolve a11y warning on BottomSheet dialog role
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:50:41 +01:00
joakim 24e9883f68 feat: integrate all Tier 1 features in page orchestrator
Wire BottomSheet+TaskDetail, undo Toast, ConfirmDialog for delete,
and start/stop handlers into +page.svelte.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:48:16 +01:00
joakim aa2ca9aec3 feat: add TaskDetail, bidirectional swipe, and active indicator
- SwipeAction: bidirectional with onSwipeRight/onSwipeLeft, dual backgrounds
- TaskItem: onTap for bottom sheet, onStartStop, active border + pill
- TaskDetail: full field layout with inline editing, action buttons
- TaskList: passes onTap and onStartStop through to TaskItem

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:47:39 +01:00
joakim b53e77a8ec feat: add foundational Tier 1 components and store methods
Add generic BottomSheet, Toast, and ConfirmDialog components.
Add startTask/stopTask optimistic methods to tasks store.
Add --color-active-bg/text theme tokens for all three themes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:44:30 +01:00
joakim 07d1a78dfc feat: add uncomplete command to restore completed tasks to pending
Dedicated command that sets status back to pending and clears End time.
Unlike undo, works on any completed task regardless of when it was
completed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:22:51 +01:00
joakim 2fa1316f0d docs: simplify zsh completion instructions to eval in .zshrc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:10:28 +01:00
joakim 3c0d4ee471 fix: use proper zsh/bash completion methods and correct zsh install instructions
Use GenZshCompletion (native zsh) instead of the old bash-wrapper method.
Use GenBashCompletionV2 for modern bash completions. Fix help text to show
proper fpath-based zsh installation instead of `source`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:08:27 +01:00
joakim feb5406077 feat: add shell completions, command grouping, and dynamic completions
Add completion command for bash/zsh/fish/powershell generation. Organize
help text using Cobra command groups (Task Commands, Reports, Other).
Register dynamic ValidArgsFunction on filter-accepting commands to
suggest +tag and project:name completions from the database.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:59:21 +01:00
joakim 32cc05a546 feat: add task history via log command and info integration
Add engine/history.go with GetTaskHistory and diff-style FormatTaskHistory
that compares consecutive change_log entries to show only what changed.
Add cmd/log.go command for full task history. Integrate last 5 history
entries into FormatTaskDetail (info view) as a "Recent Changes" section.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:56:55 +01:00
joakim 7aaaa86a0a feat: add annotations, undo system, and schema updates
Add annotations as JSON column on tasks table with Annotate/Denotate
methods and CLI commands. Add undo system backed by change_log with
lightweight undo_stack table (capped at 10 entries). All mutating CLI
commands (add, done, delete, modify, start, stop) now record undo
entries. Undo restores prior task state from change_log data.

Schema changes (in v1 migration):
- annotations TEXT column on tasks
- undo_stack table
- annotations field in change_log triggers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:54:58 +01:00
joakim 6fb8a40a43 feat: add --dry-run flag to action commands
Adds a persistent --dry-run flag that shows matched tasks without
performing mutations. Supported on done, delete, modify, start, and stop
commands. Also fixes preprocessArgs to skip flag-like args when
identifying commands, preventing flags from being treated as filters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:47:39 +01:00
joakim b02c40f716 feat: improve CLI output with relative dates, rich feedback, and recurring task info
Add relative date formatting (today, tomorrow, in 3d, etc.) for list and
detail views. Add structured feedback helpers for add/complete/delete
operations showing display IDs and parsed modifiers. Change Complete() to
return spawned recurring instance so callers can display recurrence info.
Add AppendTask to working set for immediate display ID assignment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:44:56 +01:00
joakim 779da6ddfd feat: IMP-13 — add version command with build-time variables
opal version (and opal --version) prints version, commit, and build
date. Values are set via ldflags at build time; defaults to "dev" for
local builds. VERSION file added at 0.1.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:38:25 +01:00
joakim f57baee6bc fix: IMP-4/5/6 — parser allowlist, delete ID resolution, consistent errors
IMP-5: Replace strings.Contains(arg, ":") heuristic with an allowlist
of recognized attribute keys (ValidAttributeKeys). Colons in task
descriptions (URLs, "Meeting: topic") are no longer misinterpreted as
modifiers. Canonical key sets live in engine/keys.go and are shared
across parseAddArgs, ParseFilter, and ParseModifier. ParseModifier now
errors on unknown keys.

IMP-4: delete command now loads the working set and resolves display IDs
via GetTaskByDisplayID, matching the pattern used by done/modify.

IMP-6: All action commands (done, delete, modify, start, stop) now
return an error on no-match (stderr, exit 1). Previously done/delete
printed to stdout and exited 0; start/stop had no check at all.

Also adds requirements and design docs for the CLI UX improvements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:37:33 +01:00
joakim a551f50cef ui updates 2026-02-18 23:16:00 +01:00
joakim f05d6e154e gradient gutters 2026-02-17 21:57:34 +01:00
joakim 4dfef88f19 refactor: use Vite built-in DEV flag instead of VITE_OAUTH_ENABLED
import.meta.env.DEV is already true during `bun run dev` and false in
production builds, so a separate env var is unnecessary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:19:34 +01:00
joakim d51c6da18d feat: replace mock mode with real backend dev mode
Add --dev flag to `opal server start` that disables auth (injects
userID=1 for all requests) and exposes a /auth/dev-session endpoint,
so the frontend can develop against a real backend without OAuth
config. Remove VITE_MOCK_MODE and all mock data/branches from the
frontend stores. Add scripts/dev.sh to start both services locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:07:34 +01:00
joakim 80ea17227d fix: prevent nil-panic on server and improve OAuth callback handling
Load config eagerly during server startup so sortByUrgency never
hits a nil config. Add nil-guard in BuildUrgencyCoefficients as
belt-and-suspenders defense. Fix OAuth callback to support both
GET and POST, and resolve issuer URLs properly with path.Dir.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:40:53 +01:00
joakim c5a963bfd9 fix: make LoadConfig read-only to prevent panic on read-only filesystems
LoadConfig() tried to create directories and write opal.yml as a side
effect of loading config. On the server (where /etc/opal is in systemd
ReadOnlyPaths), this failed, returning nil. All internal GetConfig()
callers discarded the error, passing nil to BuildUrgencyCoefficients()
which panicked on nil dereference.

Redesign the config system with layered, read-only loading:
- Defaults (always present) → YAML file (if exists) → OPAL_ env vars
- LoadConfig never writes to the filesystem or returns nil
- File creation moved to explicit InitConfig() for CLI first-run/setup
- SaveConfig uses yaml.Marshal instead of manual field-by-field Viper
  calls, eliminating the three-place maintenance burden

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 00:04:54 +01:00
joakim b3c30738bd fix(web): minor UI refinements across header, pills, swipe, and settings
- Remove ThemeSwitcher from header (already accessible via settings)
- Increase pill padding and font size for better tap targets
- Guard non-cancelable touchmove preventDefault in SwipeAction
- Restyle settings page with grid-area layout and inline sign-out button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:59:58 +01:00
joakim 3bb2ef2759 feat: add JSON serialization, urgency field, and snake_case API contract
Fix latent API bug where multi-word fields (RecurrenceDuration, ParentUUID,
CreatedAt) serialized as PascalCase, breaking the frontend. Add explicit
snake_case json tags and custom MarshalJSON/UnmarshalJSON on Task, Status,
and APIKey to emit unix timestamps and string status codes.

Add Urgency float64 as a derived field on Task, populated via
PopulateUrgency helper in all handlers before serialization. The report
engine's sortByUrgency now also retains the computed score.

Frontend updated with urgency type, color-coded badge in TaskItem, and
mock data values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:58:34 +01:00
joakim 924b66bc64 docs: add opal-task REST API reference
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:58:01 +01:00
joakim d86501e4e6 feat(web): use CSS grid-areas layout with anchor-positioned report picker
Replace flexbox layout with CSS grid using named grid-areas for responsive
content containment. Gutters collapse naturally on small screens via
min(--content-max-width, 100%). Anchor ReportPicker to its trigger button
using CSS anchor positioning instead of fixed viewport offsets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:08:41 +01:00
joakim 78881e1b07 feat: add parse endpoint, refactor recurring tasks, and improve web task completion
Extract CreateRecurringTask into engine package for reuse by both CLI
and API. Add POST /tasks/parse endpoint for CLI-style input parsing.
Remove FK constraint on change_log to preserve history after task
deletion. Update web frontend to filter completed tasks from view and
add mock mode support for development.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:49:20 +01:00
joakim 0352c22b4f feat(web): add theme system with Obsidian, Paper, and Midnight themes
Three holistic design directions with CSS custom properties, a theme
store persisted to localStorage, and a live switcher in both the header
(cycle button) and settings page (card selector). Also fixes checkbox
checkmark alignment and adds back navigation from settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 22:36:07 +01:00
joakim 6c2fc6960a feat(web): add fade-out animation for checkbox task completion
When a task is completed via checkbox tap, it fades out and collapses
before being removed from the list, matching the swipe-to-complete
animation behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:41:28 +01:00
joakim 5e829320cf feat(web): rewrite home page as single-screen CLI-passthrough orchestrator
Replace multi-page task management with single-screen layout: Header
with report picker at top, scrollable TaskList in the middle, and
InputBar with property pills fixed at the bottom. Owns state for
active report, task loading, input parsing, and task completion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:35:07 +01:00
joakim a6cd0ea41d feat(web): update TaskItem and TaskList for single-screen design
TaskItem: remove onClick navigation, wrap in SwipeAction for
swipe-to-complete, update priority colors (H=red, M=amber, L=gray,
default=hidden), add due-today amber color.

TaskList: accept activeReport prop for context-aware empty states,
replace onToggle/onTaskClick with onComplete, make scrollable with
flex:1 and overflow-y:auto.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:30:02 +01:00
joakim ac0fd6c72f feat(web): add SwipeAction touch gesture component
Implements right-swipe-to-complete with angle-based lock-in (horizontal
must exceed 2x vertical), 100px threshold, green checkmark background
reveal, and CSS transition for snap-back and completion animation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:29:14 +01:00
joakim 2f83e8fe2f feat(web): add InputBar and PropertyPills components
InputBar provides fixed-to-bottom text input with Enter to submit,
blur-delay (150ms) for pill interaction, and cursor-aware text
insertion. PropertyPills shows 8 modifier pills (Due, Pri, Project,
Tag, Recur, Scheduled, Wait, Until) on input focus.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:28:48 +01:00