The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Hub: the new filters and harness page controls fit a phone and a mouse (#1085)
Jacob Phamb2f7992e36e8
diff --git a/website/src/app/hub/community.module.css b/website/src/app/hub/community.module.cssindex 3e2847fb6..ea4ab650b 100644--- a/website/src/app/hub/community.module.css+++ b/website/src/app/hub/community.module.css@@ -119,7 +119,7 @@@media(min-width:1900px){.viewer iframe{height:780px}}@media(max-width:1100px){.wrap{width:90%}.nav{gap:20px}.barActions{gap:18px}.chat{padding-left:22px}.actions{gap:13px}.identity h1{font-size:22px}.viewer iframe{height:640px}}@media(max-width:760px){.wrap{width:92%}.feed{padding-top:22px}.grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:44px 14px}.split{grid-template-columns:1fr;gap:28px;min-height:0}.chat{padding:0}.detail{padding-top:16px;padding-bottom:50px}.back{margin-bottom:14px}.detailHead{flex-wrap:wrap;gap:16px;margin-bottom:22px}.actions{margin-left:auto}.viewer iframe{height:590px}.forkColumns,.publishForm{grid-template-columns:1fr;gap:25px}.fork h1,.publish h1{font-size:32px}.page input,.page textarea,.page select{font-size:16px}}-@media(max-width:480px){.grid{grid-template-columns:1fr;gap:36px}.actions{width:100%;margin-left:0;gap:22px}.actions .primary{margin-left:auto}.identity h1{font-size:23px}.viewer iframe{height:510px;height:min(560px,68svh)}.fork{padding-top:20px}.publish{padding-top:24px}.fork h1,.publish h1{font-size:28px}.publishForm{gap:25px}}+@media(max-width:480px){.grid{grid-template-columns:1fr;gap:36px}.actions{width:100%;margin-left:0;gap:22px}.actions>:last-child{margin-left:auto}.identity h1{font-size:23px}.viewer iframe{height:510px;height:min(560px,68svh)}.fork{padding-top:20px}.publish{padding-top:24px}.fork h1,.publish h1{font-size:28px}.publishForm{gap:25px}}.tags{display:inline-flex;gap:5px;flex-wrap:wrap;align-items:center}.tags>span{display:inline-block;background:#f3f3f1;color:#747471;font:10px/1.5 Arial,Helvetica,sans-serif;padding:3px 7px;border-radius:3px;white-space:nowrap}.cardMeta{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px}@@ -138,28 +138,49 @@.fileRow>details{flex:1;min-width:0}.sourceText{max-height:320px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;background:#f6f6f4;padding:14px;font:11px/1.7 ui-monospace,monospace}-/* Feed filters: one category at a time, and the order. */-.filters{display:flex;align-items:center;justify-content:space-between;gap:20px;margin:0 0 38px}-.chips{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;min-width:0}+/* Feed filters: one category at a time, and the order, on one row at every width. The chips scroll+ sideways under a fade that says there are more; the order keeps its place at the end. */+.filters{display:flex;align-items:center;gap:20px;margin:0 0 38px}+.chipsWrap{position:relative;flex:1;min-width:0}+.chips{--fade-left:0px;--fade-right:0px;display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;overscroll-behavior-x:contain;scroll-snap-type:x proximity;-webkit-mask-image:linear-gradient(90deg,transparent,#000 var(--fade-left),#000 calc(100% - var(--fade-right)),transparent);mask-image:linear-gradient(90deg,transparent,#000 var(--fade-left),#000 calc(100% - var(--fade-right)),transparent)}+.chips[data-fade-left]{--fade-left:48px}+.chips[data-fade-right]{--fade-right:48px}+/* Arrows over each end that hides more: small glass chips, above the fade. */+.page .chipArrow{position:absolute;z-index:1;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;min-height:0;border-radius:50%;color:#242424;background:rgba(255,255,255,.78);-webkit-backdrop-filter:saturate(180%) blur(12px);backdrop-filter:saturate(180%) blur(12px);box-shadow:0 1px 0 rgba(255,255,255,.8) inset,0 2px 10px rgba(36,36,36,.14);transition:transform .15s}+.page .chipArrow:hover{transform:translateY(-50%) scale(1.08)}+.chipArrow svg{width:16px;height:16px}+.chipArrowLeft{left:0}+.chipArrowRight{right:0}+/* A finger swipes the row; the fades are enough there, and the arrows would take a narrow row's room. */+@media(hover:none){.page .chipArrow{display:none}}.chips::-webkit-scrollbar{display:none}-.page .chips button,.page .sort button{padding:6px 12px;font-size:13px;color:#777;white-space:nowrap;border-radius:999px;transition:background-color .15s,color .15s}-.page .chips button:hover,.page .sort button:hover{color:#242424;background:#f4f4f2}-.page .chips button[aria-pressed=true]{background:#242424;color:#fff}-.sort{display:flex;gap:2px;padding:3px;border-radius:999px;background:#f4f4f2;flex-shrink:0}-.page .sort button{padding:4px 12px}-.page .sort button[aria-pressed=true]{background:#fff;color:#242424;box-shadow:0 1px 3px rgba(36,36,36,.12)}+.page .chips button,.page .sort button{display:inline-flex;align-items:center;padding:0;flex-shrink:0;color:#777;white-space:nowrap}+.chips span,.sort span{display:block;padding:6px 12px;font-size:13px;line-height:1.5;border-radius:999px;transition:background-color .15s,color .15s,box-shadow .15s}+.page .chips button{scroll-snap-align:start}+.page .chips button:last-child{margin-right:36px}+.chips [aria-pressed=true] span{background:#242424;color:#fff}+/* The order's track is drawn behind its labels, not on the buttons, for the same reason. */+.sort{position:relative;isolation:isolate;display:flex;gap:2px;padding:0 3px;flex-shrink:0}+.sort:before{content:'';position:absolute;z-index:-1;left:0;right:0;top:50%;height:34px;transform:translateY(-50%);border-radius:999px;background:#f4f4f2}+.sort span{padding:4px 12px}+.sort [aria-pressed=true] span{background:#fff;color:#242424;box-shadow:0 1px 3px rgba(36,36,36,.12)}+/* Hover only where there is a pointer: on a phone a tapped chip would keep its hover. */+@media(hover:hover){.chips button:not([aria-pressed=true]):hover span,.sort button:not([aria-pressed=true]):hover span{color:#242424;background:#ebebe8}}/* The first page's placeholders. */.skeleton .cover,.skeleton span{background:linear-gradient(100deg,#efeeeb 40%,#f7f6f3 50%,#efeeeb 60%) 0 0/200% 100%;animation:shimmer 1.4s linear infinite}.skeleton span{display:block;height:14px;margin-top:12px;width:62%}.skeleton span:last-child{width:84%;height:12px;margin-top:8px}@keyframes shimmer{to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.skeleton .cover,.skeleton span{animation:none}}-/* The output's full-screen control: a glass chip over its corner. */-.page .viewerButton{position:absolute;top:12px;right:12px;display:inline-flex;padding:8px;border-radius:10px;color:#242424;background:rgba(255,255,255,.62);-webkit-backdrop-filter:saturate(180%) blur(14px);backdrop-filter:saturate(180%) blur(14px);box-shadow:0 1px 0 rgba(255,255,255,.7) inset,0 4px 14px rgba(36,36,36,.12);opacity:.72;transition:opacity .15s,transform .15s}-.page .viewerButton:hover{opacity:1;transform:scale(1.04)}-.viewerButton svg{width:16px;height:16px}+/* The output's full-screen control, on a slim bar under it. */+.viewerBar{display:flex;justify-content:flex-end;background:#fff}+.page .viewerBar button{display:inline-flex;align-items:center;gap:6px;padding:8px 0 0;font-size:12px;color:#777}+.page .viewerBar button:hover{color:#242424}+.viewerBar svg{width:14px;height:14px}.viewer:fullscreen{background:#fff}-.viewer:fullscreen iframe{height:100%}+.viewer:fullscreen{display:flex;flex-direction:column}+.viewer:fullscreen iframe{flex:1;height:auto}+.viewer:fullscreen .viewerBar{padding:0 14px 8px}/* Source files beside the output. */.sourceFile{border-bottom:1px solid #efefed;font-size:12px}.sourceFile summary{display:flex;align-items:center;gap:12px;padding:10px 0;cursor:pointer}@@ -168,4 +189,9 @@.sourceFile pre{margin-bottom:12px}.forks{margin-top:70px}.forks h2{font-size:17px;font-weight:400;margin-bottom:26px}-@media(max-width:760px){.filters{flex-direction:column;align-items:stretch;margin:0 0 26px;gap:12px}.sort{align-self:flex-start}.forks{margin-top:50px}}+/* Phones: the chips run to the screen's left edge (the gutter is 4vw), and the order shrinks to fit beside them. */+@media(max-width:760px){.filters{gap:10px;margin:0 0 24px}.chipsWrap{margin-left:-4vw}.chips{padding-left:4vw;scroll-padding-left:4vw}.chipArrowLeft{left:2vw}.sort span{padding:4px 10px;font-size:12px}.forks{margin-top:50px}}+/* Small phones: Files and Share keep their icon; their names stay for screen readers. */+@media(max-width:480px){.actions{gap:18px}.actionLabel{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}}+.byline a,.byline button{display:inline-flex;align-items:center}+@media(max-width:760px){.chat{scroll-margin-top:104px}}diff --git a/website/src/app/hub/components/DetailHead.tsx b/website/src/app/hub/components/DetailHead.tsxindex d6e2dc282..fb2ee85df 100644--- a/website/src/app/hub/components/DetailHead.tsx+++ b/website/src/app/hub/components/DetailHead.tsx@@ -27,7 +27,7 @@ export function DetailHead({ harness, social, ready, busy, panel, onFollow, onLi<div className={styles.actions}><button className={social.liked ? styles.liked : ''} disabled={busy} aria-label={social.liked ? 'Unlike harness' : 'Like harness'} aria-pressed={social.liked} onClick={onLike}><Heart /><span>{ready ? social.likes : 'Like'}</span></button><button aria-label="Comments" aria-pressed={panel === 'comments'} onClick={() => onPanel('comments')}><MessageCircle /><span>{ready ? commentTotal(social) : 'Comments'}</span></button>- <button aria-label="Source files" aria-pressed={panel === 'files'} onClick={() => onPanel('files')}><FileCode2 /><span>Files</span></button>+ <button aria-label="Source files" aria-pressed={panel === 'files'} onClick={() => onPanel('files')}><FileCode2 /><span className={styles.actionLabel}>Files</span></button><ShareButton id={harness.id} /><ForkButton id={harness.id}><GitFork /> Fork</ForkButton></div>diff --git a/website/src/app/hub/components/FeedFilters.tsx b/website/src/app/hub/components/FeedFilters.tsxindex 25e771fda..387be37ec 100644--- a/website/src/app/hub/components/FeedFilters.tsx+++ b/website/src/app/hub/components/FeedFilters.tsx@@ -1,20 +1,38 @@'use client';+import { useEffect } from 'react';+import { ChevronLeft, ChevronRight } from 'lucide-react';import { communityCategories } from '@/lib/community/contract';import { feedSorts, type FeedSort } from '@/lib/community/feed';+import { useScrollRow } from './useScrollRow';import styles from '../community.module.css';type Props = { category: string; sort: FeedSort; onCategory: (category: string) => void; onSort: (sort: FeedSort) => void };const sortLabels: Record<FeedSort, string> = { newest: 'Newest', popular: 'Popular' };-/** One category at a time (All clears it), and the order: newest first or most liked first. */+/**+ * The categories, one at a time (All clears it). When they do not fit, the row scrolls by finger,+ * wheel or its arrows, and a fade marks each end that hides more. The chosen chip moves to the middle.+ */+function CategoryChips({ category, onCategory }: Pick<Props, 'category' | 'onCategory'>) {+ const { row, edges, step, center } = useScrollRow<HTMLDivElement>();+ useEffect(() => center(row.current?.querySelector<HTMLElement>('[aria-pressed=true]')), [category, center, row]);+ // The arrows are for a pointer; a keyboard reaches every chip with Tab, which scrolls it into view.+ return <div className={styles.chipsWrap}>+ {edges.left && <button type="button" className={`${styles.chipArrow} ${styles.chipArrowLeft}`} tabIndex={-1} aria-hidden onClick={() => step(-1)}><ChevronLeft /></button>}+ <div ref={row} className={styles.chips} data-fade-left={edges.left || undefined} data-fade-right={edges.right || undefined} role="group" aria-label="Category">+ {['', ...communityCategories].map(value => <button key={value || 'all'} type="button" aria-pressed={category === value} onClick={() => onCategory(value)}><span>{value || 'All'}</span></button>)}+ </div>+ {edges.right && <button type="button" className={`${styles.chipArrow} ${styles.chipArrowRight}`} tabIndex={-1} aria-hidden onClick={() => step(1)}><ChevronRight /></button>}+ </div>;+}++/** Each pill is drawn on its label, so a button keeps a phone's full touch height while the pill stays compact. */export function FeedFilters({ category, sort, onCategory, onSort }: Props) {return <div className={styles.filters}>- <div className={styles.chips} role="group" aria-label="Category">- {['', ...communityCategories].map(value => <button key={value || 'all'} type="button" aria-pressed={category === value} onClick={() => onCategory(value)}>{value || 'All'}</button>)}- </div>+ <CategoryChips category={category} onCategory={onCategory} /><div className={styles.sort} role="group" aria-label="Order">- {feedSorts.map(value => <button key={value} type="button" aria-pressed={sort === value} onClick={() => onSort(value)}>{sortLabels[value]}</button>)}+ {feedSorts.map(value => <button key={value} type="button" aria-pressed={sort === value} onClick={() => onSort(value)}><span>{sortLabels[value]}</span></button>)}</div></div>;}diff --git a/website/src/app/hub/components/ShareButton.tsx b/website/src/app/hub/components/ShareButton.tsxindex 722ed97ea..915f7db86 100644--- a/website/src/app/hub/components/ShareButton.tsx+++ b/website/src/app/hub/components/ShareButton.tsx@@ -1,6 +1,7 @@'use client';import { useEffect, useState } from 'react';import { Check, Link2 } from 'lucide-react';+import styles from '../community.module.css';type Copy = 'idle' | 'copied' | 'failed';const labels: Record<Copy, string> = { idle: 'Share', copied: 'Link copied', failed: 'Copy failed' };@@ -17,6 +18,6 @@ export function ShareButton({ id }: { id: string }) {try { await navigator.clipboard.writeText(`${window.location.origin}/hub/${id}`); setCopy('copied'); } catch { setCopy('failed'); }}return <button type="button" aria-label="Copy link to this harness" onClick={() => void share()}>- {copy === 'copied' ? <Check /> : <Link2 />}<span aria-live="polite">{labels[copy]}</span>+ {copy === 'copied' ? <Check /> : <Link2 />}<span className={styles.actionLabel} aria-live="polite">{labels[copy]}</span></button>;}diff --git a/website/src/app/hub/components/SidePanel.tsx b/website/src/app/hub/components/SidePanel.tsxindex 67f9fcf81..1d327ce68 100644--- a/website/src/app/hub/components/SidePanel.tsx+++ b/website/src/app/hub/components/SidePanel.tsx@@ -1,4 +1,5 @@'use client';+import { useEffect, useRef } from 'react';import { X } from 'lucide-react';import { commentTotal } from '@/lib/community/comments';import type { HarnessComment, OpenHarness, SocialState } from '@/lib/community/types';@@ -18,11 +19,22 @@ type Props = {const titles: Record<Panel, string> = { log: 'Chat log', comments: 'Comments', files: 'Source files' };+/** On a phone the panel sits under the output: one the reader opens is brought into view, not left below it. */+function useRevealOnOpen(panel: Panel) {+ const aside = useRef<HTMLElement>(null), opened = useRef(panel);+ useEffect(() => {+ if (panel === opened.current) return;+ opened.current = panel;+ if (panel !== 'log' && window.matchMedia?.('(max-width: 760px)').matches) aside.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });+ }, [panel]);+ return aside;+}+/** Beside the output: the agent's chat log, or the comments, or the project's files. */export function SidePanel({ harness, social, ready, busy, panel, error, onClose, onRetry, onRemove, onPost }: Props) {- const files = useHarnessFiles(harness.id, panel === 'files');+ const files = useHarnessFiles(harness.id, panel === 'files'), aside = useRevealOnOpen(panel);const title = panel === 'comments' && ready ? `Comments · ${commentTotal(social)}` : titles[panel];- return <aside className={styles.chat} aria-label={panel === 'log' ? 'Agent chat log' : titles[panel]}>+ return <aside ref={aside} className={styles.chat} aria-label={panel === 'log' ? 'Agent chat log' : titles[panel]}><div className={styles.chatHead}><h2>{title}</h2>{panel === 'log' ? <HarnessTags harness={harness} /> : <button className={styles.icon} onClick={onClose} aria-label="Back to chat log"><X /></button>}</div>{panel === 'log' && <Transcript harness={harness} />}{panel === 'comments' && <Comments social={social} ready={ready} busy={busy} onRetry={onRetry} onRemove={onRemove} onPost={onPost} />}diff --git a/website/src/app/hub/components/Viewer.tsx b/website/src/app/hub/components/Viewer.tsxindex 14750e229..6742d8dff 100644--- a/website/src/app/hub/components/Viewer.tsx+++ b/website/src/app/hub/components/Viewer.tsx@@ -30,8 +30,11 @@ export function Viewer({ harness }: { harness: OpenHarness }) {</section>;return <section ref={section} className={styles.viewer} aria-label="Output viewer"><iframe title={`${harness.title} output`} srcDoc={previewDocument(html)} sandbox={harness.example ? 'allow-scripts allow-downloads allow-modals' : 'allow-scripts'} referrerPolicy="no-referrer" />- {fullscreen.supported && <button type="button" className={styles.viewerButton} onClick={fullscreen.toggle} aria-label={fullscreen.active ? 'Exit full screen' : 'View output full screen'} title={fullscreen.active ? 'Exit full screen' : 'Full screen'}>- {fullscreen.active ? <Minimize2 /> : <Maximize2 />}- </button>}+ {/* Under the output, never over it: a corner control would cover the page's own controls. */}+ {fullscreen.supported && <div className={styles.viewerBar}>+ <button type="button" onClick={fullscreen.toggle} aria-label={fullscreen.active ? 'Exit full screen' : 'View output full screen'}>+ {fullscreen.active ? <Minimize2 /> : <Maximize2 />}<span>{fullscreen.active ? 'Exit full screen' : 'Full screen'}</span>+ </button>+ </div>}</section>;}diff --git a/website/src/app/hub/components/useScrollRow.ts b/website/src/app/hub/components/useScrollRow.tsnew file mode 100644index 000000000..3cd5279f2--- /dev/null+++ b/website/src/app/hub/components/useScrollRow.ts@@ -0,0 +1,49 @@+'use client';+import { useCallback, useEffect, useRef, useState } from 'react';++type Edges = { left: boolean; right: boolean };++/**+ * A row that scrolls sideways under a mouse as well as a finger: which ends still hide something,+ * a page step either way, and centering one item. A vertical wheel over the row scrolls it, until+ * the row reaches its end; then the wheel scrolls the page again.+ */+export function useScrollRow<T extends HTMLElement>() {+ const row = useRef<T>(null);+ const [edges, setEdges] = useState<Edges>({ left: false, right: false });+ useEffect(() => {+ const element = row.current;+ if (!element) return;+ const update = () => {+ const left = element.scrollLeft > 1, right = element.scrollLeft + element.clientWidth < element.scrollWidth - 1;+ setEdges(previous => previous.left === left && previous.right === right ? previous : { left, right });+ };+ const wheel = (event: WheelEvent) => {+ // A trackpad's sideways swipe already scrolls the row.+ if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return;+ const end = element.scrollWidth - element.clientWidth;+ if (end <= 0 || (event.deltaY < 0 && element.scrollLeft <= 0) || (event.deltaY > 0 && element.scrollLeft >= end)) return;+ event.preventDefault();+ element.scrollLeft += event.deltaY;+ };+ // The observer also answers once at the start, so the ends are known without a render of their own.+ const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update);+ resize?.observe(element);+ element.addEventListener('scroll', update, { passive: true });+ element.addEventListener('wheel', wheel, { passive: false });+ return () => { resize?.disconnect(); element.removeEventListener('scroll', update); element.removeEventListener('wheel', wheel); };+ }, []);+ /** Scrolls most of a row's width one way, keeping a little of what was in view. */+ const step = useCallback((direction: 1 | -1) => {+ const element = row.current;+ element?.scrollBy?.({ left: direction * element.clientWidth * 0.7, behavior: 'smooth' });+ }, []);+ /** Brings an item to the row's middle, so its neighbours on both sides stay in view. */+ const center = useCallback((item: HTMLElement | null | undefined) => {+ const element = row.current;+ if (!element || !item) return;+ const box = element.getBoundingClientRect(), target = item.getBoundingClientRect();+ element.scrollBy?.({ left: target.left + target.width / 2 - (box.left + box.width / 2), behavior: 'smooth' });+ }, []);+ return { row, edges, step, center };+}