@@ -14,6 +14,7 @@ import { buildSelectorChainForNode } from '../utils/selector-build.ts';
1414import { evaluateIsPredicate , isSupportedPredicate } from '../utils/selector-is-predicates.ts' ;
1515import type { RuntimeCommand } from './index.ts' ;
1616import {
17+ type CapturedSnapshot ,
1718 captureSelectorSnapshot ,
1819 readText ,
1920 requireSnapshotSession ,
@@ -177,8 +178,8 @@ export const getCommand: RuntimeCommand<GetCommandOptions, GetCommandResult> = a
177178 runtime ,
178179 options ,
179180) : Promise < GetCommandResult > => {
180- const capture = await requireSnapshotSession ( runtime , options . session ) ;
181181 if ( options . target . kind === 'ref' ) {
182+ const capture = await requireSnapshotSession ( runtime , options . session ) ;
182183 const resolved = resolveRefNode ( capture . snapshot . nodes , options . target . ref , {
183184 fallbackLabel : options . target . fallbackLabel ?? '' ,
184185 invalidRefMessage : 'get text requires a ref like @e2' ,
@@ -195,7 +196,7 @@ export const getCommand: RuntimeCommand<GetCommandOptions, GetCommandResult> = a
195196 return { kind : 'text' , target, text, node : resolved . node , selectorChain } ;
196197 }
197198
198- const resolved = await resolveSelectorNode ( runtime , options , capture . sessionName , {
199+ const resolved = await resolveSelectorNode ( runtime , options , options . session ?? 'default' , {
199200 selector : options . target . selector ,
200201 disambiguateAmbiguous : options . property === 'text' ,
201202 } ) ;
@@ -213,7 +214,7 @@ export const getCommand: RuntimeCommand<GetCommandOptions, GetCommandResult> = a
213214 } ;
214215 }
215216
216- const text = await readText ( runtime , capture , resolved . node ) ;
217+ const text = await readText ( runtime , resolved . capture , resolved . node ) ;
217218 return {
218219 kind : 'text' ,
219220 target : { kind : 'selector' , selector : resolved . selector } ,
@@ -455,7 +456,7 @@ async function resolveSelectorNode(
455456 options : GetCommandOptions ,
456457 sessionName : string ,
457458 params : { selector : string ; disambiguateAmbiguous : boolean } ,
458- ) : Promise < { node : SnapshotNode ; selector : string ; ref : string } > {
459+ ) : Promise < { capture : CapturedSnapshot ; node : SnapshotNode ; selector : string ; ref : string } > {
459460 const capture = await captureSelectorSnapshot (
460461 runtime ,
461462 { ...options , session : sessionName } ,
@@ -473,5 +474,10 @@ async function resolveSelectorNode(
473474 if ( ! resolved ) {
474475 throw new AppError ( 'COMMAND_FAILED' , formatSelectorFailure ( chain , [ ] , { unique : true } ) ) ;
475476 }
476- return { node : resolved . node , selector : resolved . selector . raw , ref : `@${ resolved . node . ref } ` } ;
477+ return {
478+ capture,
479+ node : resolved . node ,
480+ selector : resolved . selector . raw ,
481+ ref : `@${ resolved . node . ref } ` ,
482+ } ;
477483}
0 commit comments