@@ -30,6 +30,7 @@ import ai.opencode.feature.drawer.keepingSettings |
30 | 30 | import ai.opencode.feature.drawer.persistingSnapshot |
31 | 31 | import ai.opencode.feature.media.BrowserFeature |
32 | 32 | import ai.opencode.feature.session.SessionFeature |
| 33 | +import ai.opencode.feature.settings.SettingsPage |
33 | 34 | import ai.opencode.feature.settings.onboarding.WelcomeFeature |
34 | 35 | import ai.opencode.feature.system.NotificationDestination |
35 | 36 | import ai.opencode.feature.system.SessionDirectory |
@@ -93,6 +94,10 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
93 | 94 | val delegatorClientTools: ClientToolsFeature.State = ClientToolsFeature.State(slot = ClientToolsFeature.State.Slot.Delegator), |
94 | 95 | /** Where that delegator session lives, once read. */ |
95 | 96 | val voiceDelegatorLocation: ClientToolsLocation? = null, |
| 97 | + /** Android only: the session the side-button assistant talks to, which gets the phone's tools. */ |
| 98 | + val assistantScope: AssistantScope? = null, |
| 99 | + /** Android only: Settings › Assistant › Phone Tools is All Calls, so in-app calls get the phone's tools too. */ |
| 100 | + val phoneToolsInAllCalls: Boolean = false, |
96 | 101 | val voiceOpenSession: VoiceOpenSessionFeature.State = VoiceOpenSessionFeature.State(), |
97 | 102 | val connection: Connection = Connection.Idle, |
98 | 103 | val connectionGeneration: Int = 0, |
@@ -468,6 +473,8 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
468 | 473 | /** A session the action names that the list doesn't have. */ |
469 | 474 | data class SystemSessionLoaded(val action: SystemAction, val sessionID: String, val result: Result<OpenCodeSession>) : Action |
470 | 475 | data object SystemActionErrorDismissed : Action |
| 476 | + /** Android only: the assistant panel opens Settings at a page (Voice, Experimental). */ |
| 477 | + data class SettingsPageRequested(val page: SettingsPage) : Action |
471 | 478 | /** The app became active: take what the share sheet left. */ |
472 | 479 | data object PendingSharesRequested : Action |
473 | 480 | data class SharesReceived(val shares: List<ReceivedShare>) : Action |
@@ -496,6 +503,18 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
496 | 503 | data class ClientTools(val action: ClientToolsFeature.Action) : Action |
497 | 504 | data class DelegatorClientTools(val action: ClientToolsFeature.Action) : Action |
498 | 505 | data class VoiceDelegatorLocated(val location: ClientToolsLocation) : Action |
| 506 | + |
| 507 | + /** |
| 508 | + * Android only: the assistant's panel opened for [scope]'s session, or closed (null). The |
| 509 | + * phone's tools stay offered until that session's turn finishes. |
| 510 | + */ |
| 511 | + data class AssistantPanelChanged(val scope: AssistantScope?) : Action |
| 512 | + |
| 513 | + /** Android only: the short wait after the panel closed, for the session to start its turn, is over. */ |
| 514 | + data object AssistantGraceElapsed : Action |
| 515 | + |
| 516 | + /** Android only: Settings › Assistant › Phone Tools changed (All Calls when [allCalls]). */ |
| 517 | + data class PhoneToolsReachChanged(val allCalls: Boolean) : Action |
499 | 518 | data class VoiceOpenSession(val action: VoiceOpenSessionFeature.Action) : Action |
500 | 519 | data class HomeResponse(val attemptID: Int, val result: Result<OpenCodeHomeSnapshot>) : Action |
501 | 520 | /** Server Flow: the switch's server didn't answer in time. */ |
@@ -577,6 +596,13 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
577 | 596 | return Reduced(reduced.state.copy(home = home.copy(drawerOpenRequest = null)), reduced.effect) |
578 | 597 | } |
579 | 598 |
|
| 599 | + private fun settingsPageRequested(state: State, page: SettingsPage): Reduced<State, Action> { |
| 600 | + val home = state.home ?: return Reduced(state) |
| 601 | + val shown = home.showingSettings() |
| 602 | + val settings = shown.settings ?: return Reduced(state.copy(home = shown)) |
| 603 | + return Reduced(state.copy(home = shown.copy(settings = settings.copy(path = listOf(page))))) |
| 604 | + } |
| 605 | + |
580 | 606 | private fun reduceCore(state: State, action: Action): Reduced<State, Action> = when (action) { |
581 | 607 | Action.Task -> { |
582 | 608 | migrateSettingsIfNeeded(state.knownServers) |
@@ -610,6 +636,7 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
610 | 636 | } |
611 | 637 | Action.SystemActionsTaskEnded -> Reduced(state, Effect.cancel(CancelID.SystemActions)) |
612 | 638 | is Action.SystemActionReceived -> systemActionReceived(state, action.action) |
| 639 | + is Action.SettingsPageRequested -> settingsPageRequested(state, action.page) |
613 | 640 | is Action.SystemSessionLoaded -> systemSessionLoaded(state, action) |
614 | 641 | Action.SystemActionErrorDismissed -> Reduced(state.copy(systemActionError = null)) |
615 | 642 | Action.PendingSharesRequested -> { |
@@ -679,7 +706,8 @@ class AppFeature : Reducer<AppFeature.State, AppFeature.Action> { |
679 | 706 | is Action.HomeResponse -> homeResponse(state, action) |
680 | 707 | is Action.ServerSwitchTimedOut -> serverSwitchTimedOut(action.attemptID, state) |
681 | 708 | is Action.Home -> home(state, action.action) |
682 | | - is Action.Welcome, is Action.ClientTools, is Action.DelegatorClientTools, is Action.VoiceDelegatorLocated, is Action.VoiceOpenSession -> Reduced(state) |
| 709 | + is Action.Welcome, is Action.ClientTools, is Action.DelegatorClientTools, is Action.VoiceDelegatorLocated, is Action.VoiceOpenSession, |
| 710 | + is Action.AssistantPanelChanged, Action.AssistantGraceElapsed, is Action.PhoneToolsReachChanged -> Reduced(state) |
683 | 711 | } |
684 | 712 |
|
685 | 713 | /** |
|