Get the ID of the session currently displayed in the TUI. This is only available when connecting to a server running in TUI+server mode (--ui-server). Returns: The session ID, or None if no foreground session is set. Raises: Runtime
(self)
| 3101 | return response.get("sessionId") |
| 3102 | |
| 3103 | async def get_foreground_session_id(self) -> str | None: |
| 3104 | """ |
| 3105 | Get the ID of the session currently displayed in the TUI. |
| 3106 | |
| 3107 | This is only available when connecting to a server running in TUI+server mode |
| 3108 | (--ui-server). |
| 3109 | |
| 3110 | Returns: |
| 3111 | The session ID, or None if no foreground session is set. |
| 3112 | |
| 3113 | Raises: |
| 3114 | RuntimeError: If the client is not connected. |
| 3115 | |
| 3116 | Example: |
| 3117 | >>> session_id = await client.get_foreground_session_id() |
| 3118 | >>> if session_id: |
| 3119 | ... print(f"TUI is displaying session: {session_id}") |
| 3120 | """ |
| 3121 | if not self._client: |
| 3122 | raise RuntimeError("Client not connected") |
| 3123 | |
| 3124 | response = await self._client.request("session.getForeground", {}) |
| 3125 | return response.get("sessionId") |
| 3126 | |
| 3127 | async def set_foreground_session_id(self, session_id: str) -> None: |
| 3128 | """ |