Skip to content

Conversation

@jurgenwerk
Copy link
Contributor

@jurgenwerk jurgenwerk commented Jan 20, 2026

This PR addresses a user experience issue where:

  1. User is in interact mode and opens the AI assistant and tells it to generate something (e.g. "make me a tic tac toe game")
  2. The assistant will switch to code mode and open the index card, then proceed with ai generation and once user accepts the patch to create file(s) nothing happens, they still see the index card.

This PR adds an optional boolean param createFile to switch mode command where it will create the file the assistant is about to generate. The user will be transitioned to code mode, seeing a blank file until the AI assistant is done generating the code.

The changes in this PR alone don't fix the mentioned issue yet - there will be another PR in the skills repo to teach the LLM when to use createFile parameter (I have it almost ready and confirm it works with all of the above).


Note

Introduces file-creation flow when switching to code mode and propagates the final filename back to the AI.

  • Adds createFile to SwitchSubmodeInput and new SwitchSubmodeResult card in base/command.gts
  • Implements file creation in switch-submode when entering code mode: creates blank file if missing; if target exists with content, picks a non-conflicting filename and returns it via result card
  • Extracts findNonConflictingFilename utility and reuses it in patch-code (replacing local logic)
  • Updates AI prompt builder to append instruction: "Use for the SEARCH/REPLACE block since already exists" when a SwitchSubmodeResult is returned
  • Hides switch-submode result card in room UI; adds unit/integration tests for the new behavior

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

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 38m 58s ⏱️ -44s
1 900 tests +3  1 883 ✅ +3  17 💤 ±0  0 ❌ ±0 
1 915 runs  +3  1 898 ✅ +3  17 💤 ±0  0 ❌ ±0 

Results for commit 21d54b8. ± Comparison against base commit 143407c.

♻️ This comment has been updated with latest results.

@jurgenwerk jurgenwerk force-pushed the cs-9640-when-trying-to-create-a-new-card-with-ai-it-will-sometimes branch from 76b1b4d to 2cbf92e Compare January 20, 2026 12:13
@jurgenwerk jurgenwerk requested a review from Copilot January 20, 2026 12:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the AI assistant's user experience by adding a createFile parameter to the switch-submode command. When switching from interact mode to code mode, the assistant can now create a blank file immediately, allowing users to see an empty file instead of an index card while the AI generates code.

Changes:

  • Added createFile boolean parameter to SwitchSubmodeInput and introduced SwitchSubmodeResult card definition for handling filename conflicts
  • Implemented file creation logic in switch-submode command with automatic conflict resolution when target files already exist
  • Extracted filename conflict resolution logic to a reusable utility function and refactored patch-code command to use it

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/base/command.gts Added createFile field to SwitchSubmodeInput and defined SwitchSubmodeResult card for communicating filename changes
packages/host/app/commands/switch-submode.ts Implemented file creation logic with conflict resolution when switching from interact to code mode
packages/host/app/utils/file-name.ts New utility function for finding non-conflicting filenames
packages/host/app/commands/patch-code.ts Refactored to use shared filename conflict resolution utility
packages/runtime-common/ai/prompt.ts Added instruction generation for AI when filename conflicts occur
packages/host/app/components/matrix/room-message-command.gts Hide result cards for switch-submode commands in the UI
packages/host/tests/integration/commands/switch-submode-test.gts Added tests for file creation and conflict resolution scenarios
packages/ai-bot/tests/prompt-construction-test.ts Added test for AI instruction when filename conflicts occur

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jurgenwerk and others added 3 commits January 20, 2026 13:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jurgenwerk jurgenwerk marked this pull request as ready for review January 20, 2026 13:45
@jurgenwerk jurgenwerk requested a review from a team January 20, 2026 13:57
@jurgenwerk jurgenwerk changed the title Add createFile param to switch submode command Add createFile param to the switch submode command Jan 20, 2026
@jurgenwerk
Copy link
Contributor Author

jurgenwerk commented Jan 21, 2026

Accompanying PR: cardstack/boxel-skills#44

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.

2 participants