This directory validates render-wait conditions and matches them against semantic snapshots. prepareRenderWaitCondition checks a waitForRender condition from user input and compiles its regex once. matchRenderWaitSnapshot reports whether a snapshot satisfies the text, cursor, stability and baseline parts of the condition. limits.ts holds the length limits that src/protocol/schemas.ts also uses. Callers include src/cli/commands/wait.ts, src/host/hostMain.ts and src/batch/plan.ts.
MAX_WAIT_FOR_RENDER_TEXT_LENGTH(1000),MAX_WAIT_FOR_RENDER_REGEX_LENGTH(200) andMAX_WAIT_FOR_RENDER_REGEX_TEXT_LENGTH(50,000) [limits.ts:MAX_WAIT_FOR_RENDER_TEXT_LENGTH].matcher.tsre-exports all three.PreparedRenderWaitCondition: thetext,regex,scope,screenStableMs,cursorRow,cursorColandafterSeqfields ofWaitForRenderParamsfromsrc/protocol/messages.ts, plus an optionalcompiledRegex[matcher.ts:PreparedRenderWaitCondition].prepareRenderWaitCondition(condition)validates the condition and returns aPreparedRenderWaitCondition[matcher.ts:prepareRenderWaitCondition].matchRenderWaitSnapshot(condition, snapshot, options?)returnsmatchedplus the per-part resultstextMatched,cursorMatched,stabilityMatchedandbaselineMatched, pluscontentAndCursorMatched, the matched text, the cursor,capturedAtSeqand the canonicalvisibleLines[matcher.ts:matchRenderWaitSnapshot].contentAndCursorMatchedlets the offline fallback insrc/cli/commands/wait.tstell a stability result it cannot prove from a mismatch.hasNestedQuantifiers(pattern)detects a quantified group that already contains a quantifier [matcher.ts:hasNestedQuantifiers].safeRegexExec(regex, text)runsregex.execon text cut toMAX_WAIT_FOR_RENDER_REGEX_TEXT_LENGTHcharacters [matcher.ts:safeRegexExec].
prepareRenderWaitConditionthrows anINVALID_INPUTCLI error when a rule fails [matcher.ts:prepareRenderWaitCondition]:- The condition needs at least one of
text,regex,screenStableMs,cursorRoworcursorCol.afterSeqalone is not enough. textandregexcannot both be set. Scopecursor-lineneedstextorregex.textlength must be 1 to 1000.regexlength must be 1 to 200.- A regex with nested quantifiers or an invalid pattern is rejected.
screenStableMsmust be a positive integer.cursorRow,cursorColandafterSeqmust be non-negative integers.
- The condition needs at least one of
- The compiled regex has no flags [matcher.ts:prepareRenderWaitCondition].
matchRenderWaitSnapshotasserts withinvariantthat a regex condition carriescompiledRegexand that it is not global or sticky. It also asserts non-negative integer cursor andcapturedAtSeqvalues [matcher.ts:matchRenderWaitSnapshot].- Text matching is a substring check on the canonical visible text, or on the cursor row for scope
cursor-line[matcher.ts:matchRenderWaitSnapshot]. - A snapshot meets the baseline only when
capturedAtSeq > afterSeq[matcher.ts:matchRenderWaitSnapshot]. - With
screenStableMsset and nostableForMsoption,stabilityMatchedis false [matcher.ts:matchRenderWaitSnapshot].
- None found in code.
- Run:
npx vitest run test/unit/renderWait - Run:
npm run typecheck