From d2aeca7fa24b35a59abecf9cfaeaa493c1068767 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Fri, 29 Sep 2023 10:25:05 -0400 Subject: [PATCH] Skip the multi-group frame for single groups & small app scope improvement --- src/debugAdapter/debugRequestHandlers.ts | 7 ++++++- src/debugAdapter/traceReplayEngine.ts | 5 +++++ tests/adapter.test.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/debugAdapter/debugRequestHandlers.ts b/src/debugAdapter/debugRequestHandlers.ts index c63df6f..57cc416 100644 --- a/src/debugAdapter/debugRequestHandlers.ts +++ b/src/debugAdapter/debugRequestHandlers.ts @@ -312,8 +312,13 @@ export class TxnGroupDebugSession extends LoggingDebugSession { if (typeof frame !== 'undefined') { if (frame instanceof ProgramStackFrame) { const programScope = new ProgramStateScope(args.frameId); + let scopeName = 'Program State'; + const appID = frame.currentAppID(); + if (typeof appID !== 'undefined') { + scopeName += `: App ${appID}`; + } scopes.push( - new Scope("Program State", this._variableHandles.create(programScope), false) + new Scope(scopeName, this._variableHandles.create(programScope), false) ); } scopes.push( diff --git a/src/debugAdapter/traceReplayEngine.ts b/src/debugAdapter/traceReplayEngine.ts index a25f091..c08765e 100644 --- a/src/debugAdapter/traceReplayEngine.ts +++ b/src/debugAdapter/traceReplayEngine.ts @@ -37,6 +37,11 @@ export class TraceReplayEngine { this.stack = [ new TopLevelTransactionGroupsFrame(this, simulateResponse) ]; + if (simulateResponse.txnGroups.length === 1) { + // If only a single group, get rid of the top-level frame + this.forward(); + this.stack.shift(); + } } private resetCurrentAppState() { diff --git a/tests/adapter.test.ts b/tests/adapter.test.ts index 70c1677..8468386 100644 --- a/tests/adapter.test.ts +++ b/tests/adapter.test.ts @@ -57,7 +57,7 @@ async function assertVariables(dc: DebugClient, { assert.ok(scopesResponse.success); const scopes = scopesResponse.body.scopes; - const executionScope = scopes.find(scope => scope.name === 'Program State'); + const executionScope = scopes.find(scope => scope.name.startsWith('Program State')); assert.ok(executionScope); const executionScopeResponse = await dc.variablesRequest({ variablesReference: executionScope.variablesReference });