diff --git a/packages/gui-plugins/src/media/i18n/en.ts b/packages/gui-plugins/src/media/i18n/en.ts index 536a86e5221..351976ccf9b 100644 --- a/packages/gui-plugins/src/media/i18n/en.ts +++ b/packages/gui-plugins/src/media/i18n/en.ts @@ -35,8 +35,6 @@ export default { "media.image": "Image", "day.today": "Today", "day.yesterday": "Yesterday", - "count.more": "{{count}}+", - "history.loading": "Looking through earlier messages…", - "history.failed": "Couldn't load earlier messages", - "history.retry": "Try again", + "load.more": "Load earlier messages", + "load.loading": "Loading…", } diff --git a/packages/gui-plugins/src/media/media.css b/packages/gui-plugins/src/media/media.css index fbc38c8392e..b21cc845964 100644 --- a/packages/gui-plugins/src/media/media.css +++ b/packages/gui-plugins/src/media/media.css @@ -318,28 +318,16 @@ text-wrap: balance; } - [data-slot="media-panel-end"] { - display: flex; - align-items: center; - justify-content: center; - gap: 8px; - min-height: 1px; - padding-block: 16px 8px; - color: var(--v2-text-text-faint); - font-size: 12px; - - &:empty { - padding: 0; - } - } - - [data-slot="media-panel-retry"] { - padding: 2px 8px; + [data-slot="media-panel-more"] { + display: block; + margin: 12px auto 4px; + padding: 4px 10px; border-radius: 6px; color: var(--v2-text-text-muted); + font-size: 12px; cursor: default; - &:hover { + &:not(:disabled):hover { background-color: var(--v2-overlay-simple-overlay-hover); color: var(--v2-text-text-base); } diff --git a/packages/gui-plugins/src/media/panel.tsx b/packages/gui-plugins/src/media/panel.tsx index 61ec1daad60..6399b425c3e 100644 --- a/packages/gui-plugins/src/media/panel.tsx +++ b/packages/gui-plugins/src/media/panel.tsx @@ -2,12 +2,11 @@ import { createMemo, createSignal, For, mapArray, Match, onCleanup, Show, Switch import { useDialog } from "@opencode/ui/context/dialog" import { FileIcon } from "@opencode/ui/file-icon" import { Icon } from "@opencode/ui/icon" -import { Loader } from "@opencode/ui/loader" import { ImagePreview } from "@opencode/ui/image-preview" import { SegmentedControl, SegmentedControlItem } from "@opencode/ui/segmented-control" import { Select } from "@opencode/ui/select" import { SiteIcon } from "@opencode/session-ui/sources/site-icon" -import { createKeyed, createLatest, usePlugin, type MountedSession } from "@opencode/plugin/gui" +import { createLatest, usePlugin, type MountedSession } from "@opencode/plugin/gui" import { Browser } from "@opencode/plugin/gui/browser" import type Media from "./index" import { combineMedia, messageMedia, type FileItem, type LinkItem, type MediaItem, type Sender } from "./collect" @@ -52,40 +51,6 @@ export default function MediaPanel(props: { session: MountedSession }) { return ctx.t(`empty.${kind()}`) } - // The app keeps only a session's recent messages, so older items arrive as the panel pages in history. Paging runs - // whenever the end of the list is on screen: as the user scrolls down, and again after each page while a short or - // empty list still leaves the end visible. Every tab reads the same messages, so a page fills all three. - const [end, setEnd] = createSignal(false) - const [failed, setFailed] = createSignal(false) - // Counts settled page requests. A request can add nothing, for example when it joins the timeline's own load, so - // each settle is a new chance to page while the end is still on screen. - const [settled, setSettled] = createSignal(0) - const more = () => messages().more(props.session.id) - const loading = () => messages().loading(props.session.id) - - const page = () => { - setFailed(false) - void messages() - .loadMore(props.session.id) - .then( - () => setSettled((count) => count + 1), - () => setFailed(true), - ) - } - - // Syncs with the server: one page at a time while the end is visible, so it stops once a page pushes the end off - // screen, the history ends, or a load fails. - createKeyed(() => end() && more() && !loading() && !failed() && `${props.session.id}:${settled()}`, page) - - const observeEnd = (element: HTMLElement) => { - const observer = new IntersectionObserver((entries) => setEnd(entries.some((entry) => entry.isIntersecting)), { - rootMargin: "300px", - }) - - observer.observe(element) - onCleanup(() => observer.disconnect()) - } - const openURL = (url: string) => { const pane = ctx.use(Browser)() @@ -136,9 +101,7 @@ export default function MediaPanel(props: { session: MountedSession }) { {ctx.t(`kind.${value}`)} - - {more() ? ctx.t("count.more", { count: count(value) }) : count(value)} - + {count(value)} )} @@ -179,24 +142,24 @@ export default function MediaPanel(props: { session: MountedSession }) { {(item) => } - +
{empty()}
-
- - - {ctx.t("history.failed")} - - - - - {ctx.t("history.loading")} - - -
+ + + )