@@ -126,19 +126,21 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
126126 // The session row's access_key is set when the session was created.
127127 // If the current keypair is different, manager APIs return 403
128128 // ("Only admins can perform operations on behalf of other users.")
129- // for any per-session action — disable the buttons upfront instead.
129+ // — but only for the session's owner. Admins viewing another user's
130+ // session (rendered here from SessionDetailContent) are allowed to act
131+ // on behalf of that user, so the gate is owner-only.
130132 const isAccessKeyMismatch =
131133 ! ! session ?. access_key &&
132134 ! ! baiClient . _config . accessKey &&
133135 session . access_key !== baiClient . _config . accessKey ;
136+ const shouldDisableForMismatch = isOwner && isAccessKeyMismatch ;
134137
135138 // Only swap to the mismatch tooltip when switching access keys would
136- // actually unblock the user — i.e. they own the session. For non-owners
137- // the button is already disabled for a different reason and the mismatch
138- // copy ("Switch to that access key to manage this session") would be
139- // misleading.
139+ // actually unblock the user. The button is also disabled when the
140+ // session is inactive — in that case the "switch access key" advice
141+ // is misleading, so fall back to the default tooltip.
140142 const resolveTooltip = ( defaultTitle : string ) =>
141- isAccessKeyMismatch && isOwner
143+ shouldDisableForMismatch && isActive ( session )
142144 ? t ( 'session.AccessKeyMismatchTooltip' )
143145 : defaultTitle ;
144146
@@ -213,7 +215,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
213215 ! isAppSupported ( session ) ||
214216 ! isActive ( session ) ||
215217 ! isOwner ||
216- isAccessKeyMismatch
218+ shouldDisableForMismatch
217219 }
218220 icon = { < BAIJupyterIcon /> }
219221 onClick = { ( ) => {
@@ -250,7 +252,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
250252 ! isAppSupported ( session ) ||
251253 ! isActive ( session ) ||
252254 ! isOwner ||
253- isAccessKeyMismatch
255+ shouldDisableForMismatch
254256 }
255257 icon = { < BAIFileBrowserIcon /> }
256258 onClick = { ( ) => {
@@ -286,7 +288,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
286288 ! isAppSupported ( session ) ||
287289 ! isActive ( session ) ||
288290 ! isOwner ||
289- isAccessKeyMismatch
291+ shouldDisableForMismatch
290292 }
291293 icon = { < BAIAppIcon /> }
292294 onClick = { ( ) => {
@@ -306,7 +308,9 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
306308 < Tooltip title = { resolveTooltip ( t ( 'data.explorer.RunSSH/SFTPserver' ) ) } >
307309 < Button
308310 type = "primary"
309- disabled = { ! isActive ( session ) || ! isOwner || isAccessKeyMismatch }
311+ disabled = {
312+ ! isActive ( session ) || ! isOwner || shouldDisableForMismatch
313+ }
310314 size = { size }
311315 icon = { < BAISftpIcon /> }
312316 onClick = { ( ) => {
@@ -330,7 +334,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
330334 ! isAppSupported ( session ) ||
331335 ! isActive ( session ) ||
332336 ! isOwner ||
333- isAccessKeyMismatch
337+ shouldDisableForMismatch
334338 }
335339 icon = { < BAITerminalAppIcon /> }
336340 onClick = { ( ) => {
@@ -356,7 +360,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
356360 >
357361 < Button
358362 size = { size }
359- disabled = { isAccessKeyMismatch }
363+ disabled = { shouldDisableForMismatch }
360364 icon = { < BAISessionLogIcon /> }
361365 onClick = { ( ) => {
362366 onAction ?.( 'logs' ) ;
@@ -381,7 +385,9 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
381385 < Button
382386 size = { size }
383387 disabled = {
384- session ?. status !== 'RUNNING' || ! isOwner || isAccessKeyMismatch
388+ session ?. status !== 'RUNNING' ||
389+ ! isOwner ||
390+ shouldDisableForMismatch
385391 }
386392 icon = { < BAIContainerCommitIcon /> }
387393 onClick = { ( ) => {
@@ -406,12 +412,12 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
406412 >
407413 < Button
408414 size = { size }
409- disabled = { ! isActive ( session ) || isAccessKeyMismatch }
415+ disabled = { ! isActive ( session ) || shouldDisableForMismatch }
410416 icon = {
411417 < BAITerminateIcon
412418 style = { {
413419 color :
414- isActive ( session ) && ! isAccessKeyMismatch
420+ isActive ( session ) && ! shouldDisableForMismatch
415421 ? token . colorError
416422 : undefined ,
417423 } }
0 commit comments