mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(mobile): show the open tab as one pill with a tabs sheet The phone copied desktop's tab strip, which fits about three tabs cut to ~95 pt and hides a tab that needs you behind an edge dot. The bar now shows only the tab you're in, at full width, with the tab count. Tapping it opens a sheet of every tab grouped by what needs you, with each tab's state and last activity; swiping it steps to the next tab. The + sheet shows agents as a grid above Terminal, Browser and Markdown note, and the header names the branch instead of the tab count. * feat(mobile): pair the tab count with + and open tab actions from the pill The count and its chevron inside the pill read like a menu and hid the "another tab needs you" dot. The count now shares a capsule with +, the way phone browsers put the tab-count button beside new tab, and tapping the pill opens the tab's own actions. * feat(mobile): give the tab count its own button beside + The shared capsule made each half a small target. The count is now a round nav button like +, lined up under the header's buttons. * feat(mobile): draw the tab bar as the strip's square cells The rounded pill and round buttons read as a different control from the strip people know. The open tab is now the strip's raised, underlined cell from the screen edge, with the count and + as square cells in the same row, which also gives them 46x44 pt targets. * fix(mobile): keep a hairline after the tab bar's last cell in the top bar
372 lines
14 KiB
TypeScript
372 lines
14 KiB
TypeScript
import { Platform } from 'react-native'
|
|
import { useMobileTranslation } from '../i18n/use-mobile-translation'
|
|
import { getRepoIdFromWorktreeId } from '../../../src/shared/worktree/id'
|
|
import { useClipboardWriter } from '../platform/clipboard'
|
|
import { Copy, FileText, RefreshCw } from 'lucide-react-native'
|
|
import { MobileSessionTerminalLayoutSheet } from '../terminal/session/MobileSessionTerminalLayoutSheet'
|
|
import { QuickCommandsSheet } from '../terminal/quick-commands/QuickCommandsSheet'
|
|
import { triggerSuccess, triggerError } from '../platform/haptics'
|
|
import { ActionSheetModal } from '../components/ActionSheetModal'
|
|
import { TextInputModal } from '../components/TextInputModal'
|
|
import { MobileTerminalRenameModal } from '../terminal/session/MobileTerminalRenameModal'
|
|
import { ConfirmModal } from '../components/ConfirmModal'
|
|
import { CustomKeyModal } from '../components/CustomKeyModal'
|
|
import { MobileDictationSetupSheet } from '../components/MobileDictationSetupSheet'
|
|
import { useWorkspaceOnPairedHost } from '../navigation/workspace-execution-host'
|
|
import { MobileBrowserTabActionSheet } from './tabs/MobileBrowserTabActionSheet'
|
|
import { getMobileTerminalActionSheetActions } from '../terminal/session/mobile-terminal-action-sheet-actions'
|
|
import { isTerminalPhoneDisplayMode } from '../terminal/session/terminal-phone-display-mode'
|
|
import type { MobileSessionController } from './use-mobile-session-controller'
|
|
import { useMobileAllowAutoCloseActions } from './tabs/mobile-worker-auto-close'
|
|
import { MobileAgentSessionTabActionSheet } from './tabs/MobileAgentSessionTabActionSheet'
|
|
import { MobileNewTabSheet } from './tabs/MobileNewTabSheet'
|
|
|
|
export function MobileSessionSheets({ controller }: { controller: MobileSessionController }) {
|
|
const t = useMobileTranslation()
|
|
const terminalWorkerActions = useMobileAllowAutoCloseActions(
|
|
controller.client,
|
|
controller.actionTarget && { terminal: controller.actionTarget.handle }
|
|
)
|
|
const {
|
|
worktreeId,
|
|
isFolderWorkspaceRoute,
|
|
isFloatingWorkspaceRoute,
|
|
client,
|
|
worktreeName,
|
|
sessionTabs,
|
|
pendingDiffNotesDelivery,
|
|
setPendingDiffNotesDelivery,
|
|
showCreateTabDrawer,
|
|
setShowCreateTabDrawer,
|
|
showQuickCommands,
|
|
setShowQuickCommands,
|
|
setShowCreateBrowserModal,
|
|
showCreateBrowserModal,
|
|
showTerminalLayout,
|
|
setShowTerminalLayout,
|
|
actionTarget,
|
|
setActionTarget,
|
|
markdownActionTarget,
|
|
setMarkdownActionTarget,
|
|
fileActionTarget,
|
|
setFileActionTarget,
|
|
browserActionTarget,
|
|
setBrowserActionTarget,
|
|
discardMarkdownTarget,
|
|
setDiscardMarkdownTarget,
|
|
leaveDrafts,
|
|
setLeaveDrafts,
|
|
setRenameTarget,
|
|
setCustomKeys,
|
|
showCustomKeyModal,
|
|
setShowCustomKeyModal,
|
|
deleteKeyTarget,
|
|
setDeleteKeyTarget,
|
|
terminalModes,
|
|
showDictationSetup,
|
|
closeDictationSetup,
|
|
browserScreencastSupported,
|
|
quickCommandsSupported,
|
|
showToast,
|
|
nativeChatController,
|
|
toggleTabChatView,
|
|
toggleDisplayMode,
|
|
readFileTab,
|
|
leaveSessionDroppingDrafts,
|
|
discardMarkdownLocalContent,
|
|
copyMarkdownPath,
|
|
confirmDiscardMarkdown,
|
|
handleDeleteCustomKey,
|
|
handleManageShortcuts,
|
|
smartRailEnabled,
|
|
handleSmartRailChange,
|
|
handleClearTerminal,
|
|
handleCreateTerminal,
|
|
launchQuickCommand,
|
|
handleCreateMarkdownNote,
|
|
handleCreateBrowser,
|
|
handleBrowserNavigationCommand,
|
|
handleCloseTerminal,
|
|
handleCloseSessionTab,
|
|
bulkCloseActions,
|
|
bulkCloseConfirm,
|
|
closeWithBulkActions,
|
|
createTabAgentStatusRow,
|
|
createTabAgentOptions,
|
|
sendDiffNotesAgentActions
|
|
} = controller
|
|
const clipboard = useClipboardWriter()
|
|
const onPairedHost = useWorkspaceOnPairedHost()
|
|
return (
|
|
<>
|
|
<MobileSessionTerminalLayoutSheet
|
|
controller={controller}
|
|
visible={showTerminalLayout}
|
|
onClose={() => setShowTerminalLayout(false)}
|
|
/>
|
|
<QuickCommandsSheet
|
|
visible={showQuickCommands && quickCommandsSupported === true}
|
|
onClose={() => setShowQuickCommands(false)}
|
|
client={client}
|
|
repoId={
|
|
isFolderWorkspaceRoute || isFloatingWorkspaceRoute
|
|
? null
|
|
: getRepoIdFromWorktreeId(worktreeId) || null
|
|
}
|
|
repoName={worktreeName || null}
|
|
agentPromptMaxLength={controller.quickCommandAgentPromptMaxLength}
|
|
onLaunch={launchQuickCommand}
|
|
/>
|
|
<MobileNewTabSheet
|
|
visible={showCreateTabDrawer}
|
|
workspaceName={worktreeName}
|
|
agentOptions={createTabAgentOptions}
|
|
agentStatusRow={createTabAgentStatusRow}
|
|
// Why: browser/markdown creation resolve a real worktree on the host
|
|
// (browser.tabCreate, files.createFile); the floating sentinel is
|
|
// terminal-only over RPC, so those options hide there.
|
|
canCreateBrowser={!isFloatingWorkspaceRoute}
|
|
canCreateMarkdownNote={!isFloatingWorkspaceRoute && onPairedHost}
|
|
onClose={() => setShowCreateTabDrawer(false)}
|
|
onCreateAgent={(agent) => void handleCreateTerminal(agent)}
|
|
onCreateTerminal={() => void handleCreateTerminal()}
|
|
onCreateBrowser={() => {
|
|
if (browserScreencastSupported !== true) {
|
|
showToast(
|
|
t(
|
|
'session.sheets.browserUpdateRequired',
|
|
'Desktop update required for mobile browser streaming'
|
|
),
|
|
1600
|
|
)
|
|
return
|
|
}
|
|
setShowCreateBrowserModal(true)
|
|
}}
|
|
onCreateMarkdownNote={() => void handleCreateMarkdownNote()}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={pendingDiffNotesDelivery !== null}
|
|
title={t('session.sheets.sendReviewNotes', 'Send Review Notes')}
|
|
message={t('session.sheets.notesHint', 'Choose an agent session for the current notes.')}
|
|
actions={[
|
|
...sendDiffNotesAgentActions,
|
|
{
|
|
id: 'copyNotes',
|
|
label: t('session.sheets.copyNotes', 'Copy Notes'),
|
|
icon: Copy,
|
|
onPress: () => {
|
|
const delivery = pendingDiffNotesDelivery
|
|
setPendingDiffNotesDelivery(null)
|
|
if (!delivery) {
|
|
return
|
|
}
|
|
void clipboard
|
|
.writeText(delivery.prompt)
|
|
.then(() => {
|
|
triggerSuccess()
|
|
showToast(t('session.sheets.notesCopied', 'Notes copied'))
|
|
})
|
|
.catch(() => {
|
|
triggerError()
|
|
showToast(t('session.sheets.copyNotesFailed', "Couldn't copy notes"), 1500)
|
|
})
|
|
}
|
|
}
|
|
]}
|
|
onClose={() => setPendingDiffNotesDelivery(null)}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={actionTarget != null}
|
|
title={actionTarget?.title || t('session.sheets.terminal', 'Terminal')}
|
|
actions={getMobileTerminalActionSheetActions({
|
|
target: actionTarget,
|
|
tabs: sessionTabs.filter((tab) => tab.type === 'terminal'),
|
|
isTabChatView: nativeChatController.isTabChatView,
|
|
nativeChatTranscriptIsLocalReadable: controller.nativeChatTranscriptIsLocalReadable,
|
|
onDismiss: () => setActionTarget(null),
|
|
onToggleChat: toggleTabChatView,
|
|
isPhoneMode: (handle) => isTerminalPhoneDisplayMode(handle, terminalModes),
|
|
onToggleDisplayMode: (handle) => void toggleDisplayMode(handle),
|
|
onRename: setRenameTarget,
|
|
onClear: (target) => void handleClearTerminal(target),
|
|
onClose: (target) => void handleCloseTerminal(target),
|
|
onCloseSessionTab: (tab) => void handleCloseSessionTab(tab),
|
|
bulkCloseActions,
|
|
workerActions: terminalWorkerActions
|
|
})}
|
|
onClose={() => setActionTarget(null)}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={markdownActionTarget != null}
|
|
title={markdownActionTarget?.title || t('session.sheets.markdown', 'Markdown')}
|
|
actions={[
|
|
{
|
|
id: 'refresh',
|
|
label: t('common.refresh', 'Refresh'),
|
|
icon: RefreshCw,
|
|
// Why: dirty refresh opens ConfirmModal; wait for this sheet's native
|
|
// Modal to unmount first (same dual-Modal race as tab Rename, #10331).
|
|
closeBeforePress: true,
|
|
onPress: () => {
|
|
const target = markdownActionTarget
|
|
if (target) {
|
|
discardMarkdownLocalContent(target)
|
|
}
|
|
}
|
|
},
|
|
{
|
|
id: 'copyPath',
|
|
label: t('session.sheets.copyPath', 'Copy Path'),
|
|
icon: FileText,
|
|
onPress: () => {
|
|
const target = markdownActionTarget
|
|
setMarkdownActionTarget(null)
|
|
if (target) {
|
|
void copyMarkdownPath(target)
|
|
}
|
|
}
|
|
},
|
|
...closeWithBulkActions(markdownActionTarget, () => setMarkdownActionTarget(null))
|
|
]}
|
|
onClose={() => setMarkdownActionTarget(null)}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={fileActionTarget != null}
|
|
title={fileActionTarget?.title || t('session.sheets.file', 'File')}
|
|
actions={[
|
|
{
|
|
id: 'refresh',
|
|
label: t('common.refresh', 'Refresh'),
|
|
icon: RefreshCw,
|
|
onPress: () => {
|
|
const target = fileActionTarget
|
|
setFileActionTarget(null)
|
|
if (target) {
|
|
void readFileTab(target)
|
|
}
|
|
}
|
|
},
|
|
...closeWithBulkActions(fileActionTarget, () => setFileActionTarget(null))
|
|
]}
|
|
onClose={() => setFileActionTarget(null)}
|
|
/>
|
|
<MobileBrowserTabActionSheet
|
|
target={browserActionTarget}
|
|
onClose={() => setBrowserActionTarget(null)}
|
|
onNavigate={handleBrowserNavigationCommand}
|
|
onCloseTab={handleCloseSessionTab}
|
|
bulkCloseActions={bulkCloseActions}
|
|
/>
|
|
<MobileAgentSessionTabActionSheet
|
|
controller={controller}
|
|
workspaceOnPairedHost={onPairedHost}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={leaveDrafts != null}
|
|
title={t('session.sheets.unsavedMarkdown', 'Unsaved markdown changes')}
|
|
message={t('session.sheets.draftsHint', 'Copy or discard phone drafts before leaving.')}
|
|
actions={[
|
|
{
|
|
id: 'copyAllAndLeave',
|
|
label: t('session.sheets.copyAllAndLeave', 'Copy All & Leave'),
|
|
icon: FileText,
|
|
onPress: () => {
|
|
const drafts = leaveDrafts ?? []
|
|
const combined = drafts
|
|
.map((draft) => `# ${draft.title}\n\n${draft.content}`)
|
|
.join('\n\n---\n\n')
|
|
void clipboard
|
|
.writeText(combined)
|
|
.then(() => {
|
|
setLeaveDrafts(null)
|
|
leaveSessionDroppingDrafts(drafts)
|
|
})
|
|
.catch(() => {
|
|
triggerError()
|
|
showToast(t('session.sheets.copyDraftsFailed', "Couldn't copy drafts"), 1500)
|
|
})
|
|
}
|
|
},
|
|
{
|
|
id: 'discardAndLeave',
|
|
label: t('session.sheets.discardAndLeave', 'Discard & Leave'),
|
|
destructive: true,
|
|
onPress: () => {
|
|
setLeaveDrafts(null)
|
|
leaveSessionDroppingDrafts(leaveDrafts ?? [])
|
|
}
|
|
}
|
|
]}
|
|
onClose={() => setLeaveDrafts(null)}
|
|
/>
|
|
<ConfirmModal
|
|
visible={discardMarkdownTarget != null}
|
|
title={t('session.sheets.discardChanges', 'Discard Changes')}
|
|
message={t(
|
|
'session.sheets.discardMessage',
|
|
'Replace the phone draft with the latest desktop file?'
|
|
)}
|
|
confirmLabel={t('session.sheets.discard', 'Discard')}
|
|
destructive
|
|
onConfirm={confirmDiscardMarkdown}
|
|
onCancel={() => setDiscardMarkdownTarget(null)}
|
|
/>
|
|
<ConfirmModal {...bulkCloseConfirm} />
|
|
<MobileTerminalRenameModal controller={controller} />
|
|
<TextInputModal
|
|
visible={showCreateBrowserModal}
|
|
title={t('session.sheets.newBrowser', 'New Browser')}
|
|
message={t('session.sheets.urlPrompt', 'Enter a URL, or leave blank for a new tab.')}
|
|
defaultValue=""
|
|
placeholder="https://example.com"
|
|
submitLabel={t('common.open', 'Open')}
|
|
allowEmpty
|
|
selectTextOnFocus
|
|
// The session page reports 'web', where RN Web maps 'url' to the URL keyboard.
|
|
keyboardType={Platform.OS === 'android' ? 'default' : 'url'}
|
|
onSubmit={(value) => {
|
|
void handleCreateBrowser(value).then((created) => {
|
|
if (created) {
|
|
setShowCreateBrowserModal(false)
|
|
}
|
|
})
|
|
}}
|
|
onCancel={() => setShowCreateBrowserModal(false)}
|
|
/>
|
|
<CustomKeyModal
|
|
visible={showCustomKeyModal}
|
|
onClose={() => setShowCustomKeyModal(false)}
|
|
onKeysChanged={setCustomKeys}
|
|
onManageShortcuts={handleManageShortcuts}
|
|
smartRail={{ enabled: smartRailEnabled, onChange: handleSmartRailChange }}
|
|
/>
|
|
<MobileDictationSetupSheet
|
|
visible={showDictationSetup}
|
|
client={client}
|
|
onClose={closeDictationSetup}
|
|
onReady={closeDictationSetup}
|
|
/>
|
|
<ActionSheetModal
|
|
visible={deleteKeyTarget != null}
|
|
title={deleteKeyTarget?.label ?? t('session.sheets.shortcut', 'Shortcut')}
|
|
message={t('session.sheets.removeShortcutMessage', 'Remove this custom shortcut?')}
|
|
actions={[
|
|
{
|
|
id: 'remove',
|
|
label: t('common.remove', 'Remove'),
|
|
destructive: true,
|
|
onPress: () => {
|
|
if (deleteKeyTarget) {
|
|
void handleDeleteCustomKey(deleteKeyTarget)
|
|
}
|
|
setDeleteKeyTarget(null)
|
|
}
|
|
}
|
|
]}
|
|
onClose={() => setDeleteKeyTarget(null)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|