Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Bug: AI Creates Files in Wrong Root in Multi-Root Workspace

Open DangDangMao01 opened this issue 10 months ago • 2 comments

Before opening, please confirm:

Operating System

Windows x64

Kiro Version

0.8.140

Bug Description

In a multi-root workspace, when AI creates files (via fsWrite, strReplace, etc.), the files are saved to the wrong root folder, causing project pollution and confusion.

What Happened:

  • Opened a multi-root workspace with projects A, B, C
  • Chat history shows Project A's context (first root)
  • Asked AI to create a document about Kiro IDE feature request
  • AI created the file in Project B (Kiro-KB-Plugin) instead of Project A (K_Kiro_Work)

Expected Behavior:

  • File should be created in Project A (the active/first root)
  • Or AI should ask which root to save to
  • Or follow a clear, documented rule

Actual Behavior:

  • File was created in Project B (seemingly random)
  • No indication of which root would be used
  • User had to manually move the file to correct location

Steps to Reproduce

  1. Create a multi-root workspace:

    • File → Add Folder to Workspace
    • Add Project A, Project B, Project C
  2. Start a chat conversation (chat history shows Project A's context)

  3. Ask AI to create a file: "Create a feature request document"

  4. Observe: File is created in Project B instead of Project A

Expected Behavior

Files should be created in a predictable location:

  • Option 1: Always use first root (simple and predictable)
  • Option 2: Use active file's root (smart detection)
  • Option 3: Ask user which root to use (explicit control)
  • Option 4: Add root selector in chat UI (best UX)

At minimum, the behavior should be documented and consistent.

Conversation ID

No response

Additional Context

Impact: High - Makes multi-root workspaces unreliable for AI file operations

Related Issues:

  • Issue #195: Support for multi-root workspaces (Closed) - solved file access
  • This bug is about file creation behavior, which was not addressed in #195

Root Cause:

  • Lack of "active root" concept in multi-root workspaces
  • No way to indicate which root the user is currently working in

Real-World Scenario: Workspace: Frontend + Backend + Shared-Utils

  • User working on Frontend
  • Chat context: Frontend project
  • Ask AI: "Create a new component"
  • AI saves to Backend project ❌
  • Component is in wrong place, build breaks

User Quote: "I can't use multi-root workspace because I don't know where AI will save files. It causes project pollution."

Version Info:

  • Kiro Version: 0.8.140
  • Platform: Windows x64
  • Commit: e9761ecebe507c32c4eefdc1f4f0a85a2bb29529

DangDangMao01 avatar Jan 28 '26 11:01 DangDangMao01

Hi @DangDangMao01, thanks for the detailed report with clear reproduction steps and proposed solutions.

We understand the issue — in multi-root workspaces, AI file operations (fsWrite, strReplace, etc.) are creating files in the wrong root folder with no predictable behavior, making multi-root workspaces unreliable for AI-assisted development.

Since you're on 0.8.140, could you please update to the latest version and try again? We've made improvements to workspace handling in recent releases.

If the issue persists after updating, could you share:

  • Updated Kiro version
  • Conversation ID from the updated version
  • Which root was active (open file/focused editor) when the file was created in the wrong location

Thank you for your patience!

AnilMaktala avatar Feb 25 '26 21:02 AnilMaktala

This issue has been automatically closed due to inactivity. It has been 7 days since we requested additional information.

If you still need help with this issue, please feel free to reopen it or create a new issue with the requested details.

github-actions[bot] avatar Mar 05 '26 00:03 github-actions[bot]