Skip to content

notion: per-project Notion task integration with auto-session pickup#100

Open
mattmoran56 wants to merge 2 commits into
mainfrom
claude/notion-task-integration-S7imK
Open

notion: per-project Notion task integration with auto-session pickup#100
mattmoran56 wants to merge 2 commits into
mainfrom
claude/notion-task-integration-S7imK

Conversation

@mattmoran56
Copy link
Copy Markdown
Owner

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.

  • Main-process poller (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.
  • Per-project settings UI with on/off toggle, token, DB id (auto-strips Notion URLs), Test connection, schema-driven filter + property-update builders, append markdown, startup prompt template, branch name template, backfill checkbox, and clear-cache button.
  • Copy-paste MCP setup prompts — two variants, "Create a new database" and "Use my existing database" (user substitutes <DB NAME>). Crucible injects the absolute config file path and project id at copy time so the agent can edit the JSON directly.
  • Local picked-up cache (capped at 1000 ids/project) for dedup; per-project seed on first enable so the user's existing backlog isn't dumped into new sessions unless they opt in via the backfill checkbox.

Screenshots

Empty (default landing — three projects, none configured)

Notion settings — empty

Configured (form expanded for one project)

Notion settings — configured

MCP setup prompts open (two copy buttons)

Notion settings — MCP prompt

Tests

Wrapped at unit, integration, and e2e tiers — full suite passes (558 unit tests, 36 e2e tests, all snapshots green).

  • Unittests/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.
  • Integrationtests/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.
  • E2E (Playwright + mock backend, tests/e2e/notion.spec.ts, 4 tests): Settings UI renders one card per project; 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 agent terminal; applyWriteBack is called with branch + session id.
  • Screenshot regression — three Storybook stories (Empty, Configured, McpPromptOpen) wired into tests/screenshots/storybook.spec.ts. Snapshots committed at tests/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-run
  • electron-vite build — full build succeeds
  • Manual verification against a real Notion DB (not possible from the test container — node-pty native rebuild fails without system build tools)

Generated by Claude Code

claude and others added 2 commits May 20, 2026 14:16
…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>
@mattmoran56 mattmoran56 force-pushed the claude/notion-task-integration-S7imK branch from 56289d3 to af2cee1 Compare May 20, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants