This repository was archived by the owner on Jul 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
fix: use local dates to fix timezone handling + add This Week preset #13
Open
ahanel13
wants to merge
3
commits into
dougcooper:main
Choose a base branch
from
ahanel13:fix-timezone-this-week-preset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+183
−28
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| npm test # Run tests once (Vitest + JSDOM) | ||
| npm run test:watch # Run tests in watch mode | ||
| npm run test:coverage # Generate v8 coverage report | ||
| npm run check:syntax # Validate JS syntax via Acorn (extracts <script> from index.html) | ||
| npm run build:min # Minify HTML/CSS/JS into build/sp-dashboard/ | ||
| npm run screenshot # Regenerate assets/ screenshots via Puppeteer | ||
| make build # Full plugin build → sp-dashboard.zip | ||
| make release-check # Verify prerequisites before releasing (clean state, tag, gh CLI) | ||
| make release # Tag, push, create GitHub release (requires clean git state + gh CLI) | ||
| make clean # Remove generated files | ||
| ``` | ||
|
|
||
| To run a single test: `npx vitest run --reporter=verbose tests/index.test.js -t "test name pattern"` | ||
|
|
||
| ## Architecture | ||
|
|
||
| This is a **Super Productivity plugin** — a sandboxed iframe widget. All UI logic must live in `sp-dashboard/index.html` as a self-contained file (embedded CSS + JS, no external runtime dependencies). | ||
|
|
||
| ### Two-file plugin model | ||
|
|
||
| - **`sp-dashboard/plugin.js`** — runs in the host app context. Registers an ACTION Redux hook with `PluginAPI.addEventListener`, then fires a `postMessage` to the iframe on every state change. This is the only bridge between the host app and the UI. | ||
| - **`sp-dashboard/index.html`** — runs in an isolated iframe. Receives `SP_STATE_CHANGED` messages and pulls fresh data via `PluginAPI.getTasks()` / `getArchivedTasks()` / `getAllProjects()`. All rendering, state, and logic lives here. | ||
|
|
||
| Available PluginAPI methods (beyond data fetching): `showSnack({ msg, ico })` for toast notifications, `getStorage()` / `setStorage(data)` for persistence (declared in manifest but currently unused). | ||
|
|
||
| ### Data flow inside index.html | ||
|
|
||
| ``` | ||
| postMessage → loadData() → PluginAPI calls → cachedTasks / cachedProjects | ||
| → processData(tasks, projects, dateRange) → metrics object | ||
| → updateDashboardUI() (stat cards) | ||
| → updateBarChart() (weekly time, CSS flex bars) | ||
| → updatePieChart() (project breakdown, CSS conic-gradient) | ||
| → renderTable() (detailed entries, sortable) | ||
| ``` | ||
|
|
||
| `processData()` is the core aggregation function. It deduplicates active + archived tasks (Map by ID, active takes precedence), filters by date range, and computes: time spent, completion counts, overdue/late flags, per-day breakdowns, and per-project summaries. | ||
|
|
||
| ### Mock data fallback | ||
|
|
||
| If `PluginAPI` is unavailable (standalone file:// development), a 500ms timeout injects mock data so the full UI renders without the host app. | ||
|
|
||
| ### Charts | ||
|
|
||
| No charting library. Bar chart uses CSS flexbox with `height` set as a percentage of max value; it automatically buckets data when the date range exceeds 30 days. Pie/donut chart uses a single `<div>` with `conic-gradient` computed from cumulative percentages. | ||
|
|
||
| ### Theming | ||
|
|
||
| All colors are CSS custom properties (`--bg`, `--text-color`, `--c-primary`, etc.). Dark mode is toggled by `.dark-theme` on `<body>` — mirroring the host app's class injection. | ||
|
|
||
| ### Build pipeline | ||
|
|
||
| `make build` runs: template substitution on `manifest.json.template` (injects VERSION/DESCRIPTION) → `scripts/minify.sh` (html-minifier-terser) → zip packaging. Version is the single source of truth in `package.json`. | ||
|
|
||
| ## Testing | ||
|
|
||
| Tests live in `tests/index.test.js` and use Vitest with a JSDOM environment. The test harness sets `document.documentElement.innerHTML = html`, then executes the `<script>` block via `new Function()` — this means **any function you want to test must be explicitly assigned to `window`** inside the script (e.g. `window.processData = processData`). Mock `PluginAPI` is injected via `global.PluginAPI` before each test. | ||
|
|
||
| ## Key constraints | ||
|
|
||
| - Keep `index.html` self-contained — no `import` statements, no external CDN links, no `require()`. | ||
| - All user-visible strings in the UI must be sanitized before insertion into the DOM (use `textContent`, not `innerHTML`, for any data-derived content). | ||
| - Plugin permissions are declared in `manifest.json.template`; `persistDataSynced` / `loadSyncedData` are declared but currently unused. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.