diff --git a/packages/gui-plugins/src/media/i18n/en.ts b/packages/gui-plugins/src/media/i18n/en.ts index 6f6e07bd939..351976ccf9b 100644 --- a/packages/gui-plugins/src/media/i18n/en.ts +++ b/packages/gui-plugins/src/media/i18n/en.ts @@ -16,13 +16,20 @@ export default { "empty.links": "Links from your messages, the agent's replies and its web searches show here", "empty.user": "Nothing from you here yet", "empty.agent": "Nothing from the agent here yet", - "file.attached": "Attached", - "file.mentioned": "Mentioned", - "file.created": "Created", - "file.returned": "From a tool", - "link.text": "In a message", - "link.fetch": "Opened", - "link.search": "Search result", + "file.user.attached": "You attached", + "file.user.mentioned": "You mentioned", + "file.user.created": "You created", + "file.user.returned": "You shared", + "file.agent.attached": "Agent attached", + "file.agent.mentioned": "Agent mentioned", + "file.agent.created": "Agent created", + "file.agent.returned": "Agent returned", + "link.user.text": "You shared", + "link.user.fetch": "You opened", + "link.user.search": "You found", + "link.agent.text": "Agent mentioned", + "link.agent.fetch": "Agent opened", + "link.agent.search": "Agent found", "media.failed": "Couldn't load", "media.video": "Video", "media.image": "Image", diff --git a/packages/gui-plugins/src/media/media.css b/packages/gui-plugins/src/media/media.css index 121411ec388..b21cc845964 100644 --- a/packages/gui-plugins/src/media/media.css +++ b/packages/gui-plugins/src/media/media.css @@ -43,7 +43,7 @@ padding: 12px; } - [data-slot="media-panel-gallery"] { + [data-slot="media-panel-days"] { display: flex; flex-direction: column; gap: 20px; @@ -186,22 +186,22 @@ white-space: nowrap; } - /* Rows pad their own content, so the list reaches past the body padding to line text up with the filters. */ + /* Rows pad their own content, so the list reaches past the body padding to line text up with the headings. */ [data-slot="media-panel-list"] { - margin-inline: -8px; display: flex; flex-direction: column; gap: 2px; + margin-inline: -8px; } - [data-slot="media-panel-row"] { + [data-slot="media-row"] { display: grid; - grid-template-columns: 16px minmax(0, 1fr) auto; + grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; - column-gap: 10px; + column-gap: 12px; width: 100%; padding: 8px; - border-radius: 8px; + border-radius: 10px; color: var(--v2-text-text-base); text-align: start; text-decoration: none; @@ -219,51 +219,95 @@ } } - [data-slot="media-panel-row-icon"] { - display: inline-flex; + [data-slot="media-row-icon"] { + display: flex; align-items: center; justify-content: center; - width: 16px; - height: 16px; + width: 36px; + height: 36px; + border-radius: 9px; + background-color: var(--v2-background-bg-layer-02); + box-shadow: inset 0 0 0 1px var(--v2-border-border-muted); + + > svg { + width: 18px; + height: 18px; + } + + /* A link's site fills its tile, as a coloured letter square rather than a small circle. */ + > [data-component="site-icon"] { + --site-icon-size: 36px; + border-radius: 9px; + font-size: 15px; + } } - [data-slot="media-panel-row-text"] { + [data-slot="media-row-text"] { display: flex; flex-direction: column; - gap: 2px; + gap: 3px; min-width: 0; } - [data-slot="media-panel-row-title"], - [data-slot="media-panel-row-detail"] { + [data-slot="media-row-title"] { overflow: hidden; + font-size: 13px; + font-weight: 500; + line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; } - [data-slot="media-panel-row-title"] { - font-size: 13px; - } - - [data-slot="media-panel-row-detail"] { - color: var(--v2-text-text-muted); - font-size: 12px; - } - - [data-slot="media-panel-row-path"] { - margin-inline-start: 6px; - color: var(--v2-text-text-faint); - } - - [data-slot="media-panel-row-meta"] { + [data-slot="media-row-detail"] { display: flex; - flex-direction: column; - align-items: flex-end; - gap: 2px; + gap: 5px; + min-width: 0; color: var(--v2-text-text-faint); - font-size: 11px; + font-size: 12px; + line-height: 1.3; + white-space: nowrap; + } + + /* The place gives way first, so who did what always shows. */ + [data-slot="media-row-place"] { + overflow: hidden; + color: var(--v2-text-text-muted); + text-overflow: ellipsis; + } + + [data-slot="media-row-separator"], + [data-slot="media-row-action"] { + flex: none; + } + + /* The time, swapped for an open arrow while the row is hovered or focused. */ + [data-slot="media-row-end"] { + display: grid; + justify-items: end; + color: var(--v2-text-text-faint); + font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; + + > * { + grid-area: 1 / 1; + transition: opacity 120ms ease-out; + } + + > [data-slot="icon-svg"] { + opacity: 0; + color: var(--v2-text-text-muted); + } + } + + [data-slot="media-row"]:is(:hover, :focus-visible) [data-slot="media-row-end"]:has([data-slot="icon-svg"]) { + > time { + opacity: 0; + } + + > [data-slot="icon-svg"] { + opacity: 1; + } } [data-slot="media-panel-empty"] { @@ -307,4 +351,9 @@ [data-slot="media-card"]:hover [data-slot="media-card-frame"] > img { transform: none; } + + [data-slot="media-row"], + [data-slot="media-row-end"] > * { + transition: none; + } } diff --git a/packages/gui-plugins/src/media/panel.tsx b/packages/gui-plugins/src/media/panel.tsx index 957d3cb6248..6399b425c3e 100644 --- a/packages/gui-plugins/src/media/panel.tsx +++ b/packages/gui-plugins/src/media/panel.tsx @@ -1,4 +1,4 @@ -import { createMemo, createSignal, For, mapArray, Match, onCleanup, Show, Switch, untrack } from "solid-js" +import { createMemo, createSignal, For, mapArray, Match, onCleanup, Show, Switch, untrack, type JSX } from "solid-js" import { useDialog } from "@opencode/ui/context/dialog" import { FileIcon } from "@opencode/ui/file-icon" import { Icon } from "@opencode/ui/icon" @@ -133,14 +133,14 @@ export default function MediaPanel(props: { session: MountedSession }) { /> 0}> -
- {(item) => } -
+ + {(item) => } +
0}> -
- {(item) => } -
+ + {(item) => } +
{empty()}
@@ -174,9 +174,33 @@ function MediaGrid(props: { view: (id: string) => void thumbnail: (id: string, element: HTMLImageElement | undefined) => void }) { - const ctx = usePlugin() + return ( + + {(item) => ( + + )} + + ) +} - // Keyed by day and id strings: a streaming reply derives new item objects, and its cards must not load again. +/** + * Items under a heading per local day, newest first as given. Keyed by day and id strings: a streaming reply derives new + * item objects, and their rows must not mount again. + */ +function DayGroups(props: { + items: readonly T[] + layout: "grid" | "list" + children: (item: T) => JSX.Element +}) { + const ctx = usePlugin() const byID = createMemo(() => new Map(props.items.map((item) => [item.id, item]))) const days = createMemo(() => @@ -203,28 +227,14 @@ function MediaGrid(props: { } return ( -
+
{(day) => (

{label(day)}

-
+
- {(id) => ( - - {(item) => ( - - )} - - )} + {(id) => {(item) => props.children(item())}}
@@ -435,7 +445,7 @@ const yearFormat = new Intl.DateTimeFormat(undefined, { year: "numeric", month: const timeFormat = new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit" }) -function FileRow(props: { item: FileItem; openPath: (path: string) => void }) { +function FileRow(props: { item: FileItem; directory: string; openPath: (path: string) => void }) { const ctx = usePlugin() const href = () => { @@ -444,34 +454,41 @@ function FileRow(props: { item: FileItem; openPath: (path: string) => void }) { return source?.type === "url" ? source.url : undefined } + // The folder the file sits in, relative to the session's directory when it is inside it. + const folder = () => { + const path = props.item.path + + if (!path) return undefined + const root = props.directory.replace(/\/+$/, "") + "/" + const relative = path.startsWith(root) ? path.slice(root.length) : path + const split = relative.lastIndexOf("/") + + return split > 0 ? relative.slice(0, split) : undefined + } + const content = () => ( - <> - - - - - {props.item.name} - - {ctx.t(`file.${props.item.action}`)} - {(path) => {path()}} - - - - + } + title={props.item.name} + place={folder()} + action={ctx.t(`file.${props.item.from}.${props.item.action}`)} + time={props.item.time} + opens={!!props.item.path || !!href()} + /> ) return ( - {content()}
}> + {content()}
}> {(path) => ( - )} {(url) => ( - + {content()} )} @@ -483,9 +500,16 @@ function FileRow(props: { item: FileItem; openPath: (path: string) => void }) { function LinkRow(props: { item: LinkItem; openURL: (url: string) => void }) { const ctx = usePlugin() + // The page without its scheme, `www.` or trailing slash, as the address bar would show it. + const page = () => { + const url = new URL(props.item.url) + + return `${url.pathname.replace(/\/+$/, "")}${url.search}` + } + return ( { @@ -493,37 +517,52 @@ function LinkRow(props: { item: LinkItem; openURL: (url: string) => void }) { props.openURL(props.item.url) }} > - - - - - {props.item.title ?? props.item.url} - - {props.item.site} - {ctx.t(`link.${props.item.via}`)} - - - + } + title={props.item.title ?? `${props.item.site}${page()}`} + place={props.item.title ? `${props.item.site}${page()}` : undefined} + action={ctx.t(`link.${props.item.from}.${props.item.via}`)} + time={props.item.time} + opens + /> ) } -const format = new Intl.DateTimeFormat(undefined, { - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", -}) - -function Meta(props: { from: Sender; time: number }) { - const ctx = usePlugin() - +/** A file or link row's content: its icon tile, title, where it is and who did what, and the time. */ +function Row(props: { + icon: JSX.Element + title: string + place?: string + action: string + time: number + opens: boolean +}) { return ( - - - {ctx.t(props.from === "user" ? "from.user" : "from.agent")} + <> + {props.icon} + + {props.title} + + + {(place) => ( + <> + {place()} + + + )} + + {props.action} + - - + + + + + + + ) }