-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
📋 Summary
Create a VSCode extension that streamlines working with Reflex (or similar pub/sub) event IDs. It should:
- Generate new event/subscription IDs and insert them into the shared
event-ids.ts/sub-ids.tsfiles. - Provide “Go to implementation” navigation:
- From a
dispatch('someId')call jump to the matchingregEvent('someId', …)handler. - From a
useSubscription('someId')call jump to the matchingregSub('someId', …)handler. - From a
regEvent('someId', …)/regSubdeclaration jump to all dispatch/useSubscription points.
- From a
🎯 Goals
- Reduce friction when adding new events or subscriptions.
- Enable one-click navigation between dispatch calls and handler registrations.
- Keep modules decoupled (no need to import handlers into the UI just for navigation).
✍️ User Stories
-
As a developer, when I type
Reflex: Create new event…in the Command Palette, I can enter a new ID ("todos/add") and have:- A new entry appended under
export const EVENT_IDS = { … }insrc/events.ts, and - A stub
regEvent('todos/add', (ctx) => { /* TODO */ })injected intosrc/events.ts(or into a designatedhandlers.ts).
- A new entry appended under
-
As a developer, when I place the cursor on
dispatch('todos/add')and press F12 (Go to Definition), I am taken to the matchingregEvent('todos/add', …)stub. -
As a developer, when I place the cursor on
regEvent('todos/add', …)and press “Find All References”, I see alldispatch('todos/add')anduseSubscription(['todos/add'])usages.
🛠 Technical Requirements
-
Command Palette integration
reflex.createEventId- Prompt: “Enter new event ID”
- Inserts into
src/events.tsunder theEVENT_IDSobject (maintain sorted order or append). - Creates or updates a stub
regEventcall insrc/events.ts(or in a separatehandlers.ts).
-
Definition Provider
- For any string literal argument matching the pattern of a registered ID, hook into VSCode’s Go To Definition to route from
dispatch(id)oruseSubscription([id])to the correspondingregEvent(id, handler)location.
- For any string literal argument matching the pattern of a registered ID, hook into VSCode’s Go To Definition to route from
-
Reference Provider
- From the
regEvent(id, …)location, support “Find All References” to list everydispatch(id, …)anduseSubscription([id])occurrence.
- From the
-
Configuration
- Let users configure:
- Path/glob for their
events.tsandsubscriptions.ts(defaults:src/events.ts,src/subscriptions.ts). - Naming conventions for constants vs plain strings.
- Path/glob for their
- Let users configure:
-
Robustness
- Should handle both string-literal unions and
as const–based ID definitions. - Support TypeScript and JavaScript workspaces.
- Should handle both string-literal unions and
✅ Acceptance Criteria
- Create Event ID command appears in the Command Palette.
- Create Sub ID command appears in the Command Palette.
- New IDs are correctly inserted into the configured events file.
- A matching stub
regEvent(...)is created or updated without breaking existing code. - F12 on
dispatch(id)jumps directly to itsregEvent(id, …)handler. - “Find All References” on
regEvent(id, …)shows every dispatch/useSubscription usage. - Extension settings allow customizing file paths and ID naming patterns.
- Works in both JS and TS projects (with or without
as const).