Skip to content

refactor(meta): move to a feature structure#20

Merged
cheefbird merged 8 commits into
mainfrom
refactor/refactor-feature-structure
Mar 15, 2026
Merged

refactor(meta): move to a feature structure#20
cheefbird merged 8 commits into
mainfrom
refactor/refactor-feature-structure

Conversation

@cheefbird
Copy link
Copy Markdown
Owner

@cheefbird cheefbird commented Mar 15, 2026

Context

I figured I should refactor NOW rather than later for easier feature adding. The old pattern (manual imports in the entry point, no error isolation, components scattered at the content script root) doesn't scale.

this refactor introduces a feature manager with auto-discovery so adding a feature is just "create a directory with an index.ts."

Changes Made

  • rename github.content/ to grody.content/
  • add FeatureDefinition contract and PageContext types in src/lib/feature-types.ts
  • add page-context.ts with URL parsing and route predicates (isActionsPage, isRepoPage, etc.)
  • add feature-manager.ts — lifecycle engine with include/exclude predicates, per-feature AbortControllers, error isolation, and SPA navigation reinit
  • entry point uses import.meta.glob("./features/*/index.ts") for zero-touch feature registration
  • co-locate svelte components inside their feature directories (features/status-indicator/, features/workflow-filter/)
  • rewrite both features as typed FeatureDefinition exports with signal-based cleanup
  • 32 new tests (19 page-context + 13 feature-manager), 84 total passing
  • updated README

Testing Notes

  • pnpm test — 84 pass, 0 fail
  • pnpm check — 0 errors
  • pnpm lint — 0 warnings
  • pnpm build — succeeds, outputs content-scripts/grody.js + grody.css
  • test-setup.ts suppresses a node-specific quirk where AbortController defers abort listener errors via nextTick (browsers rethrow synchronously). only affects the teardown isolation test.

- add FeatureDefinition and PageContext types in src/lib/feature-types.ts
- rename github.content to grody.content entry point
- add page-context module with URL parsing and route predicates
- add 19 tests for buildPageContext and all predicates
- include/exclude predicates, per-feature AbortControllers, SPA nav reinit
- teardown wraps abort() in try/catch so one feature can't break others
- 13 tests for run, onNavigate, invalidation, teardown isolation
- test-setup handles node deferring abort listener errors via nextTick
- co-locate svelte components inside their feature directories
- rewrite feature init files as typed FeatureDefinition exports
- entry point uses import.meta.glob for zero-touch feature registration
- remove redundant try/catch around unmount in feature abort handlers
- delete old workflow-filter.test.ts (migrated to page-context)
@cheefbird cheefbird self-assigned this Mar 15, 2026
- scope test-setup handler to only suppress "teardown boom" by message
- add [grody] prefix to onNavigate catch for log attribution
- add null guard on workflow-filter unmount to match status-indicator pattern
- add dev-only duplicate feature ID detection in feature manager
- remove location fallback from production code, stub in tests instead
@cheefbird cheefbird merged commit 99648b8 into main Mar 15, 2026
4 checks passed
@cheefbird cheefbird deleted the refactor/refactor-feature-structure branch March 15, 2026 06:04
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.

1 participant