(app)
| 130 | const session = app.getCurrentSession(); |
| 131 | const reservation = session ? app.beginSessionMutation?.(session.id) : null; |
| 132 | if (session && app.beginSessionMutation && !reservation) { |
| 133 | await app.acknowledgeSessionMutationBusy?.(session.id); |
| 134 | return { session, modelName: session.model, busy: true }; |
| 135 | } |
| 136 | try { |
| 137 | |
| 138 | await db.saveSetting('selectedModel', normalizedModelName); |
| 139 | |
| 140 | if (!session) { |
| 141 | app.state.pendingModelName = normalizedModelName; |
| 142 | app.applyPersistedParallelPendingConfig?.(normalizedModelName); |
| 143 | app.renderCurrentModel(); |
| 144 | return { session: null, modelName: normalizedModelName }; |
| 145 | } |
| 146 | |
| 147 | session.model = normalizedModelName; |
| 148 | await db.saveSession(session); |
| 149 | app.renderCurrentModel(); |
| 150 | return { session, modelName: normalizedModelName }; |
| 151 | } finally { |
| 152 | if (reservation) app.endSessionMutation(session.id, reservation); |
| 153 | } |
| 154 | }, |
| 155 | async selectCouncilSecondaryModel(modelName) { |
| 156 | const normalizedModelName = app.normalizeModelName(modelName); |
| 157 | if (app.chatInput?.selectCouncilSecondaryModel) { |
| 158 | await app.chatInput.selectCouncilSecondaryModel(normalizedModelName); |
| 159 | } |
| 160 | return { session: app.getCurrentSession(), modelName: normalizedModelName }; |
| 161 | }, |
no test coverage detected