MCPcopy Index your code
hub / github.com/garrytan/gstack / resolveRef

Method resolveRef

browse/src/tab-session.ts:88–107  ·  view source on GitHub ↗

* Resolve a selector that may be a @ref (e.g., "@e3", "@c1") or a CSS selector. * Returns { locator } for refs or { selector } for CSS selectors.

(selector: string)

Source from the content-addressed store, hash-verified

86 * Returns { locator } for refs or { selector } for CSS selectors.
87 */
88 async resolveRef(selector: string): Promise<{ locator: Locator } | { selector: string }> {
89 if (selector.startsWith('@e') || selector.startsWith('@c')) {
90 const ref = selector.slice(1); // "e3" or "c1"
91 const entry = this.refMap.get(ref);
92 if (!entry) {
93 throw new Error(
94 `Ref ${selector} not found. Run 'snapshot' to get fresh refs.`
95 );
96 }
97 const count = await entry.locator.count();
98 if (count === 0) {
99 throw new Error(
100 `Ref ${selector} (${entry.role} "${entry.name}") is stale — element no longer exists. ` +
101 `Run 'snapshot' for fresh refs.`
102 );
103 }
104 return { locator: entry.locator };
105 }
106 return { selector };
107 }
108
109 /** Get the ARIA role for a ref selector, or null for CSS selectors / unknown refs. */
110 getRefRole(selector: string): string | null {

Callers 4

batch.test.tsFile · 0.45
handleWriteCommandFunction · 0.45
handleMetaCommandFunction · 0.45
handleReadCommandFunction · 0.45

Calls 1

getMethod · 0.45

Tested by

no test coverage detected