notion: per-project Notion task integration with auto-session pickup#100
Open
mattmoran56 wants to merge 2 commits into
Open
notion: per-project Notion task integration with auto-session pickup#100mattmoran56 wants to merge 2 commits into
mattmoran56 wants to merge 2 commits into
Conversation
…asks
Per-project integration that:
- polls a configured Notion database every 5s from a main-process service
- applies user-configured "on pickup" property updates and optional markdown
blocks to each picked-up page (with placeholder substitution for
{{taskUrl}}, {{taskTitle}}, {{taskTitleSlug}}, {{taskId}}, {{branch}},
{{sessionId}})
- fires an IPC event to the renderer for each new task, which creates a
session with a resolved startup prompt typed into the agent terminal
- dedups via a per-project picked-up cache (capped at 1000 ids)
- re-reads config from disk on every tick so the JSON file can be edited
externally without an app restart
Settings UI lives next to Session Startup Prompts. Includes a Test
connection button, a filter / property-update builder backed by the live
DB schema, a backfill toggle for the first-enable seed pass, and two
copy-pasteable prompts ("create a new DB" / "use my existing DB") that
hand off setup to a Claude (or other) coding agent with the Notion MCP
plus filesystem tools — Crucible injects the absolute config file path so
the agent can edit it directly.
https://claude.ai/code/session_017PpnJd3iQ5Bz5mWpCYMD9a
Co-authored-by: Matt Moran <79716720+mattmoran56@users.noreply.github.com>
Tests added across all three tiers: - Unit: notion-poller.service (tick, dedup cache, MAX_FIRES_PER_TICK cap, immediate-vs-deferred update split, write-back, disabled projects); notionStore (load, save with backfill, testConnection, loadSchema, clearPickedUp, configPath caching). - Integration (vitest + jsdom): useNotionBootstrap drives session creation + applyWriteBack from a fired NOTION_FIRE_TASK, including cross-project safety and error toasting. - E2E (Playwright + mock backend): the settings panel renders one card per project, the Configure form persists token/db-id back through the IPC, firing NOTION_FIRE_TASK produces a real session card with the resolved prompt written to the terminal, and the write-back IPC is invoked with the new branch + session id. Storybook stories (Empty / Configured / McpPromptOpen) drive three visual snapshots committed under tests/screenshots/...-snapshots/, which also live under docs/screenshots/ so the PR description can embed them via raw GitHub URLs. Mock backend (mock/mockApi.ts) gained a `notion` namespace plus two test hooks (window.__notionFireTask, window.__notionWriteBackCalls) so the e2e suite can simulate poller-fired tasks deterministically. https://claude.ai/code/session_017PpnJd3iQ5Bz5mWpCYMD9a Co-authored-by: Matt Moran <79716720+mattmoran56@users.noreply.github.com>
56289d3 to
af2cee1
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Per-project Notion integration that polls a configured Notion database every 5s and automatically starts a session for each new matching task, with the task URL (and any other placeholders) typed into the agent terminal as the startup prompt.
notion-poller.service.ts) re-reads config from disk on every tick so the MCP-driven path (agent edits the JSON file directly) takes effect within 5s, no restart needed. Splits property updates into an immediate pass (dedup-critical, e.g.Status → In Progress) and a deferred pass that runs after the renderer creates the session, so{{branch}}/{{sessionId}}placeholders can be resolved.<DB NAME>). Crucible injects the absolute config file path and project id at copy time so the agent can edit the JSON directly.Screenshots
Empty (default landing — three projects, none configured)
Configured (form expanded for one project)
MCP setup prompts open (two copy buttons)
Tests
Wrapped at unit, integration, and e2e tiers — full suite passes (558 unit tests, 36 e2e tests, all snapshots green).
tests/unit/main/notion.service.test.ts(14): placeholder resolution, slugify, session-placeholder detection, DB-id URL normalization.tests/unit/main/notion-poller.service.test.ts(10): tick behaviour, dedup cache, MAX_FIRES_PER_TICK cap, immediate-vs-deferred update split, write-back (property + appended blocks), disabled-project short-circuit.tests/unit/stores/notionStore.test.ts(12): load/save (with backfill option), testConnection, loadSchema, clearPickedUp, configPath caching, error toasting.tests/unit/hooks/useNotionBootstrap.test.tsx(6): hook subscribes/unsubscribes correctly, createSession is invoked with the right repo + name + resolved prompt, applyWriteBack is called with the resulting branch + session id, cross-project safety, error path.tests/e2e/notion.spec.ts, 4 tests): Settings UI renders one card per project; Configure form persists token + DB id back through the IPC; firingNOTION_FIRE_TASKproduces a real session card with the resolved prompt written to the agent terminal;applyWriteBackis called with branch + session id.Empty,Configured,McpPromptOpen) wired intotests/screenshots/storybook.spec.ts. Snapshots committed attests/screenshots/storybook.spec.ts-snapshots/notion-settings-*.png.Test plan
npx vitest run— 558 unit tests pass (28 new for Notion)npx playwright test --project=e2e— 36 e2e tests pass (4 new for Notion)npx playwright test --project=screenshots -g notion-settings— 3 snapshots stable on re-runelectron-vite build— full build succeedsGenerated by Claude Code