Skip to content

Add support for snapshots in "Run And Debug" view. - #38

Merged
aragners merged 1 commit into
intel:mainfrom
aragners:snapshots
Nov 26, 2026
Merged

aragners merged 1 commit into
intel:mainfrom
aragners:snapshots

Conversation

@aragners

@aragners aragners commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
  • Adds support for taking, restoring and deleting snapshots, either named or getting a default name.

@aragners
aragners requested review from clillies and a lite review from Copilot November 25, 2026 06:26
@aragners
aragners requested a review from a team as a code owner November 25, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Defer approval because the new SimUtils snapshot protocol and stateful history behavior require runtime validation against supported Simics TCF agents, including resume ordering and undo/redo races not covered by the repository’s fakes.

No open issues 🎉

What changed in this PR

Adds Simics snapshot management and step-history undo/redo support to the Run and Debug experience. The PR also migrates the launch-settings webview to React and updates the build/type-check configuration.

Changes:

  • Adds SimUtils snapshot commands, DAP requests, automatic step/run history, and undo/redo behavior.
  • Adds the Snapshots tree view, commands, menus, settings, documentation, and changelog entries.
  • Replaces the legacy launch-settings webview with a React implementation and updates bundling.
File Description
tsconfig.json Excludes the browser React webview from the main TypeScript project.
src/​webview/​launchSettings/​vscode.ts Provides VS Code webview messaging and persisted-state helpers.
src/​webview/​launchSettings/​styles.css Removes styles for controls no longer used by the migrated form.
src/​webview/​launchSettings/​index.tsx Adds the React entry point for launch settings.
src/​webview/​launchSettings/​components/​controls.tsx Implements reusable React launch-configuration controls.
src/​webview/​launchSettings/​App.tsx Implements the React launch-configuration editor.
src/​test/​snapshots.test.ts Adds coverage for snapshot operations and step-history behavior.
src/​test/​schema.test.ts Updates schema tests after removing legacy webview field features.
src/​tcfDebugSession.ts Integrates snapshot services, custom requests, and automatic history capture with stepping and running.
src/​tcf/​services/​simUtils.ts Adds the SimUtils TCF service wrapper for snapshot commands and events.
src/​snapshotsView.ts Implements the Snapshots tree view and associated commands.
src/​snapshots.ts Implements snapshot state management, naming, retention, and undo/redo logic.
src/​settings.ts Maps step-history settings into debug-session arguments.
src/​launchSettings/​webview/​tsconfig.json Removes the obsolete legacy webview TypeScript configuration.
src/​launchSettings/​webview/​launchSettings.ts Removes the legacy launch-settings DOM implementation.
src/​launchSettings/​webview/​controls.ts Removes the legacy launch-settings control implementation.
src/​launchSettings/​schema.ts Simplifies schema field kinds for the new form implementation.
src/​extension.ts Registers the Snapshots view during extension activation.
README.md Documents snapshot commands, step history, settings, and architecture.
package.json Registers the Snapshots view, commands, menus, settings, and updated type-check script.
esbuild.mjs Builds the new React launch-settings webview entry point.
CHANGELOG.md Records the new snapshot and step-history features.

Review effort: Lite

Comment thread README.md
Comment on lines 764 to 803
## Source layout

- `src/extension.ts` – VS Code entry point, registers the `simics-target-debug`
debug type.
- `src/tcfDebugSession.ts` – DAP implementation (no `vscode` dependency, so it
can also be run as a standalone debug adapter later).
- `src/contextSession.ts` – adapter of the child sessions that show the
threads of a container context; passes requests on to the root session's
adapter.
- `src/contextSessionManager.ts` – starts the child sessions in VS Code and
maps them to their root session for the extension's views and commands.
- `src/breakpointManager.ts` – keeps the agent's breakpoint table in sync with
VS Code.
- `src/variables.ts` – local variables and expressions through the
`Expressions` and `Symbols` services.
- `src/pathMapper.ts` – path mapping between compiled and host paths.
- `src/symbolFiles.ts` – symbol files from the debug configuration, sent to
the agent's memory map.
- `src/targetMemory/` – Target Memory panels and commands (extension side).
- `src/webview/targetMemory/` – Target Memory UI (React), bundled to
`out/target-memory.{js,css}`.
- `src/shared/targetMemory/` – code shared by the Target Memory extension
side, webview and debug adapter: messages, formatting, search needles and
the memory search.
- `src/tcfRequests.ts` – custom DAP requests used by the Target Memory view.
- `src/simicsConsole.ts` – the Simics console: keys to `CommandLine` key
presses, events to VT text (no `vscode` dependency).
- `src/simicsConsoleManager.ts` – the Simics CLI terminals and their commands.
- `src/consolesView.ts` – the Consoles view.
- `src/snapshots.ts` – Simics snapshots in the adapter, and the custom
requests of the Snapshots view (no `vscode` dependency).
- `src/snapshotsView.ts` – the Snapshots view and its commands.
- `src/launchSettings/` – the TCF Launch Configurations editor: reading and editing
`launch.json` (`launchJson.ts`), form fields from `package.json`
(`schema.ts`), the custom editor (`editorProvider.ts`) and the form in its
webview (`webview/`).
- `src/tcf/channel.ts` – TCF TCP channel: framing, escaping, tokens, events.
- `src/tcf/json.ts` – JSON parsing that keeps 64-bit integers exact (`bigint`).
- `src/tcf/services/` – typed wrappers for TCF services.
- `src/test/` – unit tests (`node:test`), they need no TCF agent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest we should remove this from the README since it's not very useful for a human. It's easier to just ask the agent to summarize the code structure (and easier to keep that up to date) and ask it what goes where.

If we want it for agents (to give them a cheap/fast context of the source code), then we could move it to a copilot instruction (or similar). But honestly, I'm not sure it's needed - the agents are so good/cheap to run nowadays.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, can be done in a separate patch.

@emanuelen5

Copy link
Copy Markdown
Contributor

Looks like you need to rebase your PR. Two of the commits in your PR have already been merged to main

Comment thread CHANGELOG.md Outdated
Comment on lines +24 to +29
- Undo Step and Redo Step in the Snapshots view: with the setting
`simics-target-debug.stepHistory.size`, a snapshot is taken before each
step and continue, to go back and forward through. Off by default.
Recording can be paused for a session, and the step snapshots cleared
without deleting the others. `simics-target-debug.stepHistory.includeRuns`
leaves continues out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would think it's useful if this was controllable per debug session (but the default can be in the settings). Can we perhaps add a toggle button for it in the debug pane?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, probably, this depends a bit on target as discussed below. Some targets support snapshotting better than others. I think I'll back out the step-undo and maybe re-add it later when it's been though thru.

Comment thread package.json Outdated
"type": "integer",
"order": 1,
"minimum": 0,
"maximum": 100,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not always have this enabled? I guess it takes a lot of space? If so, how does a user know how "large" they should set the step history to? Why is 100 the max?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great questions (as AI would say). For why it's partly because it consumes a lot of memory, but also that platforms don't always support snapshotting perfectly (lots of logs etc when restoring snapshots). It can be considered a bit experimental.
The question about what is a good value is interesting and should be documented, suggested somehow. I have used 5 myself when testing. But larger "undo-buffer" can of course be wanted. And the hard limit of 100 is something Claude came up with. Really hard to say where one should put the limit.

We could potentially skip this whole feature of step undo. It's mainly something I have though of for some time (since we removed reverse execution in 7) and that I now took the time to try it out. Should probably be supported in CLI as well if we want it.
If kept it should probably be marked as experimental somehow. It's a cool feature, though. But can be added later after it's been further discussed.

Users want to take, restore and delete Simics snapshots from VS Code,
without typing commands in the Simics CLI. The view uses the snapshot
commands of the Simics SimUtils service, and follows its
snapshotsChanged event, so snapshots taken elsewhere show up too.
A Delete All button clears them all at once, after asking.

The debug adapter owns the TCF connection and answers custom requests
from the view, like for the Path Maps view. This keeps the adapter
free of vscode code.

Unnamed snapshots get a free name like take-snapshot gives them.
Changes run one at a time, so two quick takes do not pick the same
name.

SimUtils is internal to Simics and older versions lack the snapshot
commands. Then the view says that snapshots are not available and
the take buttons are disabled. Restore and delete have no enablement
condition: VS Code kept their buttons on the snapshot rows greyed
out. Those rows only exist when snapshots are supported anyway.

Signed-off-by: Andreas Ragnerstam <andreas.ragnerstam@intel.com>
@aragners

Copy link
Copy Markdown
Contributor Author

I reduced this to only be for adding snapshots support, not the undo-step part as that is more of an experimental feature that can be its own patch.

@aragners
aragners requested a review from emanuelen5 November 26, 2026 07:20

@emanuelen5 emanuelen5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I haven't tried it, but sounds useful.

Comment thread src/tcfDebugSession.ts
Comment on lines 549 to 550
this.sendEvent(new Event("symbolFilesChanged"));
this.sendEvent(new Event("pathMapChanged"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For a follow-up PR: we should probably refactor these plain strings so the debug adapter events are typed and defined in one place. And in such a way that we can use type narrowing (i.e. so that the receiver of the event can know what data it has attached).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.
I'll try to fix your good suggestions. I have a few other PRs I would like to commit, but waited with them until this had landed due to CHANGLOG conflicts. But I can put the rest in one PR.
And then do follow ups with the cleanups in README and strings in another PR.

@aragners
aragners merged commit 0bfb0b2 into intel:main Nov 26, 2026
5 checks passed
@aragners
aragners deleted the snapshots branch November 26, 2026 07:45
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.

3 participants