@@ -16,6 +16,7 @@ import {
1616 projectSessionObserverDigest ,
1717 resolveChatPaneObserverRunId ,
1818} from "../../lib/observer-digest.ts" ;
19+ import { readSessionMethodAccess } from "../../lib/session-method-access.ts" ;
1920import { buildAgentMainSessionKey } from "../../lib/sessions/session-key.ts" ;
2021import { renderBoardSessionSurface } from "./board-session-surface.ts" ;
2122import { clearChatHistory } from "./chat-history.ts" ;
@@ -79,6 +80,14 @@ export class ChatPane extends ChatPaneHeader {
7980 return html `< main class ="app-shell app-shell--booting " aria-busy ="true "> </ main > ` ;
8081 }
8182 const selectedSession = selectedChatSessionRow ( state ) ;
83+ const runtimePatchAccess = readSessionMethodAccess ( this . context . gateway . snapshot , {
84+ method : "sessions.patch" ,
85+ params : { key : state . sessionKey , model : null } ,
86+ } ) ;
87+ const unarchiveAccess = readSessionMethodAccess ( this . context . gateway . snapshot , {
88+ method : "sessions.patch" ,
89+ params : { key : state . sessionKey , archived : false } ,
90+ } ) ;
8291 const projectedObserverDigest = projectSessionObserverDigest (
8392 selectedSession ?. key ?? state . sessionKey ,
8493 selectedSession ?. observerDigest ,
@@ -336,7 +345,12 @@ export class ChatPane extends ChatPaneHeader {
336345 kind : "composer-replacement" ,
337346 text : t ( "chat.archivedSessionDisabled" ) ,
338347 actionLabel : t ( "common.unarchive" ) ,
339- onAction : ( ) => void this . restoreArchivedSession ( state . sessionKey ) ,
348+ disabledReason : unarchiveAccess . allowed ? undefined : unarchiveAccess . reason ,
349+ onAction : ( ) => {
350+ if ( unarchiveAccess . allowed ) {
351+ void this . restoreArchivedSession ( state . sessionKey ) ;
352+ }
353+ } ,
340354 }
341355 : modelSetupRequired
342356 ? createChatModelSetupBanner ( ( ) => this . context . navigate ( "model-setup" ) )
@@ -395,17 +409,26 @@ export class ChatPane extends ChatPaneHeader {
395409 modelSelectionRuntimeId : selectedSession ?. agentRuntime ?. id ,
396410 modelSwitching : Boolean ( state . chatModelSwitchPromises [ state . sessionKey ] ) ,
397411 modelsLoading : state . chatModelsLoading ,
412+ mutationDisabledReason : runtimePatchAccess . allowed
413+ ? undefined
414+ : runtimePatchAccess . reason ,
398415 sending : state . chatSending ,
399416 sessionKey : state . sessionKey ,
400417 sessionsResult : state . sessionsResult ,
401418 stream : state . chatStream ,
402419 onRequestUpdate : ( ) => state . requestUpdate ?.( ) ,
403420 onFastModeSelect : ( next , targetSessionKey ) =>
404- switchChatFastMode ( state , next , targetSessionKey ) ,
421+ runtimePatchAccess . allowed
422+ ? switchChatFastMode ( state , next , targetSessionKey )
423+ : Promise . resolve ( false ) ,
405424 onModelSelect : ( next , targetSessionKey ) =>
406- switchChatModel ( state , next , targetSessionKey ) ,
425+ runtimePatchAccess . allowed
426+ ? switchChatModel ( state , next , targetSessionKey )
427+ : Promise . resolve ( false ) ,
407428 onThinkingSelect : ( next , targetSessionKey ) =>
408- switchChatThinkingLevel ( state , next , targetSessionKey ) ,
429+ runtimePatchAccess . allowed
430+ ? switchChatThinkingLevel ( state , next , targetSessionKey )
431+ : Promise . resolve ( false ) ,
409432 } ,
410433 onboarding : state . onboarding ,
411434 settings : state . settings ,
0 commit comments