refactor(meta): move to a feature structure#20
Merged
Conversation
- 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)
- 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
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.
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
github.content/togrody.content/FeatureDefinitioncontract andPageContexttypes insrc/lib/feature-types.tspage-context.tswith URL parsing and route predicates (isActionsPage,isRepoPage, etc.)feature-manager.ts— lifecycle engine with include/exclude predicates, per-feature AbortControllers, error isolation, and SPA navigation reinitimport.meta.glob("./features/*/index.ts")for zero-touch feature registrationfeatures/status-indicator/,features/workflow-filter/)FeatureDefinitionexports with signal-based cleanupTesting Notes
pnpm test— 84 pass, 0 failpnpm check— 0 errorspnpm lint— 0 warningspnpm build— succeeds, outputscontent-scripts/grody.js+grody.csstest-setup.tssuppresses a node-specific quirk where AbortController defers abort listener errors vianextTick(browsers rethrow synchronously). only affects the teardown isolation test.