refactor(core): rename Context to CommandContext#104
Conversation
…t to useScreenContext Clearer delineation between command handler context (CommandContext) and screen component context (ScreenContext). Updates all references across core, cli, middleware, docs, and tests. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
🦋 Changeset detectedLatest commit: 9157536 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis pull request systematically renames the exported context type from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The refactoring spans ~70 files with a consistent, repetitive pattern (Context → CommandContext, useCommandContext → useScreenContext), making individual change verification straightforward. However, the breadth requires systematic verification of import consistency, completeness of the rename across all affected files, alignment of documentation examples with code, and consistency of module augmentation targets. Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/middleware/http/README.md (1)
54-60:⚠️ Potential issue | 🟡 MinorUpdate the prose to
CommandContextto avoid conflicting augmentation guidance.Line 54 still instructs users to augment
Context, while Line 60 correctly augmentsCommandContext. Keep both aligned so consumers don’t augment the wrong interface.Suggested fix
-Augment the `Context` interface so TypeScript knows about the namespace property: +Augment the `CommandContext` interface so TypeScript knows about the namespace property:As per coding guidelines: “When renaming types in docs … update names precisely … and keep references … accurate and consistent across files.” (
contributing/standards/documentation/writing.md)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/middleware/http/README.md` around lines 54 - 60, The docs incorrectly refer to augmenting `Context` on line 54 while the example augments `CommandContext`; update the prose so it consistently instructs consumers to augment `CommandContext` (not `Context`) and scan the surrounding text for any other mentions of `Context` to replace with `CommandContext`, ensuring the example import and the `declare module` augmentation (including `HttpClient` and the namespace property) remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/context/index.ts`:
- Line 6: Re-add a compatibility type export for the removed public Context by
exporting CommandContext under the old name; update the context entrypoint to
re-export or alias CommandContext as Context (e.g., export the type
CommandContext as Context or declare type Context = CommandContext) so consumers
importing Context continue to work — target the export in the same module where
CommandContext is currently exported.
In `@packages/core/src/ui/index.ts`:
- Line 67: Restore the legacy export by reintroducing a compatibility re-export
for useCommandContext that points to the new hook; locate the export block in
packages/core/src/ui/index.ts where useScreenContext is exported and add a
re-export/alias so useCommandContext is exported (e.g., export {
useScreenContext as useCommandContext }) to maintain backward compatibility
while keeping the canonical symbol useScreenContext.
---
Outside diff comments:
In `@packages/core/src/middleware/http/README.md`:
- Around line 54-60: The docs incorrectly refer to augmenting `Context` on line
54 while the example augments `CommandContext`; update the prose so it
consistently instructs consumers to augment `CommandContext` (not `Context`) and
scan the surrounding text for any other mentions of `Context` to replace with
`CommandContext`, ensuring the example import and the `declare module`
augmentation (including `HttpClient` and the namespace property) remain
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: df8ccab4-7830-4ca3-b046-eb42d73efe33
⛔ Files ignored due to path filters (1)
.changeset/context-rename.mdis excluded by!.changeset/**
📒 Files selected for processing (58)
README.mddocs/concepts/context.mddocs/concepts/icons.mddocs/concepts/reporting.mddocs/guides/add-authentication.mddocs/reference/command.mddocs/reference/middleware.mddocs/reference/report.mdpackages/cli/src/commands/add/command.test.tspackages/cli/src/commands/add/command.tspackages/cli/src/commands/add/config.tspackages/cli/src/commands/add/middleware.test.tspackages/cli/src/commands/add/middleware.tspackages/cli/src/commands/build.test.tspackages/cli/src/commands/build.tspackages/cli/src/commands/commands.test.tspackages/cli/src/commands/commands.tspackages/cli/src/commands/dev.test.tspackages/cli/src/commands/dev.tspackages/cli/src/commands/doctor.test.tspackages/cli/src/commands/doctor.tspackages/cli/src/commands/init.test.tspackages/cli/src/commands/init.tspackages/core/src/cli.test.tspackages/core/src/context/create-context.tspackages/core/src/context/decorate.tspackages/core/src/context/index.tspackages/core/src/context/types.tspackages/core/src/index.tspackages/core/src/middleware/auth/README.mdpackages/core/src/middleware/auth/auth.tspackages/core/src/middleware/auth/headers.test.tspackages/core/src/middleware/auth/headers.tspackages/core/src/middleware/auth/require.tspackages/core/src/middleware/auth/types.tspackages/core/src/middleware/http/README.mdpackages/core/src/middleware/http/http.tspackages/core/src/middleware/http/types.tspackages/core/src/middleware/icons/context.tspackages/core/src/middleware/icons/types.tspackages/core/src/middleware/report/types.tspackages/core/src/middleware/typed-middleware.test.tspackages/core/src/runtime/args.test.tspackages/core/src/runtime/register.tspackages/core/src/runtime/runner.test.tspackages/core/src/runtime/runner.tspackages/core/src/runtime/runtime.test.tspackages/core/src/runtime/runtime.tspackages/core/src/runtime/types.tspackages/core/src/test/context.tspackages/core/src/test/middleware.test.tspackages/core/src/test/types.tspackages/core/src/types/command.tspackages/core/src/types/middleware.tspackages/core/src/ui/index.tspackages/core/src/ui/provider.tsxpackages/core/src/ui/screen.test.tspackages/core/src/ui/screen.tsx
Summary
Contextinterface toCommandContextfor clearer delineation between command handlers and screen componentsuseCommandContexthook touseScreenContextto match theScreenContexttype it returnsTest plan
pnpm checkpasses (typecheck + lint + format)pnpm testpasses (744 tests)auth,report,icons)