@@ -23,6 +23,9 @@ const I18N = {
2323 'ask.multi' : '(多选)' ,
2424 'ask.submit' : '提交' ,
2525 'ask.cancel' : '取消' ,
26+ 'ask.skipped' : '(已跳过)' ,
27+ 'ask.none' : '(未选)' ,
28+ 'ask.join' : '、' ,
2629 'footer.thinking' : '思考中' ,
2730 'footer.streaming' : '输出中' ,
2831 'footer.tool' : '调用工具' ,
@@ -98,6 +101,9 @@ const I18N = {
98101 'ask.multi' : '(multiple)' ,
99102 'ask.submit' : 'Submit' ,
100103 'ask.cancel' : 'Cancel' ,
104+ 'ask.skipped' : '(skipped)' ,
105+ 'ask.none' : '(none)' ,
106+ 'ask.join' : ', ' ,
101107 'footer.thinking' : 'Thinking' ,
102108 'footer.streaming' : 'Responding' ,
103109 'footer.tool' : 'Running tool' ,
@@ -434,15 +440,31 @@ createApp({
434440 this . askSel [ qi ] = this . askSel [ qi ] . map ( ( _ , i ) => i === oi ) ;
435441 }
436442 } ,
443+ // pushAskRecord 把作答折叠成一条 ask-record 消息留在对话流(对齐 TUI 的 kindSystem 档案段,issue #134):
444+ // 每题一行「❓ 问题 → **已选答案**」(多选用顿号连接);skipped=true 记「(已跳过)」。
445+ // 必须在清空 askSel 之前调用 —— 它要读 askSel 取选中项。
446+ pushAskRecord ( questions , skipped ) {
447+ const lines = ( questions || [ ] ) . map ( ( q , qi ) => {
448+ if ( skipped ) return `❓ ${ q . question } — ${ this . t ( 'ask.skipped' ) } ` ;
449+ const sel = ( q . options || [ ] )
450+ . filter ( ( _ , oi ) => this . askSel [ qi ] && this . askSel [ qi ] [ oi ] )
451+ . map ( opt => opt . label ) ;
452+ const ans = sel . length ? sel . join ( this . t ( 'ask.join' ) ) : this . t ( 'ask.none' ) ;
453+ return `❓ ${ q . question } → **${ ans } **` ;
454+ } ) ;
455+ if ( lines . length ) this . messages . push ( { role : 'ask-record' , content : lines . join ( '\n\n' ) } ) ;
456+ } ,
437457 async submitAsk ( ) {
438458 // 组装成与终端一致的格式:{"answers":[{question, selected:[value...]}]}
439- const answers = ( this . askPending || [ ] ) . map ( ( q , qi ) => ( {
459+ const questions = this . askPending || [ ] ;
460+ const answers = questions . map ( ( q , qi ) => ( {
440461 question : q . question ,
441462 selected : ( q . options || [ ] )
442463 . filter ( ( _ , oi ) => this . askSel [ qi ] && this . askSel [ qi ] [ oi ] )
443464 . map ( opt => opt . value || opt . label ) ,
444465 } ) ) ;
445466 const answer = JSON . stringify ( { answers } ) ;
467+ this . pushAskRecord ( questions , false ) ; // 留痕:先于清空 askSel
446468 this . askPending = null ;
447469 this . askSel = [ ] ;
448470 await fetch ( '/api/ask-answer' , {
@@ -452,6 +474,7 @@ createApp({
452474 } ) . catch ( ( ) => { } ) ;
453475 } ,
454476 async cancelAsk ( ) {
477+ this . pushAskRecord ( this . askPending , true ) ; // 取消也留痕:先于清空 askSel
455478 this . askPending = null ;
456479 this . askSel = [ ] ;
457480 await fetch ( '/api/ask-answer' , {
0 commit comments