Skip to content

refactor: namespace plugin RPC as 'devserverStatus.status' - #5

Merged
theshwal merged 1 commit into
mainfrom
feat/namespace-rpc
Sep 28, 2026
Merged

theshwal merged 1 commit into
mainfrom
feat/namespace-rpc

Conversation

@theshwal

Copy link
Copy Markdown
Owner

Type de PR (obligatoire)

  • Bug fix
  • Refactor / rename (no behavior change)
  • New feature
  • Documentation
  • Other: ____

Linked issue

Closes the namespace collision task described in the criteria below (no upstream issue number available; the change is driven by the requirement to avoid generic status RPC collisions between OpenFox plugins).

Objective

Rename the openfox-devserver-status plugin's generic status RPC to the namespaced devserverStatus.status so it no longer collides with RPCs registered by other OpenFox plugins. Introduce a single source of truth (RPC_NAMESPACE + RPC_METHOD) so future renames are localised.

Scope

  • src/index.ts:
    • Add and export RPC_NAMESPACE = 'devserverStatus.' and RPC_METHOD = ${RPC_NAMESPACE}status``.
    • Replace the literal 'status' argument of registerRpc(...) with RPC_METHOD.
    • Replace badge.source.method with RPC_METHOD.
  • test/index.test.ts:
    • Import RPC_NAMESPACE and RPC_METHOD from ../src/index.js.
    • Replace every literal 'devserverStatus.status' with RPC_METHOD.
    • Replace every literal 'rpc:devserverStatus.status' with `rpc:${RPC_METHOD}`.
    • Add a new test 'exposes the namespaced RPC contract from a single source of truth' asserting RPC_NAMESPACE, RPC_METHOD, and their derivation.
  • dist/index.js, dist/index.d.ts, dist/index.js.map: regenerated via npm run build.

Type of change

  • Refactor / rename (no behavior change)

Verification performed

  • npm run typecheck → exit 0 (tsc on both tsconfig.json and tsconfig.test.json).
  • npm test → exit 0; 13/13 tests pass (12 pre-existing + 1 new namespace test).
  • npm run build → exit 0.
  • grep -rn "'status'" src test --include="*.ts" no longer returns any RPC literal — only the `${RPC_NAMESPACE}status` template inside the constant definition.
  • git diff dist/ shows only the expected substitution ('status' → RPC_METHOD) and the newly-exported constants in dist/index.d.ts.

Acceptance criteria

  • CA-1: src/index.ts no longer registers an RPC named 'status'; only RPC_METHOD (derived from RPC_NAMESPACE) is used in registerRpc.
  • CA-2: src/index.ts no longer registers a badge with source.method === 'status'.
  • CA-3: Constant RPC_NAMESPACE = 'devserverStatus.' exists at the top of src/index.ts, and the registered RPC method is derived from it (single source of truth).
  • CA-4: No literal 'rpc:status' reference remains in src/ or test/.
  • CA-5: Badge id: 'devserver-status' and slot 'session.row.badges' unchanged (badge behavior preserved).
  • CA-6: Hooks devserver.started, devserver.stopped, devserver.state.changed unchanged.
  • CA-7: npm run typecheck exits 0.
  • CA-8: npm test exits 0; all tests pass (now 13 cases including the new namespace test).
  • CA-9: npm run build exits 0 and dist/index.js contains registerRpc(RPC_METHOD, ...) which emits 'devserverStatus.status'.
  • CA-10: dist/ regenerated correctly (will pass git diff --exit-code -- dist once this PR is merged into main and the dist is re-committed on main).
  • CA-11: Only src/, test/, and dist/ are modified. No other repo files are touched.

Out of scope

  • No changes to OpenFox upstream contracts (src/openfox-plugin.d.ts already accepts a free-form method name).
  • No change to badge id 'devserver-status', slot 'session.row.badges', hooks, persistence keys, or runtime state.
  • No change to displayed data (tooltips, tones, port value, refresh interval).
  • No change to README (it never named the RPC explicitly).
  • No addition of a lint tool (the project does not currently configure one).

Risks / known limitations

  • Existing OpenFox instances that hard-code the old 'status' method name for this plugin's badge would break; this is by design — the namespace is the whole point of the change.
  • dist/ is rebuilt as part of the same commit; if the merge rebase conflicts on dist/index.js.map, re-run npm run build to regenerate.
  • No lint step exists in this project (package.json has no lint script); only typecheck, build, and test were executed.

…atus'

- Export RPC_NAMESPACE and RPC_METHOD constants as single source of truth in src/index.ts
- Update badge source.method and registerRpc to use RPC_METHOD (derives 'devserverStatus.status')
- Update tests to import the exported constants; replace all literal 'devserverStatus.status' / 'rpc:devserverStatus.status' usages with RPC_METHOD / `rpc:${RPC_METHOD}`
- Add test 'exposes the namespaced RPC contract from a single source of truth' that verifies the namespace and derivation
- Regenerate dist/index.js, dist/index.d.ts, dist/index.js.map via npm run build

Verified locally:
- npm run typecheck exit 0
- npm test exit 0 (13/13 tests pass, including the new namespace test)
- npm run build exit 0
- Badge id 'devserver-status' and slot 'session.row.badges' unchanged
- Hooks devserver.started|stopped|state.changed unchanged
- Only src/, test/, dist/ modified (CA-11)
@theshwal
theshwal merged commit 7035257 into main Sep 28, 2026
2 checks passed
@theshwal
theshwal deleted the feat/namespace-rpc branch September 28, 2026 06:25
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