okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
e9a1215f0
main
1// #5617: a question from the agent (ask_user_question) waited for the person with no notification, although an approval, which waits the same 2// way, notifies when "Notify me when Strata needs an answer" is on. The question now gets that notification: the approval's own title, no body. 3import test from 'node:test' ; 4import assert from 'node:assert/strict' ; 5import { readFileSync } from 'node:fs' ; 6import { build } from 'esbuild' ; 7 8const compiled = await build ({ stdin :{ contents :"export * from './src/lib/attention'; export * from './src/lib/i18n';" , resolveDir :process . cwd () }, bundle :true , write :false , format :'esm' , platform :'node' , loader :{ '.json' :'json' } }); 9const A = await import ( `data:text/javascript;base64, ${ Buffer . from ( compiled . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 10const src = name => readFileSync ( new URL ( `../src/ ${ name } ` , import . meta. url ), 'utf8' ). replace ( / \r\n / g , '\n' ); 11 12test ( 'the question notice is the approval notice\'s title with no new sentence, under the same opt-in' , async () => { 13assert . deepEqual ( A . questionNotice (), { title :'Strata needs your answer' , body :'' }); 14assert . equal ( A . questionNotice (). title , A . approvalNotice ( 'x' ). title ); 15assert . equal ( await A . questionAsked ( false , false ), false , 'off unless the person turned it on' ); 16assert . equal ( await A . questionAsked ( true , true ), false , 'the person is looking at Strata' ); 17}); 18 19test ( 'a new question notifies once; the same question again (a reload, a repeat frame) does not' , () => { 20const store = src ( 'lib/store.ts' ); 21assert . match ( store , / import \{ approvalNeeded, questionAsked, workFinished \} from '\.\/attention'; / ); 22const at = store . indexOf ( 'export function addAgentAsk(' ); 23const body = store . slice ( at , store . indexOf ( '\n}\n' , at )); 24assert . match ( body , / if \(ask && loopScheduler\.isRunning\(sessionId\)\) \{ [ ^ \n ] * return; \} / , 'a /loop question is skipped before anything else' ); 25assert . match ( body , / const known = \(state\.agentAsks\[sessionId\] \?\? \[\]\)\.some\(a => a\.callId === ask\.callId\); / ); 26assert . match ( body , / if \(!known\) void questionAsked\(state\.approvalNotify\); / ); 27});