Limit AI edits with Add to Chat
Distinguish source-sharing chips from permission to change a control, procedure or whole document.
Sharing and editing are different permissions#
Document chips select source to send. Add to Chat creates a target-marked scope chip defining what may change. With a nonempty scope, the toolchain checks Build, Fix, Apply selected and plan-stage proposals against it. More context does not silently widen that scope. An empty scope is not a read-only mode: choose Ask, Plan or Explain when no editing is intended.
Add the smallest useful target#
| Where | Command | Editable target |
|---|---|---|
| A Designer control or selected controls | Add to Chat | Selected properties/layout and exclusively owned event handlers. Shared handlers remain read-only. |
| A control-array member | Add Array to Chat | All current members and shared handlers; adding a new member still needs permission. |
| Empty Form canvas | Add Form to Chat | The whole Form’s code and layout. |
| Form/module/class/test in the Project tree | Add to Chat | The complete document. |
| A procedure in the editor | Add Procedure to Chat | That procedure’s signature and body. |
Supporting declarations and called-procedure signatures can be read-only context. Nonvisual components have no canvas context menu; use the owning Form. A chat supports up to 32 scope items.
Treat a property accessor as its own item#
Property Get, Let and Set are separate scope items. The current change mechanism cannot replace a single property accessor in isolation: rewriting the containing document requires the corresponding permission card. Do not assume selecting Get automatically permits changing Let or a WithEvents subscriber.
Decide whether a proposal may cross the boundary#
| Choice | Effect | Important boundary |
|---|---|---|
| Yes | Permit the requested expansion for one Check | A repair after a failed Check asks again. |
| No | Do not apply the outside-scope change; ask for a solution within the boundary | A plan can pause as outside the scope when it cannot continue. |
| Yes, and add to scope | Permit the change and retain eligible existing targets as scope chips | New documents, new procedures, plugin references and migrations can only be allowed once. |
A new control outside the selected controls, a second document or a new dependency needs a decision. Dependency approval and the apply policy remain separate gates. Sending another message while a permission card waits sets that proposal aside.
Keep the boundary current#
Control scope chips track object identity through renames. A control-array chip instead follows the array name: after renaming the array, add it again with Add Array to Chat. If an item is deleted, McBasic™ stops before the next send so you can review the removal. A plan can pause if its entire scope disappears. Removing a chip changes what later requests may modify, not changes already applied.
Scope and its permission decisions are stored locally with the chat. A conversation imported from another Mac does not import those grants, even when its questions and approved plan remain readable.
Test a narrow edit and its recovery#
Use the scoped greeting exercise for exact settings, prompts, complete expected handler code and a diff checklist. Reject unrelated edits, inspect the checked result, then Run the normal and empty-input cases.
20f4bfed6b · Build manifestSources & maintenance
Original web explanation, reviewed against these repository sources. API tables and example files follow the implementation.
docs/manual/16-working-with-the-ai-assistant.mdsrc/McBasic.Build/AiScope.csmacos/McBasicIDE/Sources/AIScope.swift