()
| 1678 | } |
| 1679 | |
| 1680 | async createNewSession(): Promise<void> { |
| 1681 | if (this.state.appState.isReplaying) { |
| 1682 | this.showError('Cannot start a new session while history is replaying.'); |
| 1683 | return; |
| 1684 | } |
| 1685 | |
| 1686 | let session: Session; |
| 1687 | try { |
| 1688 | session = await this.createSessionFromCurrentState(); |
| 1689 | } catch (error) { |
| 1690 | const msg = formatErrorMessage(error); |
| 1691 | this.showError(`Failed to start a new session: ${msg}`); |
| 1692 | return; |
| 1693 | } |
| 1694 | |
| 1695 | this.resetSessionRuntime(); |
| 1696 | await this.setSession(session); |
| 1697 | this.setAppState({ sessionId: session.id }); |
| 1698 | try { |
| 1699 | await this.activateRuntime(); |
| 1700 | await this.syncRuntimeState(session); |
| 1701 | } catch (error) { |
| 1702 | this.sessionEventHandler.startSubscription(); |
| 1703 | const msg = formatErrorMessage(error); |
| 1704 | this.showError(`Post-create setup failed: ${msg}`); |
| 1705 | return; |
| 1706 | } |
| 1707 | try { |
| 1708 | await this.refreshSkillCommands(this.session); |
| 1709 | await this.refreshPluginCommands(this.session); |
| 1710 | } catch { |
| 1711 | /* keep the new session usable even if dynamic skills fail */ |
| 1712 | } |
| 1713 | this.sessionEventHandler.startSubscription(); |
| 1714 | this.clearTranscriptAndRedraw(); |
| 1715 | this.showStatus(`Started a new session (${session.id}).`); |
| 1716 | void this.showSessionWarnings(session); |
| 1717 | void this.showConfigWarningsIfAny(); |
| 1718 | } |
| 1719 | |
| 1720 | /** Surface config.toml load warnings (degraded or kept-previous config) in the status bar. */ |
| 1721 | private async showConfigWarningsIfAny(): Promise<void> { |
nothing calls this directly
no test coverage detected