返回 DeepSeek-Reasonix
permission_session_fence.go
根目录 / desktop / permission_session_fence.go
1 package main
2
3 import (
4 "errors"
5 "strings"
6
7 "reasonix/internal/control"
8 )
9
10 // errPermissionSessionChanged refuses a preset choice read from a session the
11 // tab no longer shows; the bridge carries it as reasonix_error:permission_session_changed.
12 var errPermissionSessionChanged = errors.New("permission choice was made in another session")
13
14 const permissionSessionChangedCode = "permission_session_changed"
15
16 func requirePermissionSession(live control.PermissionSnapshot, expectedSessionID string) error {
17 expected := strings.TrimSpace(expectedSessionID)
18 if expected != "" && expected == strings.TrimSpace(live.SessionID) {
19 return nil
20 }
21 return &inboxCodedError{code: permissionSessionChangedCode, cause: errPermissionSessionChanged}
22 }
23
23 lines GO