@@ -407,6 +407,12 @@ window.__ModuleLoader__.load({
407407 "memory.explorer.scopeBadge" : "作用域" ,
408408 "memory.explorer.detail.agentScope" : "Agent 作用域" ,
409409 "memory.explorer.detail.workspaceScope" : "工作区作用域" ,
410+ "memory.explorer.detail.scopeGlobal" : "全局(所有会话可见)" ,
411+ "memory.explorer.detail.scopeSourceAuto" : "自动" ,
412+ "memory.explorer.detail.scopeSourceExplicit" : "显式" ,
413+ "memory.explorer.detail.scopeEditHint" : "留空 = 全局;也可填写具体标签收窄归属" ,
414+ "memory.explorer.detail.scopeWidenConfirm" : "确认放宽可见性?" ,
415+ "memory.explorer.detail.scopeWidenHint" : "放宽后该记忆将对所有会话可见" ,
410416 "memory.explorer.detail.sensitivity" : "敏感度" ,
411417 "memory.explorer.detail.occurred" : "发生时间" ,
412418 "memory.explorer.detail.edit" : "编辑" ,
@@ -748,6 +754,12 @@ window.__ModuleLoader__.load({
748754 "memory.explorer.scopeBadge" : "Scoped" ,
749755 "memory.explorer.detail.agentScope" : "Agent scope" ,
750756 "memory.explorer.detail.workspaceScope" : "Workspace scope" ,
757+ "memory.explorer.detail.scopeGlobal" : "Global (visible to all sessions)" ,
758+ "memory.explorer.detail.scopeSourceAuto" : "auto" ,
759+ "memory.explorer.detail.scopeSourceExplicit" : "explicit" ,
760+ "memory.explorer.detail.scopeEditHint" : "Empty = global; or enter a specific label to narrow the scope" ,
761+ "memory.explorer.detail.scopeWidenConfirm" : "Widen visibility?" ,
762+ "memory.explorer.detail.scopeWidenHint" : "Widening makes this memory visible to all sessions" ,
751763 "memory.explorer.detail.sensitivity" : "Sensitivity" ,
752764 "memory.explorer.detail.occurred" : "Occurred" ,
753765 "memory.explorer.detail.edit" : "Edit" ,
@@ -3191,11 +3203,30 @@ window.__ModuleLoader__.load({
31913203 // 右侧滑出:全文、来源、质量分、关联实体与手动操作(编辑/归档/删除)。
31923204 // 编辑态本地暂存草稿,保存经 POST /update 落库;后端成功后重渲染镜像,
31933205 // 前端只做本地视图同步。两步删除确认在此完成(红钮武装 → 实心红提交)。
3206+ // v0.8.1 底座(issue #170):scope 行的来源徽注(显式/自动)。存量行无来源
3207+ // 时不加后缀——与 A4 的「未标注零视觉变化」同款克制。
3208+ const scopeSourceSuffix = ( t , source ) =>
3209+ source === "explicit" ? ` · ${ t ( "memory.explorer.detail.scopeSourceExplicit" ) } `
3210+ : source === "auto" ? ` · ${ t ( "memory.explorer.detail.scopeSourceAuto" ) } `
3211+ : "" ;
3212+ const scopeProvenanceTitle = ( t , source , decidedAt ) =>
3213+ [
3214+ source === "explicit" ? t ( "memory.explorer.detail.scopeSourceExplicit" )
3215+ : source === "auto" ? t ( "memory.explorer.detail.scopeSourceAuto" ) : null ,
3216+ decidedAt ?? null
3217+ ] . filter ( Boolean ) . join ( " · " ) ;
3218+
31943219 function MemoryDrawer ( { t, memory, conflict, deleting, deleteError, onClose, onDelete, onSaved } ) {
31953220 const [ editing , setEditing ] = useState ( false ) ;
31963221 const [ title , setTitle ] = useState ( memory . title || "" ) ;
31973222 const [ content , setContent ] = useState ( memory . content || "" ) ;
31983223 const [ importance , setImportance ] = useState ( memory . importance || 3 ) ;
3224+ // v0.8.1 底座(issue #170):scope 归属的人工修正入口。空串=放宽到全局
3225+ // (发送 null),非空=收窄到该标签;只有真的改动才会随 patch 发送并盖
3226+ // explicit 章——普通编辑不得污染归属来源。
3227+ const [ agentScope , setAgentScope ] = useState ( memory . agent_scope || "" ) ;
3228+ const [ workspaceScope , setWorkspaceScope ] = useState ( memory . workspace_scope || "" ) ;
3229+ const [ confirmWiden , setConfirmWiden ] = useState ( false ) ;
31993230 const [ confirmDelete , setConfirmDelete ] = useState ( false ) ;
32003231 const [ busy , setBusy ] = useState ( false ) ;
32013232 const [ savedTick , setSavedTick ] = useState ( false ) ;
@@ -3234,7 +3265,25 @@ window.__ModuleLoader__.load({
32343265 const save = ( ) => {
32353266 const t2 = title . trim ( ) ;
32363267 if ( ! t2 ) return ;
3237- postUpdate ( { title : t2 , content, importance } , { } ) ;
3268+ const patch = { title : t2 , content, importance } ;
3269+ const curAgent = memory . agent_scope ?? "" ;
3270+ const curWorkspace = memory . workspace_scope ?? "" ;
3271+ const nextAgent = agentScope . trim ( ) ;
3272+ const nextWorkspace = workspaceScope . trim ( ) ;
3273+ const agentChanged = nextAgent !== curAgent ;
3274+ const workspaceChanged = nextWorkspace !== curWorkspace ;
3275+ if ( agentChanged ) patch . agent_scope = nextAgent || null ;
3276+ if ( workspaceChanged ) patch . workspace_scope = nextWorkspace || null ;
3277+ // 放宽可见性(标注→全局)必须显式确认(issue #170 的安全阀):
3278+ // 第一次点保存只弹确认,再次点「确认放宽」才真正落库。
3279+ const widening = ( curAgent && agentChanged && ! nextAgent )
3280+ || ( curWorkspace && workspaceChanged && ! nextWorkspace ) ;
3281+ if ( widening && ! confirmWiden ) {
3282+ setConfirmWiden ( true ) ;
3283+ return ;
3284+ }
3285+ setConfirmWiden ( false ) ;
3286+ postUpdate ( patch , { } ) ;
32383287 } ;
32393288
32403289 return h ( "aside" , { className : "mneme-drawer" , "aria-label" : t ( "memory.explorer.detail" ) } ,
@@ -3278,12 +3327,40 @@ window.__ModuleLoader__.load({
32783327 memory . occurred_at && h ( react . Fragment , null ,
32793328 h ( "span" , { className : "mneme-dmetakey" } , t ( "memory.explorer.detail.occurred" ) ) ,
32803329 h ( "span" , { className : "mneme-dmetaval" , title : memory . occurred_at } , formatDateShort ( memory . occurred_at ) ) ) ,
3281- memory . agent_scope && h ( react . Fragment , null ,
3330+ // v0.8.1 底座:scope 行双态——查看态展示归属 + 来源徽注(显式声明的
3331+ // 「全局」也渲染,不再因 NULL 而隐身);编辑态为文本框(留空=全局)。
3332+ ( editing || memory . agent_scope || memory . agent_scope_source === "explicit" ) && h ( react . Fragment , null ,
32823333 h ( "span" , { className : "mneme-dmetakey" } , t ( "memory.explorer.detail.agentScope" ) ) ,
3283- h ( "span" , { className : "mneme-dmetaval" , title : memory . agent_scope } , memory . agent_scope ) ) ,
3284- memory . workspace_scope && h ( react . Fragment , null ,
3334+ editing
3335+ ? h ( "input" , {
3336+ type : "text" ,
3337+ className : "mneme-select" ,
3338+ style : { height : 26 , fontSize : 12 , justifySelf : "start" , width : "100%" } ,
3339+ value : agentScope ,
3340+ placeholder : t ( "memory.explorer.detail.scopeGlobal" ) ,
3341+ title : t ( "memory.explorer.detail.scopeEditHint" ) ,
3342+ onChange : ( e ) => setAgentScope ( e . target . value )
3343+ } )
3344+ : h ( "span" , {
3345+ className : "mneme-dmetaval" ,
3346+ title : scopeProvenanceTitle ( t , memory . agent_scope_source , memory . scope_decided_at ) || memory . agent_scope
3347+ } , ( memory . agent_scope ?? t ( "memory.explorer.detail.scopeGlobal" ) ) + scopeSourceSuffix ( t , memory . agent_scope_source ) ) ) ,
3348+ ( editing || memory . workspace_scope || memory . workspace_scope_source === "explicit" ) && h ( react . Fragment , null ,
32853349 h ( "span" , { className : "mneme-dmetakey" } , t ( "memory.explorer.detail.workspaceScope" ) ) ,
3286- h ( "span" , { className : "mneme-dmetaval" , title : memory . workspace_scope } , memory . workspace_scope ) ) ,
3350+ editing
3351+ ? h ( "input" , {
3352+ type : "text" ,
3353+ className : "mneme-select" ,
3354+ style : { height : 26 , fontSize : 12 , justifySelf : "start" , width : "100%" } ,
3355+ value : workspaceScope ,
3356+ placeholder : t ( "memory.explorer.detail.scopeGlobal" ) ,
3357+ title : t ( "memory.explorer.detail.scopeEditHint" ) ,
3358+ onChange : ( e ) => setWorkspaceScope ( e . target . value )
3359+ } )
3360+ : h ( "span" , {
3361+ className : "mneme-dmetaval" ,
3362+ title : scopeProvenanceTitle ( t , memory . workspace_scope_source , memory . scope_decided_at ) || memory . workspace_scope
3363+ } , ( memory . workspace_scope ?? t ( "memory.explorer.detail.scopeGlobal" ) ) + scopeSourceSuffix ( t , memory . workspace_scope_source ) ) ) ,
32873364 memory . sensitivity && h ( react . Fragment , null ,
32883365 h ( "span" , { className : "mneme-dmetakey" } , t ( "memory.explorer.detail.sensitivity" ) ) ,
32893366 h ( "span" , { className : "mneme-dmetaval" , title : memory . sensitivity } , memory . sensitivity ) ) ,
@@ -3316,7 +3393,16 @@ window.__ModuleLoader__.load({
33163393 h ( "div" , { className : "mneme-dactions" } ,
33173394 editing
33183395 ? h ( react . Fragment , null ,
3319- h ( "button" , { type : "button" , className : "mneme-btn" , disabled : busy , onClick : save } , t ( "memory.explorer.detail.save" ) ) ,
3396+ confirmWiden
3397+ ? h ( react . Fragment , null ,
3398+ h ( "span" , { style : { fontSize : 12 , color : "var(--dsw-alias-state-warn,#b8860b)" } } ,
3399+ t ( "memory.explorer.detail.scopeWidenHint" ) ) ,
3400+ h ( "button" , { type : "button" , className : "mneme-btn mneme-btndangerconfirm" , disabled : busy , onClick : save } ,
3401+ t ( "memory.explorer.detail.scopeWidenConfirm" ) ) ,
3402+ h ( "button" , { type : "button" , className : "mneme-btn" , disabled : busy , onClick : ( ) => setConfirmWiden ( false ) } ,
3403+ t ( "memory.explorer.cancel" ) )
3404+ )
3405+ : h ( "button" , { type : "button" , className : "mneme-btn" , disabled : busy , onClick : save } , t ( "memory.explorer.detail.save" ) ) ,
33203406 h ( "button" , {
33213407 type : "button" ,
33223408 className : "mneme-btn" ,
@@ -3326,6 +3412,9 @@ window.__ModuleLoader__.load({
33263412 setTitle ( memory . title || "" ) ;
33273413 setContent ( memory . content || "" ) ;
33283414 setImportance ( memory . importance || 3 ) ;
3415+ setAgentScope ( memory . agent_scope || "" ) ;
3416+ setWorkspaceScope ( memory . workspace_scope || "" ) ;
3417+ setConfirmWiden ( false ) ;
33293418 }
33303419 } , t ( "memory.explorer.detail.cancel" ) ) ,
33313420 savedTick && h ( "span" , { className : "mneme-saved" } , t ( "memory.explorer.detail.saved" ) ) ,
0 commit comments