Skip to content

Commit 49a6887

Browse files
committed
Local test merge of PR anomalyco#186: Improve mobile Web UI experience
2 parents a1c9fec + 783a0a7 commit 49a6887

5 files changed

Lines changed: 167 additions & 21 deletions

File tree

‎packages/desktop/src/components/terminal.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export const Terminal = (props: TerminalProps) => {
241241
data-prevent-autofocus
242242
classList={{
243243
...(local.classList ?? {}),
244-
"size-full px-6 py-3 font-mono": true,
244+
"size-full px-3 sm:px-6 py-3 font-mono": true,
245245
[local.class ?? ""]: !!local.class,
246246
}}
247247
{...others}

‎packages/desktop/src/context/layout.tsx‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
7777
filesCount?: number
7878
onOpen?: () => void
7979
}
80+
mobileMessageNav: {
81+
visible?: boolean
82+
messages?: { id: string; title?: string }[]
83+
currentIndex?: number
84+
onSelect?: (index: number) => void
85+
}
8086
}>({
8187
connect: {},
8288
dialog: {},
8389
mobileReview: {},
90+
mobileMessageNav: {},
8491
})
8592
const usedColors = new Set<AvatarColorKey>()
8693

@@ -282,6 +289,21 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
282289
setEphemeral("mobileReview", { visible: false, filesCount: 0, onOpen: undefined })
283290
},
284291
},
292+
mobileMessageNav: {
293+
visible: createMemo(() => ephemeral.mobileMessageNav?.visible ?? false),
294+
messages: createMemo(() => ephemeral.mobileMessageNav?.messages ?? []),
295+
currentIndex: createMemo(() => ephemeral.mobileMessageNav?.currentIndex ?? 0),
296+
onSelect: createMemo(() => ephemeral.mobileMessageNav?.onSelect),
297+
register(messages: { id: string; title?: string }[], currentIndex: number, onSelect: (index: number) => void) {
298+
setEphemeral("mobileMessageNav", { visible: true, messages, currentIndex, onSelect })
299+
},
300+
update(currentIndex: number) {
301+
setEphemeral("mobileMessageNav", "currentIndex", currentIndex)
302+
},
303+
unregister() {
304+
setEphemeral("mobileMessageNav", { visible: false, messages: [], currentIndex: 0, onSelect: undefined })
305+
},
306+
},
285307
theme: {
286308
current: createMemo(() => store.theme),
287309
set(themeId: string) {

‎packages/desktop/src/pages/layout.tsx‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export default function Layout(props: ParentProps) {
723723
}
724724
>
725725
<div class="flex items-center gap-3 min-w-0 grow flex-nowrap">
726-
<div class="flex items-center gap-2 min-w-0">
726+
<div class="hidden sm:flex items-center gap-2 min-w-0">
727727
<Select
728728
options={layout.projects.list().map((project) => project.worktree)}
729729
current={currentDirectory()}
@@ -742,7 +742,7 @@ export default function Layout(props: ParentProps) {
742742
</div>
743743
)}
744744
</Select>
745-
<div class="text-text-weaker hidden sm:block">/</div>
745+
<div class="text-text-weaker">/</div>
746746
</div>
747747
<div class="flex items-center min-w-0 sm:hidden">
748748
<DropdownMenu>
@@ -857,7 +857,44 @@ export default function Layout(props: ParentProps) {
857857
<FontPicker />
858858
<ThemePicker />
859859
</div>
860-
<div class="hidden sm:flex items-center gap-4">
860+
<div class="flex items-center gap-2">
861+
{/* Mobile message navigation */}
862+
<Show when={layout.mobileMessageNav.visible()}>
863+
<div class="sm:hidden">
864+
<DropdownMenu>
865+
<DropdownMenu.Trigger
866+
as={Button}
867+
variant="ghost"
868+
size="small"
869+
class="gap-1 px-2"
870+
>
871+
<span class="text-12-medium">
872+
{layout.mobileMessageNav.currentIndex() + 1}/{layout.mobileMessageNav.messages().length}
873+
</span>
874+
<Icon name="chevron-down" size="small" />
875+
</DropdownMenu.Trigger>
876+
<DropdownMenu.Portal>
877+
<DropdownMenu.Content class="max-w-[calc(100vw-2rem)] max-h-80 overflow-y-auto">
878+
<For each={layout.mobileMessageNav.messages()}>
879+
{(msg, index) => (
880+
<DropdownMenu.Item onSelect={() => layout.mobileMessageNav.onSelect()?.(index())}>
881+
<DropdownMenu.ItemLabel class="flex items-center gap-3">
882+
<span class="text-text-weak shrink-0">{index() + 1}</span>
883+
<span class="truncate">{msg.title || "Message"}</span>
884+
</DropdownMenu.ItemLabel>
885+
<Show when={index() === layout.mobileMessageNav.currentIndex()}>
886+
<DropdownMenu.ItemIndicator>
887+
<Icon name="check-small" size="small" />
888+
</DropdownMenu.ItemIndicator>
889+
</Show>
890+
</DropdownMenu.Item>
891+
)}
892+
</For>
893+
</DropdownMenu.Content>
894+
</DropdownMenu.Portal>
895+
</DropdownMenu>
896+
</div>
897+
</Show>
861898
<Tooltip
862899
class="shrink-0"
863900
value={

‎packages/desktop/src/pages/session.tsx‎

Lines changed: 104 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default function Page() {
128128
userInteracted: false,
129129
stepsExpanded: true,
130130
mobileTabsOpen: false,
131+
mobileTerminalFullscreen: false,
131132
diffSplit: false,
132133
})
133134
let inputRef!: HTMLDivElement
@@ -152,6 +153,25 @@ export default function Page() {
152153
layout.mobileReview.unregister()
153154
})
154155

156+
// Register mobile message navigation in header when there are multiple messages
157+
createEffect(() => {
158+
const messages = visibleUserMessages()
159+
if (messages.length > 1) {
160+
const currentIndex = messages.findIndex((m) => m.id === activeMessage()?.id)
161+
layout.mobileMessageNav.register(
162+
messages.map((m) => ({ id: m.id, title: m.summary?.title })),
163+
currentIndex >= 0 ? currentIndex : 0,
164+
(index) => setActiveMessage(messages[index])
165+
)
166+
} else {
167+
layout.mobileMessageNav.unregister()
168+
}
169+
})
170+
171+
onCleanup(() => {
172+
layout.mobileMessageNav.unregister()
173+
})
174+
155175
createEffect(() => {
156176
if (layout.terminal.opened()) {
157177
if (terminal.all().length === 0) {
@@ -872,24 +892,36 @@ export default function Page() {
872892
<DragDropSensors />
873893
<ConstrainDragYAxis />
874894
<Tabs variant="alt" value={terminal.active()} onChange={terminal.open}>
875-
<Tabs.List class="h-10">
876-
<SortableProvider ids={terminal.all().map((t: LocalPTY) => t.id)}>
877-
<For each={terminal.all()}>{(pty) => <SortableTerminalTab terminal={pty} />}</For>
878-
</SortableProvider>
879-
<div class="h-full flex items-center justify-center">
880-
<Tooltip
881-
value={
882-
<div class="flex items-center gap-2">
883-
<span>New terminal</span>
884-
<span class="text-icon-base text-12-medium">{command.keybind("terminal.new")}</span>
885-
</div>
886-
}
887-
class="flex items-center"
888-
>
889-
<IconButton icon="plus-small" variant="ghost" iconSize="large" onClick={terminal.new} />
895+
<div class="flex h-10">
896+
<Tabs.List class="h-10 flex-1 min-w-0 overflow-x-auto">
897+
<SortableProvider ids={terminal.all().map((t: LocalPTY) => t.id)}>
898+
<For each={terminal.all()}>{(pty) => <SortableTerminalTab terminal={pty} />}</For>
899+
</SortableProvider>
900+
<div class="h-full flex items-center justify-center">
901+
<Tooltip
902+
value={
903+
<div class="flex items-center gap-2">
904+
<span>New terminal</span>
905+
<span class="text-icon-base text-12-medium">{command.keybind("terminal.new")}</span>
906+
</div>
907+
}
908+
class="flex items-center"
909+
>
910+
<IconButton icon="plus-small" variant="ghost" iconSize="large" onClick={terminal.new} />
911+
</Tooltip>
912+
</div>
913+
</Tabs.List>
914+
<div class="sm:hidden h-full flex items-center justify-center shrink-0 px-2 border-l border-border-weak-base">
915+
<Tooltip value="Fullscreen terminal" class="flex items-center">
916+
<IconButton
917+
icon="expand"
918+
variant="ghost"
919+
iconSize="small"
920+
onClick={() => setStore("mobileTerminalFullscreen", true)}
921+
/>
890922
</Tooltip>
891923
</div>
892-
</Tabs.List>
924+
</div>
893925
<For each={terminal.all()}>
894926
{(pty) => (
895927
<Tabs.Content value={pty.id}>
@@ -1083,6 +1115,62 @@ export default function Page() {
10831115
</div>
10841116
</div>
10851117
</Show>
1118+
1119+
{/* Mobile terminal fullscreen overlay */}
1120+
<Show when={store.mobileTerminalFullscreen}>
1121+
<div
1122+
class="fixed inset-0 z-50 sm:hidden flex flex-col bg-background-base"
1123+
style={{
1124+
"padding-top": "var(--safe-area-inset-top)",
1125+
"padding-bottom": "var(--safe-area-inset-bottom)",
1126+
"padding-left": "var(--safe-area-inset-left)",
1127+
"padding-right": "var(--safe-area-inset-right)",
1128+
}}
1129+
>
1130+
<div class="flex-1 min-h-0 overflow-hidden flex flex-col">
1131+
<Tabs variant="alt" value={terminal.active()} onChange={terminal.open} class="flex flex-col h-full">
1132+
<div class="shrink-0 flex h-10">
1133+
<Tabs.List class="flex-1 min-w-0 overflow-x-auto">
1134+
<For each={terminal.all()}>
1135+
{(pty) => (
1136+
<Tabs.Trigger value={pty.id} class="max-w-40 truncate">
1137+
{pty.title}
1138+
</Tabs.Trigger>
1139+
)}
1140+
</For>
1141+
<div class="h-full flex items-center justify-center">
1142+
<IconButton
1143+
icon="plus-small"
1144+
variant="ghost"
1145+
iconSize="large"
1146+
onClick={terminal.new}
1147+
aria-label="New terminal"
1148+
/>
1149+
</div>
1150+
</Tabs.List>
1151+
<div class="h-full flex items-center justify-center shrink-0 px-2 border-l border-border-weak-base">
1152+
<Tooltip value="Exit fullscreen" class="flex items-center">
1153+
<IconButton
1154+
icon="collapse"
1155+
variant="ghost"
1156+
iconSize="small"
1157+
onClick={() => setStore("mobileTerminalFullscreen", false)}
1158+
aria-label="Exit fullscreen"
1159+
/>
1160+
</Tooltip>
1161+
</div>
1162+
</div>
1163+
<For each={terminal.all()}>
1164+
{(pty) => (
1165+
<Tabs.Content value={pty.id} class="flex-1 min-h-0">
1166+
<Terminal pty={pty} onCleanup={terminal.update} onConnectError={() => terminal.clone(pty.id)} />
1167+
</Tabs.Content>
1168+
)}
1169+
</For>
1170+
</Tabs>
1171+
</div>
1172+
</div>
1173+
</Show>
10861174
</Portal>
10871175
</div>
10881176
)

‎packages/ui/src/components/session-message-rail.css‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[data-component="session-message-rail"] {
2-
display: flex;
32
flex-shrink: 0;
43
}
54

0 commit comments

Comments
 (0)