Skip to content

Conversation

@cameroncooke
Copy link
Collaborator

@cameroncooke cameroncooke commented Oct 6, 2025

Summary

  • migrate the build_run_sim tool to the session-aware factory so session defaults are merged at runtime
  • narrow the public schema/description to match the new session-managed pattern
  • update the test suite to clear session state and expect the new validation responses

Testing

  • npm run test -- build_run_sim

Note

Migrates build_run_sim to a session-aware tool, narrowing its public schema/description and updating tests to clear session state and expect new validation messages.

  • Simulator Tool (src/mcp/tools/simulator/build_run_sim.ts):
    • Refactor to use createSessionAwareTool with requirements and exclusivePairs, merging session defaults at runtime.
    • Narrow public schema via omit (hide projectPath, workspacePath, scheme, configuration, simulatorId, simulatorName, useLatestOS).
    • Update schema to public-only fields and shorten description.
  • Tests (src/mcp/tools/simulator/__tests__/build_run_sim.test.ts):
    • Add beforeEach to sessionStore.clear() and update imports.
    • Replace schema expectations to only non-session fields (derivedDataPath, extraArgs, preferXcodebuild) and adjust type checks.
    • Update XOR/validation assertions to new error messages (missing session defaults, mutually exclusive params, etc.).

Written by Cursor Bugbot for commit 74eb7a4. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Stricter input validation with clear mutually exclusive parameter checks.
    • Improved error messages for missing session defaults and missing project/workspace.
    • Consistent, concise messaging across failure scenarios.
  • Refactor

    • Streamlined command handling for more predictable behavior.
    • Public-facing parameters narrowed to essential options.
    • Shortened tool description for clarity.
  • Tests

    • Updated tests to align with refined validation, public schema exposure, and command execution flow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

Walkthrough

This update refactors the simulator build-and-run logic and its test suite to adopt a session-aware tool wrapper, streamlining parameter validation, input schema exposure, and error handling. The command logic now leverages a public schema and enforces stricter runtime validation, with tests updated for the refined validation flow and error messaging.

Changes

Cohort / File(s) Change Summary
Session-aware Tool Refactor
src/mcp/tools/simulator/build_run_sim.ts
Switched from manual validation to using a session-aware tool wrapper with internal and public schemas, enforcing mutually exclusive input constraints and concise descriptions.
Test Suite Alignment
src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
Updated tests to set up session state, adjust for new validation errors and public schema exposure, and to verify command generation under session/default-driven logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Tool (build_run_sim)
    participant SessionStore
    participant Executor

    Note over User, Tool: Request to build and run app on simulator

    User->>Tool: invoke handler(params)
    Tool->>SessionStore: load session defaults (if needed)
    Tool->>Tool: validate input params (require scheme, XOR project/workspace, XOR id/name)
    alt validation error
        Tool-->>User: error (e.g., "Missing required session defaults", "Mutually exclusive parameters provided")
    else valid input
        Tool->>Executor: invoke build/run command
        Executor-->>Tool: result
        Tool-->>User: success
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A rabbit hops through fields of code—
Where schemas prune the winding road.
Sessions aware, with XORs in tow,
Shy errors quick, but clearer now show.
With tests refreshed to validate anew,
This patch brings order, strong and true!
🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely summarizes the main change—migrating the build_run_sim command to session defaults—using a clear conventional commit style that matches the pull request scope and objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/session-managed-build-run-sim

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Contributor

claude bot commented Oct 6, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cameroncooke/XcodeBuildMCP/xcodebuildmcp@121

commit: 74eb7a4

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues found in the current changes.

@cameroncooke cameroncooke merged commit 2f73662 into main Oct 6, 2025
7 of 9 checks passed
@cameroncooke cameroncooke deleted the feat/session-managed-build-run-sim branch October 6, 2025 20:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/mcp/tools/simulator/build_run_sim.ts (1)

507-520: Session-aware configuration looks correct.

The requirements and exclusive pairs are properly configured to enforce the tool's constraints:

  • scheme is required via session defaults
  • One of projectPath or workspacePath is required (XOR constraint)
  • One of simulatorId or simulatorName is required (XOR constraint)
  • Mutual exclusivity is enforced for both pairs

The type cast at line 508 is necessary because Zod's .refine() returns a ZodEffects type rather than ZodType, but the factory's .parse() method will work correctly with refined schemas. Consider adding a comment explaining why the cast is needed to help future maintainers.

Consider adding a clarifying comment:

 handler: createSessionAwareTool<BuildRunSimulatorParams>({
+  // Type cast needed: .refine() returns ZodEffects, but factory accepts ZodType
   internalSchema: buildRunSimulatorSchema as unknown as z.ZodType<BuildRunSimulatorParams>,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c210b7 and 74eb7a4.

📒 Files selected for processing (2)
  • src/mcp/tools/simulator/__tests__/build_run_sim.test.ts (3 hunks)
  • src/mcp/tools/simulator/build_run_sim.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: Use .ts extensions for all internal relative imports (e.g., import { tool } from './tool.ts')
Use .ts extensions in re-exports for internal files (e.g., export { default } from '../shared/tool.ts')
Use .js extension only for external package entry points (e.g., import ... from '@scope/pkg/file.js')
Never import internal project files using .js extensions

Files:

  • src/mcp/tools/simulator/build_run_sim.ts
  • src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.ts: Do not use Vitest mocking APIs in tests (no vi.mock, vi.fn, vi.spyOn, etc.)
In tests, import the core ...Logic function from the tool and use createMockExecutor/createMockFileSystemExecutor to simulate outcomes

Files:

  • src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
🧠 Learnings (1)
📚 Learning: 2025-09-21T19:27:22.795Z
Learnt from: CR
PR: cameroncooke/XcodeBuildMCP#0
File: AGENTS.md:0-0
Timestamp: 2025-09-21T19:27:22.795Z
Learning: Applies to **/*.{test,spec}.ts : In tests, import the core ...Logic function from the tool and use createMockExecutor/createMockFileSystemExecutor to simulate outcomes

Applied to files:

  • src/mcp/tools/simulator/__tests__/build_run_sim.test.ts
🧬 Code graph analysis (2)
src/mcp/tools/simulator/build_run_sim.ts (1)
src/utils/typed-tool-factory.ts (1)
  • createSessionAwareTool (74-174)
src/mcp/tools/simulator/__tests__/build_run_sim.test.ts (1)
src/utils/session-store.ts (1)
  • sessionStore (47-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: code-review
🔇 Additional comments (7)
src/mcp/tools/simulator/build_run_sim.ts (2)

13-13: LGTM!

The import follows the coding guidelines by using the .ts extension for internal module imports.


493-501: LGTM!

The public schema correctly exposes only the non-session fields (derivedDataPath, extraArgs, preferXcodebuild) by omitting all session-managed parameters. This aligns with the session-aware pattern and the test expectations.

src/mcp/tools/simulator/__tests__/build_run_sim.test.ts (5)

8-9: LGTM!

The import changes correctly follow the coding guidelines by using .ts extensions. The addition of sessionStore is necessary for the session cleanup in beforeEach, and the removal of createMockFileSystemExecutor aligns with the testing pattern of using only createMockExecutor for this tool's tests.

Based on learnings.


13-15: LGTM!

The beforeEach hook properly clears the session state before each test, preventing test pollution and ensuring each test runs with a clean slate. This is essential for testing session-aware tools.


23-23: LGTM!

The test expectation correctly matches the concise description from the tool implementation.


30-52: LGTM!

The schema exposure test correctly validates that only non-session fields (derivedDataPath, extraArgs, preferXcodebuild) are exposed in the public schema, and that session-managed fields (scheme, simulatorName, projectPath, etc.) are not exposed. The test is thorough and covers both valid and invalid inputs.


537-560: LGTM!

The XOR validation tests correctly verify the new error message format from the session-aware tool wrapper:

  • Missing required session defaults now returns the appropriate "Missing required session defaults" error with the helpful message "Provide a project or workspace"
  • Mutually exclusive parameters are properly detected and reported with "Mutually exclusive parameters provided" along with the specific parameter names

These expectations align with the factory implementation in typed-tool-factory.ts.

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