diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index 1a860dab6..e03966feb 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -20,6 +20,11 @@ the highlighted one. **Escape**, **Tab** or a press elsewhere shut the list with changing anything. Typing the start of an option's name picks it, also with the list shut. A dropdown inside a dialog opens above the dialog and the dialog doesn't cut it off. +On a narrow screen (40em or less, the one width breakpoint the UI has) the header puts +the swarm name and its menus on one row and the nav on a second row that scrolls sideways, the +agent icon on a card shrinks, and the state badges over a terminal stay one row that +scrolls sideways. Nothing makes the page itself scroll sideways at 360px. + A dialog grows to fit its content, up to 64em or nine tenths of the window, whichever is smaller; short confirm dialogs stay short. diff --git a/frontend/packages/swarm-ui/src/agent/AgentIcon.css b/frontend/packages/swarm-ui/src/agent/AgentIcon.css index 67baafb5d..0c583c631 100644 --- a/frontend/packages/swarm-ui/src/agent/AgentIcon.css +++ b/frontend/packages/swarm-ui/src/agent/AgentIcon.css @@ -29,3 +29,10 @@ width: 1.3em; border-radius: 3px; } + +/* A narrow screen: a smaller square, so a card's text keeps its width. */ +@media (max-width: 40em) { + .ui-agent-icon { + width: 3.5em; + } +} diff --git a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css index e9b37bd11..5215a352b 100644 --- a/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css +++ b/frontend/packages/swarm-ui/src/agent/roster/AgentCard.css @@ -3,8 +3,9 @@ message arrangement inside one. */ .ui-agent-card-line1 { display: flex; + flex-wrap: wrap; align-items: center; - gap: 0.6em; + gap: 0.4em 0.6em; } .ui-agent-card-name { font-weight: 600; diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css index 844944079..9a1c737c4 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentTermPreview.css @@ -137,3 +137,20 @@ border-radius: 0 0 0.5em 0.5em; overflow: hidden; } + +/* A narrow screen: the state badges stay one row that scrolls sideways, so the + row over the terminal keeps the height its padding reserves instead of + wrapping onto the first rows of text. */ +@media (max-width: 40em) { + .ui-agent-term-preview-header-badges { + flex-wrap: nowrap; + overflow-x: auto; + scrollbar-width: none; + } + .ui-agent-term-preview-header-badges::-webkit-scrollbar { + display: none; + } + .ui-agent-term-preview-header-badges > * { + flex: none; + } +} diff --git a/frontend/packages/swarm-ui/src/shell/Shell.css b/frontend/packages/swarm-ui/src/shell/Shell.css index 661889cda..8d8a74f79 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.css +++ b/frontend/packages/swarm-ui/src/shell/Shell.css @@ -92,6 +92,34 @@ gap: 1em; position: relative; /* anchor for .shell-nav-indicator */ } +/* A narrow screen (40em, the one width breakpoint the swarm UI has): the brand + and the header's menus share the first row, and the nav takes the second as + one row that scrolls sideways, instead of wrapping into two or three rows + that cover a third of a phone. */ +@media (max-width: 40em) { + .shell-header { + gap: 0.25em 0.75em; + padding: 0.5em 0.75em; + } + .shell-header-actions { + order: 1; + } + .shell-nav { + order: 2; + flex: 1 0 100%; + flex-wrap: nowrap; + overflow-x: auto; + scrollbar-width: none; + } + .shell-nav::-webkit-scrollbar { + display: none; + } + .shell-nav-link, + .shell-tabs { + flex: none; + white-space: nowrap; + } +} /* Holds `SettingsMenu` + `LinksMenu` — one `margin-left: auto` on the wrapper, not one on each child (see Shell.tsx's comment for why two adjacent auto margins don't sit flush together). */ diff --git a/frontend/packages/swarm-ui/src/shell/Shell.tsx b/frontend/packages/swarm-ui/src/shell/Shell.tsx index b625e8a00..b39e49e5b 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.tsx +++ b/frontend/packages/swarm-ui/src/shell/Shell.tsx @@ -304,8 +304,10 @@ export function Shell({ children }: { children: ComponentChildren }) { const navRect = navEl.getBoundingClientRect(); const textRect = textEl.getBoundingClientRect(); return { - left: textRect.left - navRect.left, - top: textRect.bottom - navRect.top, + // Plus the nav's own scroll: on a narrow screen it scrolls sideways, and + // the indicator lives in the scrolled content. + left: textRect.left - navRect.left + navEl.scrollLeft, + top: textRect.bottom - navRect.top + navEl.scrollTop, width: textRect.width, accent: item.accent, };