Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
390ecc4
Start backend
fireheartjerry Aug 14, 2025
e519298
fix: normalize settings layout and overflow
fireheartjerry Aug 14, 2025
733af2b
Merge pull request #34 from fireheartjerry/codex/develop-intervention…
fireheartjerry Aug 14, 2025
c98d815
bug fix on block groups page
Jerrychenjikai Aug 15, 2025
4cb81c4
Some fixes and edits
fireheartjerry Aug 16, 2025
1964f59
feat: seed extension with curated default data
fireheartjerry Aug 16, 2025
2eda97a
Merge pull request #35 from fireheartjerry/codex/create-unified-stora…
fireheartjerry Aug 16, 2025
b734676
update agents.md
fireheartjerry Aug 16, 2025
e26c3e2
feat: add structured logging and tab decision test
fireheartjerry Aug 17, 2025
00a32df
Add overlay unmount and cancel handling
fireheartjerry Aug 17, 2025
c53bbe3
feat: add theme options and overlay theming
fireheartjerry Aug 17, 2025
e43d787
Handle messaging errors
fireheartjerry Aug 17, 2025
e17a395
Add URL and hash change handling
fireheartjerry Aug 17, 2025
c6e8ff9
Compute safe overlay z-index
fireheartjerry Aug 17, 2025
25b05ee
docs: document interventions registry
fireheartjerry Aug 17, 2025
f9b8de1
docs: document interventions registry
fireheartjerry Aug 17, 2025
cb38fb3
test: add intervention engine coverage
fireheartjerry Aug 17, 2025
0b7c13a
Specify early content script load
fireheartjerry Aug 17, 2025
ae42982
Namespace intervention overlay classes
fireheartjerry Aug 17, 2025
6507706
Add overlay cleanup handlers for page lifecycle
fireheartjerry Aug 17, 2025
5d9003e
refactor: centralize messaging constants
fireheartjerry Aug 17, 2025
6aac0da
Add Escape key overlay teardown
fireheartjerry Aug 17, 2025
8abed88
Track and enforce time allowances
fireheartjerry Aug 17, 2025
14d4605
Handle SPA history navigation
fireheartjerry Aug 17, 2025
1789413
Add accessibility focus trapping to overlay
fireheartjerry Aug 17, 2025
3a52518
Use shadow DOM for overlay
fireheartjerry Aug 17, 2025
e05466c
feat: handle unimplemented time allowance
fireheartjerry Aug 17, 2025
5d746a4
test: add intervention engine coverage
fireheartjerry Aug 17, 2025
fa687c7
Merge pull request #55 from fireheartjerry/codex/add-tests-for-select…
fireheartjerry Aug 17, 2025
f15c91d
Merge pull request #54 from fireheartjerry/codex/add-overlay-message-…
fireheartjerry Aug 17, 2025
7f1de67
Merge pull request #53 from fireheartjerry/codex/refactor-createoverl…
fireheartjerry Aug 17, 2025
2827c9b
Merge branch 'main' into codex/enhance-time-allowance-handling
fireheartjerry Aug 17, 2025
765712c
Merge pull request #51 from fireheartjerry/codex/enhance-time-allowan…
fireheartjerry Aug 17, 2025
82dcf2b
Merge pull request #52 from fireheartjerry/codex/add-webnavigation-li…
fireheartjerry Aug 17, 2025
104303e
Merge branch 'main' into codex/add-keydown-event-listener-for-escape-key
fireheartjerry Aug 17, 2025
b2fd420
Merge pull request #49 from fireheartjerry/codex/add-keydown-event-li…
fireheartjerry Aug 17, 2025
d730df7
Merge branch 'main' into codex/enhance-accessibility-of-overlay-compo…
fireheartjerry Aug 17, 2025
ddac475
Merge branch 'main' into codex/create-messaging-constants-file-and-re…
fireheartjerry Aug 17, 2025
2b6a6d2
Merge pull request #48 from fireheartjerry/codex/create-messaging-con…
fireheartjerry Aug 17, 2025
e2ca1bf
Merge branch 'main' into codex/register-and-cleanup-event-handlers-in…
fireheartjerry Aug 17, 2025
be32f86
Merge pull request #47 from fireheartjerry/codex/register-and-cleanup…
fireheartjerry Aug 17, 2025
120a193
Merge branch 'main' into codex/update-manifest.json-run_at-property
fireheartjerry Aug 17, 2025
13ae58c
Merge pull request #46 from fireheartjerry/codex/update-manifest.json…
fireheartjerry Aug 17, 2025
c0d0119
Merge branch 'main' into codex/update-class-names-in-overlay-markup
fireheartjerry Aug 17, 2025
58cc734
Merge pull request #45 from fireheartjerry/codex/update-class-names-i…
fireheartjerry Aug 17, 2025
e2db359
Merge pull request #44 from fireheartjerry/codex/create-interventions…
fireheartjerry Aug 17, 2025
27fa92c
Merge pull request #43 from fireheartjerry/codex/add-tests-for-select…
fireheartjerry Aug 17, 2025
c3ecaba
Merge pull request #42 from fireheartjerry/codex/create-interventions…
fireheartjerry Aug 17, 2025
931e37f
Merge pull request #41 from fireheartjerry/codex/compute-safe-z-index…
fireheartjerry Aug 17, 2025
1a5bbf0
Merge branch 'main' into codex/add-listeners-for-tab-updates-and-hash…
fireheartjerry Aug 17, 2025
8e7a087
Merge pull request #40 from fireheartjerry/codex/add-listeners-for-ta…
fireheartjerry Aug 17, 2025
0c8d933
Merge branch 'main' into codex/wrap-messaging-calls-with-error-handling
fireheartjerry Aug 17, 2025
1a0c445
Merge pull request #39 from fireheartjerry/codex/wrap-messaging-calls…
fireheartjerry Aug 17, 2025
44bf8fd
Merge branch 'main' into codex/define-and-implement-theme-settings
fireheartjerry Aug 17, 2025
0081a04
Merge pull request #38 from fireheartjerry/codex/define-and-implement…
fireheartjerry Aug 17, 2025
cc91db9
Merge branch 'main' into codex/implement-unmountoverlay-and-cancel-in…
fireheartjerry Aug 17, 2025
a776653
Merge pull request #37 from fireheartjerry/codex/implement-unmountove…
fireheartjerry Aug 17, 2025
ab1b338
Merge branch 'main' into codex/nirvanify-background-logic-context-ove…
fireheartjerry Aug 17, 2025
34da6cb
Merge pull request #36 from fireheartjerry/codex/nirvanify-background…
fireheartjerry Aug 17, 2025
58a6808
Merge branch 'main' into codex/enhance-accessibility-of-overlay-compo…
fireheartjerry Aug 17, 2025
0cacab2
Merge pull request #50 from fireheartjerry/codex/enhance-accessibilit…
fireheartjerry Aug 17, 2025
30e6535
Use messaging constants in content script
fireheartjerry Aug 17, 2025
fc80255
Use settings manager for intervention persistence
fireheartjerry Aug 17, 2025
cda2610
feat: add intervention migration
fireheartjerry Aug 17, 2025
8e59262
refactor: unify intervention storage
fireheartjerry Aug 17, 2025
74a59b9
fix: load storage keys in content script
fireheartjerry Aug 17, 2025
b21bf7a
refactor intervention storage usage
fireheartjerry Aug 17, 2025
be5de83
Merge pull request #59 from fireheartjerry/codex/implement-migration-…
fireheartjerry Aug 17, 2025
b9ed177
Merge branch 'main' into codex/refactor-intervention-storage-functions
fireheartjerry Aug 17, 2025
3846c5a
Merge pull request #60 from fireheartjerry/codex/refactor-interventio…
fireheartjerry Aug 17, 2025
b185407
Merge pull request #58 from fireheartjerry/codex/update-intervention-…
fireheartjerry Aug 17, 2025
3123119
Merge branch 'main' into codex/consolidate-intervention-storage-module
fireheartjerry Aug 17, 2025
ce600a5
Merge pull request #57 from fireheartjerry/codex/consolidate-interven…
fireheartjerry Aug 17, 2025
c76e78e
Merge pull request #61 from fireheartjerry/codex/update-dynamic-impor…
fireheartjerry Aug 17, 2025
94996fe
Merge pull request #56 from fireheartjerry/codex/refactor-message-act…
fireheartjerry Aug 17, 2025
a01ba35
A bunch of bug fixes
fireheartjerry Aug 17, 2025
e5a421f
syntax fixes in content.js
Jerrychenjikai Aug 17, 2025
056f7ef
feat: add focus micro-interactions
fireheartjerry Aug 17, 2025
72d9fdf
Test recording intervention completions without ID
fireheartjerry Aug 17, 2025
a65d2fe
Refactor overlay to use shadow DOM
fireheartjerry Aug 17, 2025
a392720
feat: track active intervals
fireheartjerry Aug 17, 2025
344867d
Fix intervention state backup iteration
fireheartjerry Aug 17, 2025
243864a
Merge pull request #62 from fireheartjerry/codex/perform-exhaustive-f…
fireheartjerry Aug 17, 2025
cb3dfa4
Merge pull request #63 from fireheartjerry/codex/decide-and-implement…
fireheartjerry Aug 17, 2025
9116629
Merge branch 'main' into codex/update-overlays-to-use-shadow-dom
fireheartjerry Aug 17, 2025
a3e4169
Merge pull request #64 from fireheartjerry/codex/update-overlays-to-u…
fireheartjerry Aug 17, 2025
c1ab2e8
Merge branch 'main' into codex/add-activeintervals-set-to-content.js
fireheartjerry Aug 17, 2025
93a3c3e
Merge pull request #65 from fireheartjerry/codex/add-activeintervals-…
fireheartjerry Aug 17, 2025
55c9e81
Merge pull request #66 from fireheartjerry/codex/refactor-backupcurre…
fireheartjerry Aug 17, 2025
39e3d39
Add basic intervention storage helper
fireheartjerry Aug 17, 2025
32a66fc
Merge pull request #67 from fireheartjerry/codex/fix-typeerror-in-mul…
fireheartjerry Aug 17, 2025
db6d43a
add session feature
fireheartjerry Aug 17, 2025
45ce143
Merge branch 'main' of https://github.com/fireheartjerry/Nirvanify
fireheartjerry Aug 17, 2025
df6e045
make shadowroots open
fireheartjerry Aug 17, 2025
15d914a
Some updates
fireheartjerry Aug 17, 2025
b7c3e18
fix: handle intervention state structure in session backup
fireheartjerry Aug 17, 2025
fe0e049
fix: externalize debugging script to satisfy CSP
fireheartjerry Aug 17, 2025
2b43f64
Ensure background message handler is ready
fireheartjerry Aug 17, 2025
d400bd9
Merge pull request #70 from fireheartjerry/codex/fix-background-scrip…
fireheartjerry Aug 17, 2025
85534a3
Merge pull request #69 from fireheartjerry/codex/fix-content-security…
fireheartjerry Aug 17, 2025
e7cb297
Merge pull request #68 from fireheartjerry/codex/fix-typeerror-in-bac…
fireheartjerry Aug 17, 2025
181d16d
Some updates
fireheartjerry Aug 17, 2025
af59517
Merge branch 'main' of https://github.com/fireheartjerry/Nirvanify
fireheartjerry Aug 17, 2025
b60bfec
fix: load dashboard study session styles
fireheartjerry Aug 17, 2025
75ae1f6
minor bug fixes
Jerrychenjikai Aug 18, 2025
5d62bf4
minor bug fixes
Jerrychenjikai Aug 18, 2025
627a6d1
fixed some conflicts
Jerrychenjikai Aug 18, 2025
a88582a
fixed parenthesis mismatch
Jerrychenjikai Aug 18, 2025
2ed9082
more parenthesis mismatch
Jerrychenjikai Aug 18, 2025
541a312
minor changes
Jerrychenjikai Aug 18, 2025
5dc91b0
Some more edits
fireheartjerry Aug 19, 2025
c9f8c83
Merge branch 'main' of https://github.com/fireheartjerry/Nirvanify
fireheartjerry Aug 19, 2025
361a2be
Handle reset failures in display prefs
fireheartjerry Aug 19, 2025
1b7d05f
Stabilize display preference updates
fireheartjerry Aug 19, 2025
e283051
Merge pull request #72 from fireheartjerry/codex/prepare-for-multiple…
fireheartjerry Aug 19, 2025
346dca1
Merge pull request #71 from fireheartjerry/codex/fix-study-session-wi…
fireheartjerry Aug 19, 2025
121f7fc
Merge branch 'main' into codex/fix-multiple-warnings-and-errors
fireheartjerry Aug 19, 2025
c854d44
Merge pull request #73 from fireheartjerry/codex/fix-multiple-warning…
fireheartjerry Aug 19, 2025
6f597f4
Update stuff
fireheartjerry Aug 19, 2025
3eb031c
MOve stuff around
fireheartjerry Aug 19, 2025
7489aa0
some updates
fireheartjerry Aug 19, 2025
ba6a70e
A bunch of edits
fireheartjerry Aug 19, 2025
19378dc
Some more updates
fireheartjerry Aug 19, 2025
e76a5df
More fixes
fireheartjerry Aug 19, 2025
85b6b9d
feat: auto refresh stats and disable refresh during load
fireheartjerry Aug 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
*.log
npm-debug.log*
_metadata

# Build artifacts
*.zip
151 changes: 37 additions & 114 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,37 @@
# AGENTS Operational Manual

## Introduction
Nirvanify is a Manifest V3 Chrome extension focused on reducing digital distractions and tracking study habits. The codebase is modular and uses Web Components for all UI pieces. This document serves as the onboarding guide for future AI agents working on the project.

## Repository Overview
```
Nirvanify/
├── manifest.json # Extension configuration
├── index.html # SPA entry point with router outlet
├── components/ # All Web Component modules
│ ├── app.js # Registers components and initializes router
│ ├── router.js # Hash based router
│ ├── sidebar.js # Main navigation sidebar
│ ├── pages/ # Page level components loaded by router
│ ├── blocklist/ # Blocklist widgets used on blocklist page
│ ├── sessions/ # Session editor and list components
│ ├── dashboard/ # Dashboard widgets (analytics, stats, etc.)
│ ├── challenge/ # Placeholder for single challenge page
│ ├── challenges/ # Listing of all challenges
│ ├── interventions/ # Interventions management page
│ ├── stats/ # Statistics page component
│ ├── timer/ # Timer settings page component
│ └── storage/ # Sync storage utilities
├── css/ # Global stylesheets
├── assets/ # Images and icons
├── lib/ # Third‑party libraries (katex, purify, etc.)
└── verify_extension.py # Optional validation script
```

### Major Page Components
- **Dashboard (`#/dashboard`)** – Shows analytics widgets, streak tracker and session overview.
- **Block Groups (`#/blocklist`)** – Customizes website block sets with schedules, time limits and interventions.
- **Interventions (`#/interventions`)** – Manages challenge types presented when accessing blocked sites.
- **Study Sessions (`#/sessions`)** – Allows creation and editing of focus session templates (e.g., Pomodoro).
- **Challenges (`#/challenges`)** – Placeholder listing for various mini‑challenges.
- **Timer Settings (`#/timer`)** – Configures study timer behavior.
- **Statistics (`#/stats`)** – Displays historical usage stats (currently mocked).
- **Settings (`#/settings`)** – General extension settings.

The router defined in `components/router.js` listens to `hashchange` events and injects the appropriate page element into `<main id="app-view">` inside `index.html`.

## Component Architecture
All UI is built with the Custom Elements API. Each component resides in the `components/` directory or one of its subfolders. Components should encapsulate their markup and styles using the Shadow DOM and expose data via attributes or custom events. Reusable widgets (e.g., blocklist editors, timer controls) are placed directly under `components/`, whereas page-level views live under `components/pages/`.

## Storage Layer
All persistent state lives in Chrome Sync Storage. The `components/storage/` directory provides wrapper modules so components never call `chrome.storage` directly.

### `blocklist-storage.js`
Handles saving and loading of block groups and related metadata:
- `saveBlockTabs` / `loadBlockTabs`
- `saveSelectedIntervention` / `loadSelectedIntervention`
- `saveBlockGroupMeta` / `loadBlockGroupMeta`
- `saveBlockTimeState` / `loadBlockTimeState`
- `saveAdditionalSettings` / `loadAdditionalSettings`
- `deleteBlockTab`
Blocklist widgets import these helpers to persist user-defined rules and schedules without directly calling the Chrome Storage API.

### `session-storage.js`
Manages study session templates. On first load it creates a set of default sessions using existing block lists. Key functions include:
- `saveSessions` / `loadSessions`
- `saveSession` / `deleteSession`
- `saveBlockSets` / `loadBlockSets`

These utilities are used by `nirva-session-editor` and related components to create, update and remove session templates.

All functions return Promises for easy async/await usage inside components.

## Key Functional Flows
### Blocklist Customization
1. **`nirva-block-group-tabs`** lets users switch between block sets and stores tab meta in sync storage.
2. **`nirva-block-site-list`**, **`nirva-block-time-selector`**, **`nirva-hourly-allowance`**, **`nirva-intervention-type`** and **`nirva-additional-settings`** collect rules for the active tab.
3. `components/pages/blocklist-page.js` aggregates these widgets and persists changes via the storage utilities when the user clicks "Save Changes".

### Study Session UI
1. The sessions page contains **`nirva-sessions-list`** (left column) and **`nirva-session-editor`** (right column).
2. `nirva-sessions-list` loads all sessions on connect and exposes events when a session is selected or created.
3. `nirva-session-editor` loads the selected session for editing and saves/deletes/duplicates sessions through `session-storage.js`.

### Dashboard and Timer
- **Dashboard widgets** such as `nirva-study-session`, `nirva-sessions`, `nirva-analytics`, `nirva-past-sessions`, `nirva-full-stats` and `nirva-streak` show timer controls and usage statistics. Most data is placeholder but wired for future analytics modules.
- **Timer** functionality (start, pause, reset) is scaffolded in `dashboard/study-session.js`. The timer page simply provides configuration options.

## Development Notes
- Web Components typically use `attachShadow({mode: 'open'})` for styling isolation. Some widgets use `closed` mode where external access is not needed.
- All pages import shared styles (`css/variables.css`, `css/layout.css`, `css/components.css`) at the start of their templates.
- Components communicate via custom events (e.g., `tab-selected`, `session-saved`), allowing loose coupling.
- The repository does not include a build step. Load the extension directly from this directory when testing.
- An optional validation script (`verify_extension.py`) can be run with `python3 verify_extension.py` if you need to confirm manifest fields.

## Engineering Guidelines
- **Indentation**: Use 4 spaces for all code blocks (HTML, CSS, JavaScript, Python, etc.). Do not use tabs.
- **Naming Conventions**:
- Variables: `like_this`
- Functions: `likeThis`
- JavaScript filenames: `like-this.js`
- Constants: `LIKE_THIS`
- **Modularity**: Keep each file narrowly focused. UI rendering, storage access and routing logic should live in separate modules under `components/` or its subdirectories.
- **Custom Elements**: Register each Web Component with `customElements.define()` inside its own file. Filenames must match the element name using hyphens (e.g., `nirva-session-editor.js`).
Add the file to `components/app.js` so it is imported and registered during initialization.
- **Shadow DOM**: Use `attachShadow({ mode: 'open' })` to encapsulate styles unless the component requires private internals.
- **Documentation**: Every major function or component class should include a short comment block explaining its purpose, expected inputs and outputs and any events it emits.
- **Shared Utilities**: Import storage helpers or other utilities from `components/storage/` rather than accessing Chrome APIs directly.
- **Placement**: New reusable UI widgets belong under `components/` while higher-level views go under `components/pages/`.

## Quick Start for Agents
1. Install dependencies if needed using `npm install`.
2. In Chrome, open `chrome://extensions`, enable Developer Mode and load this folder as an unpacked extension.
3. Navigate to `index.html` in the extension to view the full dashboard.
4. Modify or extend components within `components/` to add features or fix issues. Use the storage utilities to persist new settings.
5. Optionally run `python3 verify_extension.py` if you want to confirm the manifest and required files.

---
This manual reflects the current state of the Nirvanify codebase and should be used as the primary reference for future development tasks.
# Repository Guidelines

## Project Structure & Module Organization
- Entry points: `manifest.json`, `index.html` (router outlet), `components/app.js`.
- UI: Web Components under `components/` (pages in `components/pages/`; widgets in folders like `blocklist/`, `sessions/`, `dashboard/`).
- Data: Storage modules in `storage/` (no direct `chrome.storage` calls), AJV schemas in `schema/`.
- Styles: `css/variables.css`, `css/layout.css`, `css/components.css`.
- Utilities: `components/utils/` and `utils/session-integration.js` (session orchestration).
- Assets and third‑party libs in `assets/` and `lib/`.

## Build, Test, and Development Commands
- `npm install` — install optional dev dependencies.
- `python3 verify_extension.py` — quick manifest/file sanity check.
- Load in Chrome: `chrome://extensions` → enable Developer Mode → “Load unpacked” → select repo folder.

## Coding Style & Naming Conventions
- Indentation: 4 spaces across JS/HTML/CSS/Python.
- Naming: variables `like_this`, functions `likeThis`, constants `LIKE_THIS`, JS files `like-this.js`.
- Custom Elements: filename matches element name; register with `customElements.define()` and import in `components/app.js`.
- Shadow DOM: `attachShadow({ mode: 'open' })` by default.
- Data: validate via `schema/*` before saving; use `storage/*` modules only.
- Events: use `session-*` and descriptive custom events for cross-component comms.

## Testing Guidelines
- No formal test suite. Use manual QA via the loaded extension.
- Smoke checks: navigate to `#/dashboard`, `#/blocklist`, `#/sessions` and verify basic flows.
- Run `python3 verify_extension.py` before PRs to catch manifest/config drift.

## Commit & Pull Request Guidelines
- Prefer Conventional Commits (e.g., `feat:`, `fix:`, `docs:`) with concise, present‑tense subjects.
- PRs: clear description, scope of change, linked issues, screenshots/GIFs for UI, and brief test notes.
- Keep diffs small and focused; avoid unrelated refactors.

## Architecture & Agent Notes
- Data flow: Components ↔ Storage Modules ↔ Chrome Storage; validate with AJV schemas.
- Session workflows integrate block groups and interventions via `utils/session-integration.js`.
- Security: MV3 context—avoid direct HTML injection; use `lib/` sanitizers if rendering user input; minimize permissions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Unreleased

### Fixed
- Router/deep-link refresh blank screen
- Root cause: On app bootstrap, `components/app.js` awaited `customElements.whenDefined()` for every route tag via `Promise.all`. Any route mapping to a tag that wasn't registered (e.g., `nirva-focus-redirect`) caused the promise to never resolve, blocking initial render after a hard refresh or deep-link entry.
- Fix: Render immediately and rely on the router to await only the active route's tag. Also added a placeholder page and registration for `nirva-focus-redirect` to prevent future deadlocks.
- Extra hardening: Session integration is now imported only when running inside an MV3 context to avoid `chrome.*` access in plain web runs and tests.

### Added
- Overrides persistence and UI wiring:
- `components/schema/overrides.schema.js` and storage helpers to load/save overrides.
- `components/settings/overrides-settings.js` now updates storage and toggles background blocking via messaging.
- Timed emergency override (15 minutes) from the Sessions widget, with auto re-enable and persisted state.
- App now applies stored overrides on load (and cleans up expired ones).
- Routing regression test (`tests/router-refresh.test.js`) using Puppeteer when available; gracefully skips on environments without a supported headless browser.

Loading