McBasic™Get McBasic™ ↗
Build 881
Guided workflow

Fix a behavioral bug after a clean Check

Reproduce a whitespace bug, review the source and Run evidence shared with Fix, then verify a minimal repair and Undo.

Step 1Open an isolated first-app copy#

Use McBasic™ 0.5.832 or later. Download HelloForms, extract a disposable copy and open HelloForms.mcbproj. Keep txtName, lblGreeting and cmdGreet, with Click bound to cmdGreet_Click. Configure a working AI provider, set Apply AI changes to Ask me first and leave automatic plugin/migration approval off. Use a fresh chat with no scope for this exercise; source chips are reviewed separately.

Step 2Enter a complete, deliberately incorrect handler#

Replace only cmdGreet_Click in Forms/frmMain.bas with the following. Keep Option Explicit at file scope, cmdDetails_Click and all other procedures. The temporary print uses only test names you enter yourself.

Deliberate defect — complete replacement handler
Private Sub cmdGreet_Click()
    Dim name As String
    name = txtName.Text
    Debug.Print "Greeting input: [" & name & "]"

    If Len(name) = 0 Then
        lblGreeting.Caption = "Enter a name."
        Exit Sub
    End If

    lblGreeting.Caption = "Welcome, " & name
End Sub

Step 3Prove that Check does not find this bug#

Save and run Check: it should pass. Run, enter exactly three spaces and click Greet. The Label shows Welcome, followed by spaces instead of Enter a name.; Output includes the bracketed whitespace. Enter Ada and verify the happy path works. Stop the app. Do not edit the project before reviewing its Last Run output, because an edit invalidates that evidence.

Step 4Write the report without sending yet#

Enter this report; review the next step before Send
/fix In frmMain, cmdGreet_Click has a whitespace bug. Steps: enter three spaces in txtName and click Greet. Expected: lblGreeting says "Enter a name." Actual: it says "Welcome, " followed by spaces. Check passes. Restore trimming while preserving the normal Welcome greeting and empty-input guard. Remove the temporary Debug.Print used for this reproduction. Change no other handler, layout, package or file.

The exact name frmMain identifies the Form. Paste the report into the composer without sending. The /fix command sets this message’s intent even if the persistent mode pill is still Build. Review existing document chips and optional output before the first Send: a request can proceed directly when no additional document needs to be proposed.

Step 5Review evidence, then send the report#

Before Send, inspect Show exact content and the removable Last Run output chip. It contains a bounded tail of output plus how the run ended, labelled as program data rather than instructions. Remove its × if you do not want it shared; from build 840 it stays disabled for future Runs in this chat until you choose + Add → Last Run output (Fix). The report must still describe the defect. Stop is not included as a Fix diagnostic. Press Send. Fix may first Check an absent or stale diagnostic snapshot. If McBasic™ adds frmMain or referenced documents as chips, this Send pauses before contacting the provider: inspect the Added for Fix from your report note, remove anything unrelated, and recheck Show exact content. Press Send again to proceed. If no chip was added, the first Send can proceed directly. Retry uses the same review pause when it adds source, but asks for Retry rather than Send.

Step 6Compare the entire repair before Apply#

Expected complete cmdGreet_Click after repair
Private Sub cmdGreet_Click()
    Dim name As String
    name = Trim$(txtName.Text)

    If Len(name) = 0 Then
        lblGreeting.Caption = "Enter a name."
        Exit Sub
    End If

    lblGreeting.Caption = "Welcome, " & name
End Sub

The intended changes are Trim$ around the input and removal of the temporary print. Verify cmdDetails_Click and the layout are unchanged. Confirm Check passed and the candidate is Ready to apply. If the provider changes names, behavior or scope, discard it and clarify the request instead of accepting a different solution.

Step 7Apply, retest and prove recovery#

InputExpected caption
Three spacesEnter a name.
Empty inputEnter a name.
Ada Welcome, Ada
AdaWelcome, Ada

Apply and run all four cases. Confirm the Details action still works. Stop and Undo the accepted change; the whitespace defect and temporary diagnostic print should return. Redo the reviewed repair, repeat the cases, save and reopen the practice project. A successful provider reply or green Check alone is not the result.

Source baseline 20f4bfed6b · Build manifest
Sources & 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.md
  • samples/HelloForms.mcbproj/Forms/frmMain.bas
  • src/McBasic.Build/AiChatRequest.cs
  • src/McBasic.Build/AiScope.cs
  • src/McBasic.Build/ProcedurePatchValidationService.cs
  • macos/McBasicIDE/Sources/AIContextRecipe.swift
  • macos/McBasicIDE/Sources/AIProviderController.swift