| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "reasonix/internal/control" |
| 5 | goaldomain "reasonix/internal/goal" |
| 6 | "reasonix/internal/session" |
| 7 | ) |
| 8 | |
| 9 | // TabMeta is the frontend-facing shape of one tab. |
| 10 | type TabMeta struct { |
| 11 | ID string `json:"id"` |
| 12 | Scope string `json:"scope"` |
| 13 | WorkspaceRoot string `json:"workspaceRoot"` |
| 14 | WorkspaceID string `json:"workspaceId,omitempty"` |
| 15 | WorkspaceName string `json:"workspaceName"` |
| 16 | WorkspacePath string `json:"workspacePath,omitempty"` |
| 17 | GitBranch string `json:"gitBranch,omitempty"` |
| 18 | IsolatedWorktree bool `json:"isolatedWorktree,omitempty"` |
| 19 | Remote *RemoteTabRef `json:"remote,omitempty"` |
| 20 | // RemoteState seeds restored remote shells before their first state event. |
| 21 | RemoteState string `json:"remoteState,omitempty"` |
| 22 | // ForkTargetsSupported reports whether this tab can fork a turn into an |
| 23 | // independent child session. False for a local tab and for a remote serve |
| 24 | // before its handshake; always emitted, so absence never means "unsupported". |
| 25 | ForkTargetsSupported bool `json:"forkTargetsSupported"` |
| 26 | InteractionTargetSupported bool `json:"interactionTargetSupported"` |
| 27 | ExtensionFormInstanceSupported bool `json:"extensionFormInstanceSupported"` |
| 28 | TopicID string `json:"topicId"` |
| 29 | TopicTitle string `json:"topicTitle"` |
| 30 | SessionPath string `json:"sessionPath,omitempty"` |
| 31 | SessionID string `json:"sessionId,omitempty"` |
| 32 | Session *session.SessionRef `json:"session,omitempty"` |
| 33 | SessionRevision int64 `json:"sessionRevision,omitempty"` |
| 34 | SessionDigest string `json:"sessionDigest,omitempty"` |
| 35 | SessionGeneration uint64 `json:"sessionGeneration,omitempty"` |
| 36 | ReadOnly bool `json:"readOnly,omitempty"` |
| 37 | // TakenOver marks a local or remote tab spectating a session whose writer is |
| 38 | // on the other side of a cooperative handoff. |
| 39 | TakenOver bool `json:"takenOver,omitempty"` |
| 40 | ProjectColor string `json:"projectColor,omitempty"` |
| 41 | Label string `json:"label"` |
| 42 | Ready bool `json:"ready"` |
| 43 | Runtime SessionRuntimeView `json:"runtime"` |
| 44 | Running bool `json:"running"` |
| 45 | TurnStartedAt int64 `json:"turnStartedAt,omitempty"` |
| 46 | PendingPrompt bool `json:"pendingPrompt,omitempty"` |
| 47 | RemoteControlled bool `json:"remoteControlled,omitempty"` |
| 48 | BackgroundJobs int `json:"backgroundJobs,omitempty"` |
| 49 | CancelRequested bool `json:"cancelRequested,omitempty"` |
| 50 | Cancellable bool `json:"cancellable"` |
| 51 | TurnID string `json:"turnId,omitempty"` |
| 52 | TurnStatus string `json:"turnStatus,omitempty"` |
| 53 | TurnEventSeq uint64 `json:"turnEventSeq,omitempty"` |
| 54 | TurnReplayAfter uint64 `json:"turnReplayAfterSeq,omitempty"` |
| 55 | Mode string `json:"mode"` |
| 56 | CollaborationMode string `json:"collaborationMode"` |
| 57 | ToolApprovalMode string `json:"toolApprovalMode"` |
| 58 | TokenMode string `json:"tokenMode"` |
| 59 | AgentPreset string `json:"agentPreset,omitempty"` |
| 60 | QualityFloor string `json:"qualityFloor,omitempty"` |
| 61 | FloorInferred bool `json:"floorInferred,omitempty"` |
| 62 | Goal string `json:"goal,omitempty"` |
| 63 | GoalStatus string `json:"goalStatus,omitempty"` |
| 64 | GoalView *goaldomain.View `json:"goalView,omitempty"` |
| 65 | Recovered bool `json:"recovered,omitempty"` |
| 66 | RecoveryReason string `json:"recoveryReason,omitempty"` |
| 67 | RecoveryDigest string `json:"recoveryDigest,omitempty"` |
| 68 | RecoveryParentID string `json:"recoveryParentId,omitempty"` |
| 69 | VersionKind string `json:"versionKind,omitempty"` |
| 70 | VersionState string `json:"versionState,omitempty"` |
| 71 | ParentVersionID string `json:"parentVersionId,omitempty"` |
| 72 | StartupErr string `json:"startupErr,omitempty"` |
| 73 | HistoricalSource *SessionSourceRef `json:"historicalSource,omitempty"` |
| 74 | Authentication *control.AuthenticationState `json:"authentication,omitempty"` |
| 75 | ModelSettingsPending bool `json:"modelSettingsPending,omitempty"` |
| 76 | Active bool `json:"active"` |
| 77 | Cwd string `json:"cwd"` |
| 78 | } |
| 79 | |
| 80 | // setAuthenticationMeta only exposes pending settings belonging to this runtime. |
| 81 | // A replacement controller must never inherit an older generation's hint. |
| 82 | func (m *TabMeta) setAuthenticationMeta(tab *WorkspaceTab) { |
| 83 | if auth, ok := tab.Ctrl.(interface { |
| 84 | AuthenticationState() control.AuthenticationState |
| 85 | }); ok { |
| 86 | state := auth.AuthenticationState() |
| 87 | m.Authentication = &state |
| 88 | } |
| 89 | if extras := tab.metaExtras.Load(); extras != nil && extras.controller == tab.Ctrl { |
| 90 | m.ModelSettingsPending = extras.modelSettingsPending |
| 91 | } |
| 92 | } |
| 93 |