Skip to content

Support breakpoints in virtual source documents such as AL .dal files - #137

Open
Fekete Gábor (feketegabor) wants to merge 10 commits into
microsoft:mainfrom
Ecobit-Consulting:feature/al-dal-uri-breakpoints
Open

Fekete Gábor (feketegabor) wants to merge 10 commits into
microsoft:mainfrom
Ecobit-Consulting:feature/al-dal-uri-breakpoints

Conversation

@feketegabor

@feketegabor Fekete Gábor (feketegabor) commented Sep 2, 2026 •

Copy link
Copy Markdown

Summary

Lets an agent debug sources that exist only as VS Code virtual documents, such as Business Central .dal files served through the al-preview: scheme.

  • preserve virtual-document URIs when adding, removing, or logging breakpoints
  • add an optional workingDirectory routing hint for virtual sources in multi-window sessions
  • report the source location of a stop in a virtual document: fileFullPath is the document URI, in the form the breakpoint tools accept unchanged, together with the file name, current line and following lines
  • match a breakpoint in a virtual document however its URI is written (literal spaces or percent-encoded) in remove_breakpoint, and show the decoded file name in list_breakpoints
  • accept a breakpoint or logpoint in a virtual document that cannot be opened yet; the line is then not validated and the result says so
  • keep native POSIX and Windows file-path behavior unchanged
  • make cliAdapterConfig.test.ts independent of the host's path separator and user config directory, so the suite passes on macOS and Linux
  • merged with main at 2.4.4

Why

DebugMCP previously passed every source argument to vscode.Uri.file(). That rewrites an AL virtual source such as al-preview://AlLang/.../Customer%20List.dal into a local file:// URI, so the Microsoft AL extension cannot resolve the document and the breakpoint cannot bind.

The same assumption applied on the way back. The AL adapter reports a stack frame's source as a URI with literal spaces:

{ "name": "My Codeunit", "path": "al-preview://allang/<workspace folder>/Codeunit/50100/My Codeunit.dal", "sourceReference": 0 }

Opened as a filesystem path, that left the location of every stop empty, so the agent could neither see the line it stopped on nor learn the URI to set a breakpoint with.

Business Central also serves a .dal source only once the debug session has stopped. Validating the line by opening the document therefore made it impossible to set a breakpoint in such a source before the first stop.

src/utils/sourceUri.ts holds the host-neutral text helpers (it is bundled into the standalone CLI); src/utils/vscodeSourceUri.ts holds the conversions to and from vscode.Uri. The router can use workingDirectory to select the owning editor window; it can also reuse the active target or the sole registered window.

Related

#203 fixes two general problems with the state returned right after a stop (#201, #202). It is independent of this change, but with the AL adapter each step_over returns an empty first state until it is merged.

Validation

  • npm run check-types, npm run lint, npm run bundle: clean.
  • Extension-host tests in VS Code 1.147.0 on macOS: 430 passing. New tests are in src/test/virtualSourceLocation.test.ts, src/test/sourceUri.test.ts and src/test/routing.test.ts.
  • End-to-end against a Business Central cloud sandbox (attach, AL extension 18.1), in a build that also contains Return the frame for a new stop and track resumes without a response command (#201, #202) #203:
    • stopped in an installed app's codeunit; the state carried the .dal URI, file name, line, line text and the next lines
    • added a breakpoint with the reported fileFullPath unchanged, and removed it again with the URI written with literal spaces
    • list_breakpoints showed the decoded file name
    • set a breakpoint on a .dal that had not been opened, before the first stop, and got the "line not checked" note
    • a breakpoint set with the app-ID form of the URI (al-preview://allang/<app id>/...) was hit as well

🤖 Generated with Claude Code

@feketegabor

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="EcoBit Consulting Kft."

Conflicts:
- README.md: keep upstream's new get_debug_status/get_debug_output rows and
  the fork's virtual-URI parameters for the breakpoint tools.
- src/routingDebuggingHandler.ts: keep both imports.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A stop in a virtual document (for example a Business Central `al-preview:`
`.dal` source) left `fileFullPath`, `fileName`, `currentLine`,
`currentLineContent` and `nextLines` empty: the frame's source path is a URI
there, and it was opened as a filesystem path. Open it as the URI it is and
report the canonical URI string, which the breakpoint tools accept unchanged.

`remove_breakpoint` compared the caller's text with the stored URI, so a URI
written with literal spaces never matched and only the percent-encoded form
worked. The handler now asks the executor for the canonical form of the
requested location. `list_breakpoints` shows the decoded file name.

`getBreakpoints()` reported `file:///...` for ordinary files, because every
URI string has a scheme; `remove_breakpoint` with a native path therefore
found nothing. Files on disk are reported by their native path again.

Also:
- Move the VS Code-bound URI conversions to `utils/vscodeSourceUri.ts` and keep
  `utils/sourceUri.ts` host-neutral, since the handler is bundled into the
  standalone CLI. Drop the duplicate helper and misplaced imports above the
  copyright header in `debuggingExecutor.ts`.
- Restore the changelog entries whose inline code was lost, and the upstream
  end-of-file state of files the fork only touched there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`add_breakpoint` and `add_logpoint` open the source to reject a line past its
end. For a Business Central `.dal` source that fails until the debug session
has stopped: the content is served through the session, and before the first
stop the server answers `al/previewDocument` with "An unexpected error
occurred invoking 'GetSourceContent'". In a workspace without the symbols, no
breakpoint could be set before something else had already stopped the session.

An unreadable virtual source is now left unchecked: the breakpoint is set and
the result notes that the line was not validated. A readable document is
validated as before, and a missing file on disk is still an error.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Remove tests that duplicated another test's coverage or only restated what
`vscode.Uri` does:

- `debuggingHandler.test.ts`: drop the pass-through test with a hand-written
  fake executor; the same operations are covered against the real executor in
  `virtualSourceLocation.test.ts`, which also keeps the out-of-range check.
- `sourceUri.test.ts`: keep the Windows drive-letter guard and the file-name
  helper; the URI conversions are exercised end to end by the breakpoint tests.
- `virtualSourceLocation.test.ts`: one case per behaviour instead of several
  spellings of the same URI.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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