mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
feat(app): consolidated navigation experiment (#64668)
This commit is contained in:
committed by
GitHub
Unverified
parent
bb01d3eecc
commit
723e0a9105
@@ -4,12 +4,14 @@ import type { HomeScrollController } from "../scroll"
|
||||
|
||||
export function HomeProjects(props: {
|
||||
projects: HomeProjectsController
|
||||
scroll: HomeScrollController
|
||||
scroll?: HomeScrollController
|
||||
dropdown?: boolean
|
||||
scope?: boolean
|
||||
}) {
|
||||
return (
|
||||
<HomeProjectsView
|
||||
dropdown={props.dropdown}
|
||||
scope={props.scope}
|
||||
language={props.projects.copy.language}
|
||||
servers={props.projects.server.list()}
|
||||
projects={props.projects.project.list()}
|
||||
@@ -20,7 +22,7 @@ export function HomeProjects(props: {
|
||||
collapsed={props.projects.server.collapsed}
|
||||
canRevealProject={props.projects.project.canReveal}
|
||||
hasUnread={props.projects.project.hasUnread}
|
||||
onWheel={props.scroll.viewport.containWheel}
|
||||
onWheel={(event) => props.scroll?.viewport.containWheel(event)}
|
||||
onChooseProject={props.projects.project.choose}
|
||||
onFocusServer={props.projects.server.focus}
|
||||
onAuthenticateServer={props.projects.server.authenticate}
|
||||
|
||||
@@ -80,6 +80,8 @@ export type HomeProjectsViewProps = {
|
||||
onHideProject: (server: ServerConnection.Any, project: LocalProject) => void
|
||||
onOpenSettings: () => void
|
||||
onOpenHelp: () => void
|
||||
/** With `dropdown`, opens the panel from a compact picker at the end of Home's search field. */
|
||||
scope?: boolean
|
||||
}
|
||||
|
||||
export function HomeProjectsView(props: HomeProjectsViewProps) {
|
||||
@@ -95,38 +97,59 @@ export function HomeProjectsView(props: HomeProjectsViewProps) {
|
||||
<Popover
|
||||
open={state.open}
|
||||
onOpenChange={(open) => setState("open", open)}
|
||||
placement="bottom-start"
|
||||
sameWidth
|
||||
gutter={6}
|
||||
placement={props.scope ? "bottom-end" : "bottom-start"}
|
||||
sameWidth={!props.scope}
|
||||
gutter={props.scope ? 8 : 6}
|
||||
>
|
||||
<Popover.Trigger
|
||||
data-component="home-projects-dropdown"
|
||||
aria-label={props.language.t("home.projects")}
|
||||
class="flex h-10 w-full min-w-0 items-center gap-2 rounded-[6px] bg-v2-background-bg-base px-1.5 text-start text-v2-text-text-base outline-none hover:bg-v2-background-bg-layer-01"
|
||||
<Show
|
||||
when={props.scope}
|
||||
fallback={
|
||||
<Popover.Trigger
|
||||
data-component="home-projects-dropdown"
|
||||
aria-label={props.language.t("home.projects")}
|
||||
class="flex h-10 w-full min-w-0 items-center gap-2 rounded-[6px] bg-v2-background-bg-base px-1.5 text-start text-v2-text-text-base outline-none hover:bg-v2-background-bg-layer-01"
|
||||
>
|
||||
<Show when={selected()} fallback={<Icon name="folder" />}>
|
||||
{(project) => <HomeProjectAvatar project={project()} />}
|
||||
</Show>
|
||||
<span class="flex min-w-0 flex-1 flex-col leading-[var(--line-height-compact)]">
|
||||
<bdi class="truncate">
|
||||
<Show when={selected()} fallback={props.language.t("home.projects.all")}>
|
||||
{(project) => displayName(project())}
|
||||
</Show>
|
||||
</bdi>
|
||||
<Show when={props.servers.length > 1 && server()}>
|
||||
{(server) => (
|
||||
<bdi class="truncate text-v2-text-text-muted opacity-70">
|
||||
{props.serverLabel(server())}
|
||||
</bdi>
|
||||
)}
|
||||
</Show>
|
||||
</span>
|
||||
<Icon name="chevron-down" class="shrink-0 text-v2-icon-icon-muted" />
|
||||
</Popover.Trigger>
|
||||
}
|
||||
>
|
||||
<Show when={selected()} fallback={<Icon name="folder" />}>
|
||||
{(project) => <HomeProjectAvatar project={project()} />}
|
||||
</Show>
|
||||
<span class="flex min-w-0 flex-1 flex-col leading-[var(--line-height-compact)]">
|
||||
<bdi class="truncate">
|
||||
<Popover.Trigger
|
||||
data-action="home-project-scope"
|
||||
aria-label={props.language.t("home.projects")}
|
||||
class="relative z-20 -me-1 flex h-7 min-w-0 max-w-[220px] shrink-0 items-center gap-1.5 rounded-[4px] ps-2 pe-1.5 text-[13px] leading-[var(--line-height-compact)] [font-weight:440] text-v2-text-text-muted outline-none hover:bg-v2-overlay-simple-overlay-hover hover:text-v2-text-text-base focus-visible:bg-v2-overlay-simple-overlay-hover data-[expanded]:bg-v2-overlay-simple-overlay-pressed data-[expanded]:text-v2-text-text-base"
|
||||
onMouseDown={(event: MouseEvent) => event.preventDefault()}
|
||||
>
|
||||
<Show when={selected()}>{(project) => <HomeProjectAvatar project={project()} />}</Show>
|
||||
<bdi class="min-w-0 truncate">
|
||||
<Show when={selected()} fallback={props.language.t("home.projects.all")}>
|
||||
{(project) => displayName(project())}
|
||||
</Show>
|
||||
</bdi>
|
||||
<Show when={props.servers.length > 1 && server()}>
|
||||
{(server) => (
|
||||
<bdi class="truncate text-v2-text-text-muted opacity-70">
|
||||
{props.serverLabel(server())}
|
||||
</bdi>
|
||||
)}
|
||||
</Show>
|
||||
</span>
|
||||
<Icon name="chevron-down" class="shrink-0 text-v2-icon-icon-muted" />
|
||||
</Popover.Trigger>
|
||||
<Icon name="chevron-down" class="shrink-0 text-v2-icon-icon-muted" />
|
||||
</Popover.Trigger>
|
||||
</Show>
|
||||
<Popover.Portal>
|
||||
<Popover.Content
|
||||
aria-label={props.language.t("home.projects")}
|
||||
dir={props.language.direction()}
|
||||
style={props.scope ? { width: "280px" } : undefined}
|
||||
class="z-50 max-h-[min(70dvh,var(--kb-popper-content-available-height))] overflow-hidden rounded-[10px] bg-v2-background-bg-base p-1.5 shadow-[var(--v2-elevation-floating)] outline-none data-[expanded]:animate-in data-[expanded]:fade-in data-[expanded]:slide-in-from-top-2 duration-150 ease-out motion-reduce:animate-none"
|
||||
>
|
||||
<HomeProjectsPanel
|
||||
@@ -327,6 +350,7 @@ function HomeProjectsPanel(props: HomeProjectsViewProps) {
|
||||
</div>
|
||||
<HomeUtilityNav
|
||||
class="mb-8 mt-4 hidden shrink-0 lg:flex"
|
||||
classList={{ "!hidden": !!props.dropdown }}
|
||||
onOpenSettings={props.onOpenSettings}
|
||||
onOpenHelp={props.onOpenHelp}
|
||||
language={props.language}
|
||||
@@ -337,6 +361,7 @@ function HomeProjectsPanel(props: HomeProjectsViewProps) {
|
||||
|
||||
export function HomeUtilityNav(props: {
|
||||
class?: string
|
||||
classList?: Record<string, boolean>
|
||||
onOpenSettings: () => void
|
||||
onOpenHelp: () => void
|
||||
language: ReturnType<typeof useLanguage>
|
||||
@@ -344,6 +369,7 @@ export function HomeUtilityNav(props: {
|
||||
return (
|
||||
<div
|
||||
class={`${props.class ?? ""} min-w-0 flex-row justify-between gap-1 lg:flex-col lg:justify-start lg:pr-3 [&>button]:w-auto lg:[&>button]:w-full`}
|
||||
classList={props.classList}
|
||||
>
|
||||
<HomeProjectNavButton
|
||||
type="button"
|
||||
|
||||
@@ -30,26 +30,42 @@ export function Home() {
|
||||
|
||||
function HomeOverview() {
|
||||
const layout = useLayout()
|
||||
const settings = useSettings()
|
||||
const home = createHomeController()
|
||||
const projects = createHomeProjectsController(home)
|
||||
const sessions = createHomeSessionsController(home)
|
||||
const search = createHomeSessionSearchController(home, sessions)
|
||||
const search = createHomeSessionSearchController(home, sessions, settings.appearance.navigationPrototype)
|
||||
|
||||
onMount(() => {
|
||||
if (layout.home.searchFocus.take()) search.query.focus()
|
||||
// The navigation prototype has no search dialog, so Home's search field starts focused.
|
||||
if (layout.home.searchFocus.take() || settings.appearance.navigationPrototype()) search.query.focus()
|
||||
})
|
||||
|
||||
return <HomeView projects={projects} sessions={sessions} search={search} />
|
||||
return (
|
||||
<HomeView
|
||||
projects={projects}
|
||||
sessions={sessions}
|
||||
search={search}
|
||||
searchInline={settings.appearance.navigationPrototype()}
|
||||
// The sidebar already lists sessions in side tabs and List, so Home drops its project column there and picks
|
||||
// the project from the search field instead. Top tabs have no sidebar and keep Home's column.
|
||||
projectScope={settings.appearance.navigationPrototype() && settings.appearance.tabLayout() === "vertical"}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export function HomeView(props: {
|
||||
projects: ReturnType<typeof createHomeProjectsController>
|
||||
sessions: ReturnType<typeof createHomeSessionsController>
|
||||
search: ReturnType<typeof createHomeSessionSearchController>
|
||||
/** The navigation prototype's project picker, at the end of the search field in place of the projects column. */
|
||||
projectScope?: boolean
|
||||
/** Search filters the list in place rather than opening a results panel. */
|
||||
searchInline?: boolean
|
||||
}) {
|
||||
const mobile = createMediaQuery("(max-width: 767px)")
|
||||
|
||||
const scroll = createHomeScrollController(props.sessions.data.groups)
|
||||
const scroll = createHomeScrollController(props.search.result.groups)
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -59,7 +75,7 @@ export function HomeView(props: {
|
||||
bg-v2-background-bg-base shadow-[var(--v2-elevation-raised)]
|
||||
`}
|
||||
>
|
||||
<Show when={mobile()}>
|
||||
<Show when={mobile() && !props.projectScope}>
|
||||
<div class="relative z-40 -mb-3 shrink-0 px-3 pt-3">
|
||||
<HomeProjects projects={props.projects} scroll={scroll} dropdown />
|
||||
</div>
|
||||
@@ -72,18 +88,28 @@ export function HomeView(props: {
|
||||
onScroll={(event) => scroll.viewport.update(event.currentTarget.scrollTop)}
|
||||
>
|
||||
<div
|
||||
class={`
|
||||
class={
|
||||
props.projectScope
|
||||
? "mx-auto grid min-h-full w-full max-w-[768px] grid-rows-[minmax(0,1fr)] px-3 lg:px-6"
|
||||
: `
|
||||
mx-auto grid min-h-full w-full max-w-[1080px] grid-rows-[auto_minmax(0,1fr)] gap-4 px-3
|
||||
max-md:grid-rows-[minmax(0,1fr)] lg:grid-cols-[280px_minmax(0,720px)] lg:grid-rows-1 lg:gap-8 lg:px-6
|
||||
`}
|
||||
`
|
||||
}
|
||||
>
|
||||
<Show when={!mobile()}>
|
||||
<Show when={!mobile() && !props.projectScope}>
|
||||
<HomeProjects projects={props.projects} scroll={scroll} />
|
||||
</Show>
|
||||
<HomeSessions sessions={props.sessions} search={props.search} scroll={scroll} />
|
||||
<HomeSessions
|
||||
sessions={props.sessions}
|
||||
search={props.search}
|
||||
scroll={scroll}
|
||||
searchScope={props.projectScope ? <HomeProjects projects={props.projects} dropdown scope /> : undefined}
|
||||
searchInline={props.searchInline}
|
||||
/>
|
||||
</div>
|
||||
</ScrollView>
|
||||
<div class="hidden shrink-0 px-3 py-2 md:block lg:hidden">
|
||||
<div class="hidden shrink-0 px-3 py-2 md:block lg:hidden" classList={{ "!hidden": props.projectScope }}>
|
||||
<HomeUtilityNav
|
||||
class="flex"
|
||||
onOpenSettings={props.projects.utility.settings}
|
||||
|
||||
@@ -2,19 +2,21 @@ import type { HomeScrollController } from "../scroll"
|
||||
import type { HomeSessionSearchController } from "./search"
|
||||
import type { HomeSessionsController } from "./controller"
|
||||
import { HomeSessionsView } from "./view"
|
||||
import { Show } from "solid-js"
|
||||
import { Show, type JSX } from "solid-js"
|
||||
|
||||
export function HomeSessions(props: {
|
||||
sessions: HomeSessionsController
|
||||
search: HomeSessionSearchController
|
||||
scroll: HomeScrollController
|
||||
searchScope?: JSX.Element
|
||||
searchInline?: boolean
|
||||
}) {
|
||||
return (
|
||||
<Show when={props.sessions.session.server()}>
|
||||
{(server) => (
|
||||
<HomeSessionsView
|
||||
language={props.sessions.copy.language}
|
||||
groups={props.sessions.data.groups()}
|
||||
groups={props.search.result.groups()}
|
||||
listView={props.sessions.data.listView()}
|
||||
onRetry={props.sessions.data.retry}
|
||||
desktop={props.sessions.platform.desktop}
|
||||
@@ -26,6 +28,7 @@ export function HomeSessions(props: {
|
||||
searchValue={props.search.query.value()}
|
||||
searchPlaceholder={props.search.query.placeholder()}
|
||||
searchOpen={props.search.query.open()}
|
||||
searchInline={props.searchInline}
|
||||
searchLoading={props.search.result.loading()}
|
||||
searchResults={props.search.result.list()}
|
||||
searchActive={props.search.result.active()}
|
||||
@@ -55,6 +58,7 @@ export function HomeSessions(props: {
|
||||
onSearchSelectActive={props.search.result.selectActive}
|
||||
onSearchHighlight={props.search.result.highlight}
|
||||
onSearchSelect={props.search.result.select}
|
||||
searchScope={props.searchScope}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
@@ -6,7 +6,12 @@ import { sessionLabel } from "@/session/title"
|
||||
import { makeEventListener } from "@solid-primitives/event-listener"
|
||||
import { createEffect, createMemo, createSignal, onCleanup, untrack } from "solid-js"
|
||||
import type { HomeController } from "../model"
|
||||
import { homeSessionSearchKey, type HomeSessionRecord, type HomeSessionsController } from "./controller"
|
||||
import {
|
||||
groupSessions,
|
||||
homeSessionSearchKey,
|
||||
type HomeSessionRecord,
|
||||
type HomeSessionsController,
|
||||
} from "./controller"
|
||||
import {
|
||||
INITIAL_HOME_SESSION_SEARCH_STATE,
|
||||
selectSearchExact,
|
||||
@@ -24,7 +29,12 @@ type HomeSessionSearchSource = Pick<HomeSessionsController, "data" | "session">
|
||||
|
||||
type PendingLookup = { controller: AbortController; timer: ReturnType<typeof setTimeout> }
|
||||
|
||||
export function createHomeSessionSearchController(home: HomeController, sessions: HomeSessionSearchSource) {
|
||||
/** `inline` filters Home's list in place instead of opening a results panel. */
|
||||
export function createHomeSessionSearchController(
|
||||
home: HomeController,
|
||||
sessions: HomeSessionSearchSource,
|
||||
inline: () => boolean = () => false,
|
||||
) {
|
||||
const command = useCommand()
|
||||
const language = useLanguage()
|
||||
const servers = useServers()
|
||||
@@ -94,7 +104,9 @@ export function createHomeSessionSearchController(home: HomeController, sessions
|
||||
return records[0] ? homeSessionSearchKey(records[0]) : ""
|
||||
})
|
||||
|
||||
const open = createMemo(() => selectSearchOpen(searchState()))
|
||||
const open = createMemo(() => !inline() && selectSearchOpen(searchState()))
|
||||
|
||||
const groups = createMemo(() => (inline() && query() ? groupSessions(results(), language) : sessions.data.groups()))
|
||||
|
||||
const placeholder = createMemo(() => {
|
||||
const project = home.project.selected()
|
||||
@@ -174,6 +186,7 @@ export function createHomeSessionSearchController(home: HomeController, sessions
|
||||
result: {
|
||||
loading: () => sessions.data.loading() || selectSearchLookingUp(searchState()),
|
||||
list: results,
|
||||
groups,
|
||||
active,
|
||||
noResultsLabel: () => language.t("home.sessions.search.noResults", { query: query() }),
|
||||
highlight: (record: HomeSessionRecord) =>
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
import type { SessionInfo } from "@opencode/client/promise"
|
||||
import { Key } from "@solid-primitives/keyed"
|
||||
import { createEffect, createMemo, createSignal, For, Index, Match, onCleanup, Show, Switch, untrack } from "solid-js"
|
||||
import {
|
||||
children,
|
||||
createEffect,
|
||||
createMemo,
|
||||
createSignal,
|
||||
For,
|
||||
Index,
|
||||
Match,
|
||||
onCleanup,
|
||||
Show,
|
||||
Switch,
|
||||
untrack,
|
||||
type JSX,
|
||||
} from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { InlineInput } from "@opencode/ui/inline-input"
|
||||
import { Loader } from "@opencode/ui/loader"
|
||||
@@ -116,6 +129,10 @@ export type HomeSessionsViewProps = {
|
||||
onSearchSelectActive: () => void
|
||||
onSearchHighlight: (record: HomeSessionRecord) => void
|
||||
onSearchSelect: (record: HomeSessionRecord, options?: OpenSessionOptions) => void
|
||||
/** Shown at the end of the search field, such as the project the list is scoped to. */
|
||||
searchScope?: JSX.Element
|
||||
/** The search filters `groups` in place: there is no results panel, and Enter opens the first match. */
|
||||
searchInline?: boolean
|
||||
}
|
||||
|
||||
export function HomeSessionsView(props: HomeSessionsViewProps) {
|
||||
@@ -286,6 +303,19 @@ export function HomeSessionsView(props: HomeSessionsViewProps) {
|
||||
/>
|
||||
)}
|
||||
</Match>
|
||||
<Match
|
||||
when={
|
||||
props.searchInline &&
|
||||
props.searchValue.trim() &&
|
||||
!props.searchLoading &&
|
||||
props.listView.status === "ready" &&
|
||||
props.groups.length === 0
|
||||
}
|
||||
>
|
||||
<div class={`px-2 pt-6 text-[13px] leading-[var(--line-height-compact)] ${HOME_SECTION_LABEL}`}>
|
||||
{props.searchNoResultsLabel}
|
||||
</div>
|
||||
</Match>
|
||||
<Match when={props.listView.status === "ready" && props.groups.length === 0}>
|
||||
<HomeSessionsEmpty
|
||||
onNewSession={props.canCreateSession ? props.onCreateSession : undefined}
|
||||
@@ -402,6 +432,8 @@ function HomeSessionSearch(
|
||||
onHoverSession: (sessionID: string | undefined) => void
|
||||
},
|
||||
) {
|
||||
const scope = children(() => props.searchScope)
|
||||
|
||||
return (
|
||||
<div class="w-full">
|
||||
<div
|
||||
@@ -511,6 +543,13 @@ function HomeSessionSearch(
|
||||
return
|
||||
}
|
||||
|
||||
if (props.searchInline && event.key === "Enter" && !event.isComposing && props.searchResults.length > 0) {
|
||||
event.preventDefault()
|
||||
props.onSearchSelectActive()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (!props.searchOpen || props.searchResults.length === 0) return
|
||||
|
||||
if (event.altKey || event.metaKey) return
|
||||
@@ -539,9 +578,11 @@ function HomeSessionSearch(
|
||||
<IconButton
|
||||
type="button"
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
size={props.searchInline ? "normal" : "small"}
|
||||
class="relative z-20 shrink-0"
|
||||
icon={<Icon name="close" size="large" class="text-v2-icon-icon-muted" />}
|
||||
icon={
|
||||
<Icon name="close" size={props.searchInline ? "normal" : "large"} class="text-v2-icon-icon-muted" />
|
||||
}
|
||||
aria-label={props.searchPlaceholder}
|
||||
onClick={() => {
|
||||
props.onSearchClose()
|
||||
@@ -549,6 +590,10 @@ function HomeSessionSearch(
|
||||
}}
|
||||
/>
|
||||
</Show>
|
||||
<Show when={props.searchValue && scope()}>
|
||||
<div aria-hidden="true" class="relative z-20 mx-0.5 h-4 w-px shrink-0 bg-v2-border-border-muted" />
|
||||
</Show>
|
||||
{scope()}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -895,6 +895,13 @@ export const dict = {
|
||||
"settings.experimental.sidebarOrganize.projects": "Projects",
|
||||
"settings.experimental.sidebarOrganize.list": "One list",
|
||||
"settings.experimental.sidebarOrganize.customize": "Customize",
|
||||
"settings.experimental.sidebarOrganize.consolidated": "Consolidated",
|
||||
"settings.general.row.navigation.title": "Navigation",
|
||||
"settings.general.row.navigation.description": "Keep the sessions you're working on as tabs, or see every session in one list.",
|
||||
"settings.general.row.navigation.tabs": "Tabs",
|
||||
"settings.general.row.navigation.list": "List",
|
||||
"settings.general.row.tabPosition.title": "Tab position",
|
||||
"sidebar.sessions": "Sessions",
|
||||
"sidebar.organize.projects": "Projects",
|
||||
"sidebar.organize.openTab": "Open tab",
|
||||
"sidebar.organize.showMore": "Show more",
|
||||
@@ -942,6 +949,37 @@ export const dict = {
|
||||
"tabs.groups.closeGroup": "Close group",
|
||||
"tabs.groups.name.placeholder": "Group name",
|
||||
"tabs.groups.unnamed": "Group {{number}}",
|
||||
"navigation.group.unpin": "Unpin group",
|
||||
"navigation.group.options": "Group options",
|
||||
"sidebar.recent.view.options": "Group and sort",
|
||||
"sidebar.recent.view.groupBy": "Group by",
|
||||
"sidebar.recent.view.groupBy.none": "None",
|
||||
"sidebar.recent.view.groupBy.date": "Date",
|
||||
"sidebar.recent.view.groupBy.status": "Status",
|
||||
"sidebar.recent.view.groupBy.project": "Project",
|
||||
"sidebar.recent.view.groupBy.server": "Server",
|
||||
"sidebar.recent.view.sortBy": "Sort by",
|
||||
"sidebar.recent.view.sortBy.updated": "Last updated",
|
||||
"sidebar.recent.view.sortBy.created": "Date created",
|
||||
"sidebar.recent.view.sortBy.name": "Name",
|
||||
"sidebar.recent.view.direction.desc": "Descending",
|
||||
"sidebar.recent.view.direction.asc": "Ascending",
|
||||
"sidebar.recent.view.show": "Show",
|
||||
"sidebar.recent.view.show.metadata": "Metadata",
|
||||
"sidebar.recent.view.show.emptyGroups": "Empty groups",
|
||||
"sidebar.recent.view.reset": "Reset to defaults",
|
||||
"sidebar.recent.view.viewAll": "View all",
|
||||
"sidebar.recent.group.date.today": "Today",
|
||||
"sidebar.recent.group.date.yesterday": "Yesterday",
|
||||
"sidebar.recent.group.date.week": "Last week",
|
||||
"sidebar.recent.group.date.older": "Older",
|
||||
"sidebar.recent.group.status.attention": "Needs attention",
|
||||
"sidebar.recent.group.status.working": "Working",
|
||||
"sidebar.recent.group.status.unread": "Unread",
|
||||
"sidebar.recent.group.status.read": "Read",
|
||||
"sidebar.recent.group.project.none": "No project",
|
||||
"sidebar.recent.meta.attention": "Waiting",
|
||||
"sidebar.recent.meta.working": "Working",
|
||||
"tabs.groups.color": "Group color",
|
||||
"tabs.groups.color.blue": "Steel",
|
||||
"tabs.groups.color.green": "Sage",
|
||||
|
||||
@@ -194,3 +194,155 @@
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
}
|
||||
|
||||
/* The navigation prototype's Tabs and List cards: a window that shows only its navigation, fading into the name. */
|
||||
[data-component="navigation-mode"] {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
[data-slot="navigation-mode-option"] {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 120px;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid var(--v2-border-border-base);
|
||||
border-radius: 8px;
|
||||
background-color: var(--v2-background-bg-base);
|
||||
cursor: pointer;
|
||||
transition: border-color 120ms ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--v2-border-border-strong);
|
||||
}
|
||||
|
||||
&[data-checked] {
|
||||
border-color: var(--v2-border-border-focus);
|
||||
box-shadow: inset 0 0 0 1px var(--v2-border-border-focus);
|
||||
}
|
||||
|
||||
&:has(input:focus-visible) {
|
||||
outline: 2px solid var(--v2-border-border-focus);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
span {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Color gives the structure: the window on a lighter layer, its navigation lighter again, the chosen tab or row
|
||||
brightest. Hairlines only finish the edges. */
|
||||
[data-slot="navigation-mode-sketch"] {
|
||||
position: relative;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height: 56px;
|
||||
margin: 10px 10px 0;
|
||||
border-radius: 5px 5px 0 0;
|
||||
background-color: var(--v2-background-bg-layer-01);
|
||||
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-muted);
|
||||
mask-image: linear-gradient(to bottom, #000 40%, transparent 95%);
|
||||
|
||||
&[data-mode="tabs"] {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
[data-slot="sketch-tabs"] {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
padding: 5px;
|
||||
background-color: var(--v2-background-bg-layer-02);
|
||||
box-shadow: inset 0 -0.5px 0 var(--v2-border-border-muted);
|
||||
}
|
||||
|
||||
[data-slot="sketch-tab"] {
|
||||
width: 24px;
|
||||
height: 8px;
|
||||
border-radius: 2.5px;
|
||||
background-color: var(--v2-background-bg-layer-03);
|
||||
|
||||
&[data-active] {
|
||||
background-color: var(--v2-text-text-faint);
|
||||
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base);
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="sketch-list"] {
|
||||
display: flex;
|
||||
width: 44px;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
padding: 5px 4px;
|
||||
background-color: var(--v2-background-bg-layer-02);
|
||||
box-shadow: inset -0.5px 0 0 var(--v2-border-border-muted);
|
||||
}
|
||||
|
||||
/* Even sizes keep the square and the line on the same center line. */
|
||||
[data-slot="sketch-row"] {
|
||||
display: flex;
|
||||
height: 8px;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding-inline: 2px;
|
||||
border-radius: 2px;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 1px;
|
||||
background-color: var(--v2-background-bg-layer-04);
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
height: 2px;
|
||||
flex: 1;
|
||||
border-radius: 1px;
|
||||
background-color: var(--v2-background-bg-layer-04);
|
||||
}
|
||||
|
||||
&[data-active] {
|
||||
background-color: var(--v2-background-bg-layer-04);
|
||||
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base);
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="navigation-mode-name"] {
|
||||
margin-top: -14px;
|
||||
padding: 0 10px 8px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: var(--line-height-compact);
|
||||
color: var(--v2-text-text-muted);
|
||||
transition: color 120ms ease;
|
||||
|
||||
[data-slot="navigation-mode-option"]:hover &,
|
||||
[data-checked] & {
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { For, Match, Switch, createUniqueId } from "solid-js"
|
||||
import { For, Match, Show, Switch, createUniqueId } from "solid-js"
|
||||
import { Select } from "@opencode/ui/select"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { type TabLayout, useSettings } from "@/settings/model"
|
||||
import { SettingsRow } from "@/settings/row"
|
||||
@@ -13,6 +14,92 @@ const modes = [
|
||||
export function InterfaceModeSetting() {
|
||||
const language = useLanguage()
|
||||
const settings = useSettings()
|
||||
|
||||
return (
|
||||
<Show when={settings.appearance.navigationPrototype()} fallback={<TabLayoutSetting />}>
|
||||
<NavigationSetting />
|
||||
<Show when={settings.appearance.navigation() === "tabs"}>
|
||||
<SettingsRow title={language.t("settings.general.row.tabPosition.title")} description="">
|
||||
<Select
|
||||
data-action="settings-tab-position"
|
||||
options={["horizontal", "vertical"] as const}
|
||||
current={settings.appearance.tabPosition()}
|
||||
label={(value) =>
|
||||
language.t(
|
||||
value === "horizontal"
|
||||
? "settings.general.row.interfaceMode.top"
|
||||
: "settings.general.row.interfaceMode.side",
|
||||
)
|
||||
}
|
||||
onSelect={(value) =>
|
||||
(value === "horizontal" || value === "vertical") && settings.appearance.setTabLayout(value)
|
||||
}
|
||||
placement="bottom-end"
|
||||
gutter={6}
|
||||
/>
|
||||
</SettingsRow>
|
||||
</Show>
|
||||
</Show>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationSetting() {
|
||||
const language = useLanguage()
|
||||
const settings = useSettings()
|
||||
const id = createUniqueId()
|
||||
|
||||
return (
|
||||
<SettingsRow
|
||||
title={language.t("settings.general.row.navigation.title")}
|
||||
description={<span class="[text-wrap:balance]">{language.t("settings.general.row.navigation.description")}</span>}
|
||||
align="start"
|
||||
>
|
||||
<fieldset data-component="navigation-mode" data-action="settings-navigation">
|
||||
<legend class="sr-only">{language.t("settings.general.row.navigation.title")}</legend>
|
||||
<For each={["tabs", "list"] as const}>
|
||||
{(mode) => (
|
||||
<label
|
||||
data-slot="navigation-mode-option"
|
||||
data-checked={settings.appearance.navigation() === mode ? "" : undefined}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name={id}
|
||||
value={mode}
|
||||
checked={settings.appearance.navigation() === mode}
|
||||
onChange={() => settings.appearance.setNavigation(mode)}
|
||||
/>
|
||||
{/* A window that shows only its navigation: a row of tabs across the top, or a list down the side. */}
|
||||
<span data-slot="navigation-mode-sketch" data-mode={mode} aria-hidden="true">
|
||||
<Show
|
||||
when={mode === "tabs"}
|
||||
fallback={
|
||||
<span data-slot="sketch-list">
|
||||
<For each={[0, 1, 2, 3, 4]}>
|
||||
{(index) => <span data-slot="sketch-row" data-active={index === 1 ? "" : undefined} />}
|
||||
</For>
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<span data-slot="sketch-tabs">
|
||||
<For each={[0, 1, 2]}>
|
||||
{(index) => <span data-slot="sketch-tab" data-active={index === 0 ? "" : undefined} />}
|
||||
</For>
|
||||
</span>
|
||||
</Show>
|
||||
</span>
|
||||
<span data-slot="navigation-mode-name">{language.t(`settings.general.row.navigation.${mode}`)}</span>
|
||||
</label>
|
||||
)}
|
||||
</For>
|
||||
</fieldset>
|
||||
</SettingsRow>
|
||||
)
|
||||
}
|
||||
|
||||
function TabLayoutSetting() {
|
||||
const language = useLanguage()
|
||||
const settings = useSettings()
|
||||
const id = createUniqueId()
|
||||
|
||||
return (
|
||||
|
||||
@@ -137,7 +137,7 @@ const generalSchema = Persistence.struct({
|
||||
newTimeline: Persistence.optional(Schema.Boolean),
|
||||
// Browser-style session tab grouping across vertical and horizontal tabs.
|
||||
tabGroups: Persistence.optional(Schema.Boolean),
|
||||
sidebarOrganize: Schema.Literals(["projects", "list", "customize", "recent"]),
|
||||
sidebarOrganize: Schema.Literals(["projects", "list", "customize", "recent", "consolidated"]),
|
||||
mobileTitlebarPosition: Schema.Literals(["top", "bottom"]),
|
||||
// Owned by the review plugin, which copies it out once; kept so settings rewrites cannot drop it first.
|
||||
mobileDiffWrap: Persistence.optional(Schema.Boolean),
|
||||
@@ -151,6 +151,8 @@ const appearanceSchema = Persistence.struct({
|
||||
terminal: Schema.String,
|
||||
// "inbox" is experimental: the vertical layout with a server-wide session inbox in place of tabs.
|
||||
tabLayout: Schema.Literals(["horizontal", "vertical", "inbox"]),
|
||||
// Prototype (local/dev desktop builds): tabs at `tabLayout`'s position, or one list of every session.
|
||||
navigation: Persistence.optional(Schema.Literals(["tabs", "list"])),
|
||||
sidebarOpen: Persistence.optional(Schema.Boolean),
|
||||
reduceMotion: Schema.Literals(["system", "on", "off"]),
|
||||
})
|
||||
@@ -348,11 +350,10 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
|
||||
init: () => {
|
||||
const [store, setStore, , ready] = persisted({ key: "settings.v3" }, settingsPersistence, defaultSettings)
|
||||
|
||||
const sidebarOrganizeOptions: SidebarOrganize[] = recentSessionsAvailable(
|
||||
usePlatform().platform,
|
||||
import.meta.env.VITE_OPENCODE_CHANNEL,
|
||||
)
|
||||
? ["list", "projects", "customize", "recent"]
|
||||
const prototypes = recentSessionsAvailable(usePlatform().platform, import.meta.env.VITE_OPENCODE_CHANNEL)
|
||||
|
||||
const sidebarOrganizeOptions: SidebarOrganize[] = prototypes
|
||||
? ["list", "projects", "customize", "recent", "consolidated"]
|
||||
: ["list", "projects", "customize"]
|
||||
|
||||
const showCustomAgents = withFallback(
|
||||
@@ -491,10 +492,30 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
|
||||
setTerminalFont(value: string) {
|
||||
setStore("appearance", "terminal", value.trim() ? value : "")
|
||||
},
|
||||
tabLayout: withFallback(() => store.appearance?.tabLayout, defaultSettings.appearance.tabLayout),
|
||||
// The List layout always uses the sidebar, and the prototype has no Inbox, so both read as side tabs.
|
||||
tabLayout: createMemo((): TabLayout => {
|
||||
const stored = store.appearance?.tabLayout ?? defaultSettings.appearance.tabLayout
|
||||
const prototype = prototypes && store.general?.sidebarOrganize === "consolidated"
|
||||
|
||||
if (prototype && (store.appearance?.navigation === "list" || stored === "inbox")) return "vertical"
|
||||
|
||||
return stored
|
||||
}),
|
||||
/** Where tabs go when the prototype's Tabs layout is chosen, whatever the List layout forces meanwhile. */
|
||||
tabPosition: createMemo(() => (store.appearance?.tabLayout === "horizontal" ? "horizontal" : "vertical")),
|
||||
setTabLayout(value: TabLayout) {
|
||||
setStore("appearance", "tabLayout", value)
|
||||
},
|
||||
/** The navigation prototype (Experimental → Consolidated): pinned sessions and groups, and Tabs or List. */
|
||||
navigationPrototype: createMemo(() => prototypes && store.general?.sidebarOrganize === "consolidated"),
|
||||
navigation: createMemo(() =>
|
||||
prototypes && store.general?.sidebarOrganize === "consolidated" && store.appearance?.navigation === "list"
|
||||
? "list"
|
||||
: "tabs",
|
||||
),
|
||||
setNavigation(value: "tabs" | "list") {
|
||||
setStore("appearance", "navigation", value)
|
||||
},
|
||||
sidebarOpen: withFallback(() => store.appearance?.sidebarOpen, true),
|
||||
setSidebarOpen(value: boolean) {
|
||||
setStore("appearance", "sidebarOpen", value)
|
||||
|
||||
@@ -12,7 +12,9 @@ export function useProjectNavigation() {
|
||||
const mobile = createMediaQuery("(max-width: 767px)")
|
||||
|
||||
return () => {
|
||||
if (mobile() || settings.appearance.tabLayout() !== "vertical") return false
|
||||
// The navigation prototype keeps Home in the sidebar.
|
||||
if (mobile() || settings.appearance.tabLayout() !== "vertical" || settings.appearance.navigationPrototype())
|
||||
return false
|
||||
const mode = settings.general.sidebarOrganize()
|
||||
|
||||
return mode === "projects" || mode === "customize"
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { createEffect, on, type Accessor } from "solid-js"
|
||||
import { Schema } from "effect"
|
||||
import { Persistence } from "@/runtime/persistence/schema"
|
||||
import { Persist, persisted } from "@/runtime/persistence/storage"
|
||||
import { ServerConnection } from "@/runtime/server/registry"
|
||||
import { useSettings } from "@/settings/model"
|
||||
import { tabKey, useTabs, type Tab } from "./tabs"
|
||||
|
||||
const ListSnapshot = Persistence.struct({
|
||||
/** The tabs open when List was turned on, by tab key; empty while Tabs is in use. */
|
||||
keys: Persistence.array(Schema.String),
|
||||
sessions: Persistence.array(Persistence.struct({ server: Schema.String, sessionId: Schema.String })),
|
||||
})
|
||||
|
||||
/**
|
||||
* The navigation prototype's switch between Tabs and List. List still opens each session in a tab, so turning it on
|
||||
* remembers the tabs you had; turning it off closes the tabs List opened and brings back any of yours that closed,
|
||||
* keeping the session you're on either way.
|
||||
*/
|
||||
export function createNavigationSwitch(currentTab: Accessor<Tab | undefined>) {
|
||||
const settings = useSettings()
|
||||
const tabs = useTabs()
|
||||
|
||||
const [snapshot, setSnapshot, , ready] = persisted(Persist.global("navigation.list-snapshot"), ListSnapshot, {
|
||||
keys: [],
|
||||
sessions: [],
|
||||
})
|
||||
|
||||
createEffect(
|
||||
on(
|
||||
() => ready() && settings.ready() && settings.appearance.navigation(),
|
||||
(navigation, previous) => {
|
||||
if (!navigation) return
|
||||
|
||||
if (navigation === "list") {
|
||||
// Restarting in List keeps the snapshot taken when it was turned on.
|
||||
if (!previous && snapshot.keys.length > 0) return
|
||||
|
||||
if (previous === "list") return
|
||||
setSnapshot({
|
||||
keys: tabs.store.map(tabKey),
|
||||
sessions: tabs.store.flatMap((tab) =>
|
||||
tab.type === "session" ? [{ server: tab.server, sessionId: tab.sessionId }] : [],
|
||||
),
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (previous !== "list" || snapshot.keys.length === 0) return
|
||||
restore()
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
function restore() {
|
||||
const kept = new Set(snapshot.keys)
|
||||
const current = currentTab()
|
||||
const currentKey = current ? tabKey(current) : undefined
|
||||
|
||||
const open = new Set(tabs.store.map(tabKey))
|
||||
|
||||
snapshot.sessions.forEach((session) => {
|
||||
const tab = { server: ServerConnection.Key.make(session.server), sessionId: session.sessionId }
|
||||
|
||||
if (!open.has(tabKey({ type: "session", ...tab }))) tabs.addSessionTab(tab)
|
||||
})
|
||||
|
||||
const opened = tabs.store.map(tabKey).filter((key) => !kept.has(key) && key !== currentKey)
|
||||
const keep = current ?? tabs.store.find((tab) => kept.has(tabKey(tab)))
|
||||
|
||||
if (opened.length > 0 && keep) tabs.closeTabs(opened, keep)
|
||||
setSnapshot({ keys: [], sessions: [] })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { ServerConnection } from "@/runtime/server/registry"
|
||||
import {
|
||||
createGroup,
|
||||
EMPTY_PINS,
|
||||
groupOf,
|
||||
isPinned,
|
||||
moveToGroup,
|
||||
pin,
|
||||
pinnedRefs,
|
||||
removeFromGroup,
|
||||
toggleGroup,
|
||||
ungroup,
|
||||
unpin,
|
||||
unpinGroup,
|
||||
type PinRef,
|
||||
} from "./pins"
|
||||
|
||||
const server = ServerConnection.Key.make("http://127.0.0.1:4096")
|
||||
|
||||
const ref = (sessionId: string): PinRef => ({ server, sessionId })
|
||||
|
||||
const group = (id: string) => ({ id, name: id, color: "blue" as const })
|
||||
|
||||
describe("pins", () => {
|
||||
test("groups only hold pinned sessions: grouping pins, and unpinning leaves the group", () => {
|
||||
const grouped = createGroup(EMPTY_PINS, ref("a"), group("g"))
|
||||
expect(isPinned(grouped, ref("a"))).toBe(true)
|
||||
expect(groupOf(grouped, ref("a"))?.id).toBe("g")
|
||||
|
||||
const unpinned = unpin(grouped, ref("a"))
|
||||
expect(isPinned(unpinned, ref("a"))).toBe(false)
|
||||
expect(unpinned.items).toEqual([])
|
||||
})
|
||||
|
||||
test("a group starts where its first session was pinned, and taking a session out keeps it pinned after the group", () => {
|
||||
const state = createGroup(pin(pin(pin(EMPTY_PINS, ref("a")), ref("b")), ref("c")), ref("b"), group("g"))
|
||||
expect(state.items.map((item) => (item.type === "group" ? item.id : item.sessionId))).toEqual(["a", "g", "c"])
|
||||
|
||||
const joined = moveToGroup(state, ref("c"), "g")
|
||||
expect(pinnedRefs(joined).map((item) => item.sessionId)).toEqual(["a", "b", "c"])
|
||||
|
||||
const out = removeFromGroup(joined, ref("b"))
|
||||
expect(out.items.map((item) => (item.type === "group" ? item.id : item.sessionId))).toEqual(["a", "g", "b"])
|
||||
expect(isPinned(out, ref("b"))).toBe(true)
|
||||
})
|
||||
|
||||
test("ungrouping keeps sessions pinned in place; unpinning a group unpins them", () => {
|
||||
const state = moveToGroup(createGroup(pin(EMPTY_PINS, ref("a")), ref("b"), group("g")), ref("c"), "g")
|
||||
expect(ungroup(state, "g").items.map((item) => (item.type === "group" ? item.id : item.sessionId))).toEqual([
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
])
|
||||
expect(pinnedRefs(unpinGroup(state, "g")).map((item) => item.sessionId)).toEqual(["a"])
|
||||
})
|
||||
|
||||
test("opening a group collapses the others, and no-op operations return the same state", () => {
|
||||
const state = createGroup(createGroup(EMPTY_PINS, ref("a"), group("g1")), ref("b"), group("g2"))
|
||||
const opened = toggleGroup(toggleGroup(state, "g1"), "g2")
|
||||
expect(opened.collapsed).toEqual({ g1: true, g2: false })
|
||||
expect(toggleGroup(opened, "g2").collapsed).toEqual({ g1: true, g2: true })
|
||||
|
||||
expect(pin(state, ref("a"))).toBe(state)
|
||||
expect(unpin(state, ref("zzz"))).toBe(state)
|
||||
expect(moveToGroup(state, ref("a"), "g1")).toBe(state)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,194 @@
|
||||
import { Schema } from "effect"
|
||||
import { Persistence } from "@/runtime/persistence/schema"
|
||||
import { TAB_GROUP_COLORS, type TabGroupColor } from "@/shell/titlebar/tab-groups"
|
||||
import { ServerKey } from "./schema"
|
||||
|
||||
/**
|
||||
* Pinned sessions and the groups that hold them. Groups only exist among pins (Arc's folders): grouping a session pins
|
||||
* it, and unpinning a session takes it out of its group. Every operation returns the same state when nothing changes.
|
||||
*/
|
||||
|
||||
const SessionRef = Persistence.struct({ server: ServerKey, sessionId: Schema.String })
|
||||
|
||||
const PinnedSession = Persistence.struct({
|
||||
type: Schema.Literal("session"),
|
||||
server: ServerKey,
|
||||
sessionId: Schema.String,
|
||||
})
|
||||
|
||||
const PinnedGroup = Persistence.struct({
|
||||
type: Schema.Literal("group"),
|
||||
id: Schema.String,
|
||||
name: Schema.String,
|
||||
color: Schema.Literals(TAB_GROUP_COLORS),
|
||||
sessions: Persistence.array(SessionRef),
|
||||
})
|
||||
|
||||
export const PinsStateSchema = Persistence.struct({
|
||||
items: Persistence.array(Schema.Union([PinnedSession, PinnedGroup])),
|
||||
collapsed: Persistence.record(Schema.Boolean),
|
||||
})
|
||||
|
||||
export type PinsState = typeof PinsStateSchema.Type
|
||||
|
||||
export type PinRef = typeof SessionRef.Type
|
||||
|
||||
export type PinItem = PinsState["items"][number]
|
||||
|
||||
export type PinGroup = Extract<PinItem, { type: "group" }>
|
||||
|
||||
export const EMPTY_PINS: PinsState = { items: [], collapsed: {} }
|
||||
|
||||
export const pinKey = (ref: PinRef) => `${ref.server}\0${ref.sessionId}`
|
||||
|
||||
const same = (a: PinRef, b: PinRef) => a.server === b.server && a.sessionId === b.sessionId
|
||||
|
||||
/** The group holding a pinned session, or undefined for a session pinned on its own (or not pinned). */
|
||||
export function groupOf(state: PinsState, ref: PinRef) {
|
||||
return state.items.find(
|
||||
(item): item is PinGroup => item.type === "group" && item.sessions.some((session) => same(session, ref)),
|
||||
)
|
||||
}
|
||||
|
||||
export function isPinned(state: PinsState, ref: PinRef) {
|
||||
return state.items.some((item) =>
|
||||
item.type === "session" ? same(item, ref) : item.sessions.some((session) => same(session, ref)),
|
||||
)
|
||||
}
|
||||
|
||||
/** Every pinned session in display order, groups included. */
|
||||
export function pinnedRefs(state: PinsState): PinRef[] {
|
||||
return state.items.flatMap((item) =>
|
||||
item.type === "session" ? [{ server: item.server, sessionId: item.sessionId }] : item.sessions,
|
||||
)
|
||||
}
|
||||
|
||||
export function pin(state: PinsState, ref: PinRef): PinsState {
|
||||
if (isPinned(state, ref)) return state
|
||||
|
||||
return { ...state, items: [...state.items, { type: "session", server: ref.server, sessionId: ref.sessionId }] }
|
||||
}
|
||||
|
||||
/** Unpins a session wherever it is. A group left empty goes away. */
|
||||
export function unpin(state: PinsState, ref: PinRef): PinsState {
|
||||
if (!isPinned(state, ref)) return state
|
||||
|
||||
return withItems(
|
||||
state,
|
||||
state.items.flatMap((item): PinItem[] => {
|
||||
if (item.type === "session") return same(item, ref) ? [] : [item]
|
||||
const sessions = item.sessions.filter((session) => !same(session, ref))
|
||||
|
||||
return sessions.length ? [{ ...item, sessions }] : []
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/** Starts a group with one session, where that session was pinned, or at the end if it was not pinned. */
|
||||
export function createGroup(
|
||||
state: PinsState,
|
||||
ref: PinRef,
|
||||
group: { id: string; name: string; color: TabGroupColor },
|
||||
): PinsState {
|
||||
const created: PinGroup = { type: "group", ...group, sessions: [{ server: ref.server, sessionId: ref.sessionId }] }
|
||||
const index = state.items.findIndex((item) => item.type === "session" && same(item, ref))
|
||||
|
||||
if (index !== -1) return withItems(state, state.items.toSpliced(index, 1, created))
|
||||
const rest = unpin(state, ref)
|
||||
|
||||
return withItems(rest, [...rest.items, created])
|
||||
}
|
||||
|
||||
/** Moves a session into a group, pinning it first if needed. */
|
||||
export function moveToGroup(state: PinsState, ref: PinRef, groupId: string): PinsState {
|
||||
const target = state.items.find((item) => item.type === "group" && item.id === groupId)
|
||||
|
||||
if (!target || groupOf(state, ref)?.id === groupId) return state
|
||||
const rest = unpin(state, ref)
|
||||
|
||||
return withItems(
|
||||
rest,
|
||||
rest.items.map((item) =>
|
||||
item.type === "group" && item.id === groupId
|
||||
? { ...item, sessions: [...item.sessions, { server: ref.server, sessionId: ref.sessionId }] }
|
||||
: item,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/** Takes a session out of its group and keeps it pinned, right after the group. */
|
||||
export function removeFromGroup(state: PinsState, ref: PinRef): PinsState {
|
||||
const group = groupOf(state, ref)
|
||||
|
||||
if (!group) return state
|
||||
const sessions = group.sessions.filter((session) => !same(session, ref))
|
||||
const index = state.items.indexOf(group)
|
||||
const loose: PinItem = { type: "session", server: ref.server, sessionId: ref.sessionId }
|
||||
|
||||
return withItems(
|
||||
state,
|
||||
state.items.toSpliced(index, 1, ...(sessions.length ? [{ ...group, sessions }, loose] : [loose])),
|
||||
)
|
||||
}
|
||||
|
||||
/** Dissolves a group; its sessions stay pinned where the group was. */
|
||||
export function ungroup(state: PinsState, groupId: string): PinsState {
|
||||
const index = state.items.findIndex((item) => item.type === "group" && item.id === groupId)
|
||||
const group = state.items[index]
|
||||
|
||||
if (!group || group.type !== "group") return state
|
||||
|
||||
return withItems(
|
||||
state,
|
||||
state.items.toSpliced(index, 1, ...group.sessions.map((session): PinItem => ({ type: "session", ...session }))),
|
||||
)
|
||||
}
|
||||
|
||||
/** Removes a group and unpins everything in it. */
|
||||
export function unpinGroup(state: PinsState, groupId: string): PinsState {
|
||||
if (!state.items.some((item) => item.type === "group" && item.id === groupId)) return state
|
||||
|
||||
return withItems(
|
||||
state,
|
||||
state.items.filter((item) => item.type !== "group" || item.id !== groupId),
|
||||
)
|
||||
}
|
||||
|
||||
export function updateGroup(
|
||||
state: PinsState,
|
||||
groupId: string,
|
||||
patch: Partial<Pick<PinGroup, "name" | "color">>,
|
||||
): PinsState {
|
||||
return withItems(
|
||||
state,
|
||||
state.items.map((item) => (item.type === "group" && item.id === groupId ? { ...item, ...patch } : item)),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands one group and collapses the rest (accordion), or collapses it when it was open. The group holding the
|
||||
* current session is shown expanded by the view regardless, so leaving it lets it fold away again.
|
||||
*/
|
||||
export function toggleGroup(state: PinsState, groupId: string): PinsState {
|
||||
const open = !state.collapsed[groupId]
|
||||
|
||||
const collapsed = Object.fromEntries(
|
||||
state.items.flatMap((item) => (item.type === "group" ? [[item.id, open || item.id !== groupId]] : [])),
|
||||
)
|
||||
|
||||
return { ...state, collapsed }
|
||||
}
|
||||
|
||||
/** Drops pins whose sessions are gone. */
|
||||
export function prunePins(state: PinsState, missing: (ref: PinRef) => boolean): PinsState {
|
||||
const gone = pinnedRefs(state).filter(missing)
|
||||
|
||||
return gone.reduce(unpin, state)
|
||||
}
|
||||
|
||||
function withItems(state: PinsState, items: PinItem[]): PinsState {
|
||||
const ids = new Set(items.flatMap((item) => (item.type === "group" ? [item.id] : [])))
|
||||
const collapsed = Object.fromEntries(Object.entries(state.collapsed).filter(([id]) => ids.has(id)))
|
||||
|
||||
return { items, collapsed }
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/* A group's marker: a small square of its color, drawn like a project avatar (its colors, top highlight and
|
||||
hairline border). */
|
||||
[data-slot="pinned-group-rect"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-gray);
|
||||
--pinned-group-border: var(--v2-avatar-border-gray);
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 2px;
|
||||
/* Brighter than an avatar's fill, since the square has no letter to carry it; a softer highlight. */
|
||||
background:
|
||||
linear-gradient(180deg, var(--v2-alpha-light-10) 0%, var(--v2-alpha-light-0) 100%),
|
||||
oklch(from var(--pinned-group-bg) calc(l + 0.1) calc(c * 1.15) h);
|
||||
box-shadow: inset 0 0 0 0.5px var(--pinned-group-border);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="blue"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-blue);
|
||||
--pinned-group-border: var(--v2-avatar-border-blue);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="green"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-green);
|
||||
--pinned-group-border: var(--v2-avatar-border-green);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="orange"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-orange);
|
||||
--pinned-group-border: var(--v2-avatar-border-orange);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="purple"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-purple);
|
||||
--pinned-group-border: var(--v2-avatar-border-purple);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="cyan"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-cyan);
|
||||
--pinned-group-border: var(--v2-avatar-border-cyan);
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-rect"][data-group-color="pink"] {
|
||||
--pinned-group-bg: var(--v2-avatar-bg-pink);
|
||||
--pinned-group-border: var(--v2-avatar-border-pink);
|
||||
}
|
||||
|
||||
/* Menus center it in the 16px icon slot. */
|
||||
[data-component="menu-v2-item"] [data-slot="pinned-group-rect"],
|
||||
[data-slot="pinned-group-name"] [data-slot="pinned-group-rect"] {
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
/* The name field matches the new session project search: borderless on the menu, a hairline below it. */
|
||||
[data-slot="pinned-group-name"] {
|
||||
padding: 4px 4px 2px;
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-name"] [data-component="text-input-v2"] {
|
||||
height: 28px;
|
||||
padding-inline-end: 6px;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-name"] [data-slot="text-input-v2-value"] {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-name"] [data-slot="text-input-v2-leading-icon"] {
|
||||
padding-inline-start: 6px;
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-name"] [data-slot="text-input-v2-input"]::placeholder {
|
||||
color: var(--v2-text-text-base);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
[data-component="pinned-group"][data-orientation="vertical"] [data-slot="pinned-group-rect"] {
|
||||
margin-inline: 3px;
|
||||
}
|
||||
|
||||
/* Top tabs outline a group around its marker and sessions, so its sessions read as one set. The outline is drawn
|
||||
above the tabs, whose backgrounds would otherwise cover it. */
|
||||
[data-component="pinned-group"][data-orientation="horizontal"] {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
[data-component="pinned-group"][data-orientation="horizontal"]::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
border-radius: inherit;
|
||||
box-shadow: inset 0 0 0 1px var(--tab-group-pill-border);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
[data-slot="pinned-group-label"] {
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
/* Pinned tabs sit in their own row, so the strip's separators between tabs don't apply. */
|
||||
[data-component="pinned-area"] [data-titlebar-tab-slot]::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Icon-only pinned tabs have no close button. The strip centers its close slot over the avatar at this width and
|
||||
paints it on hover, which hid the avatar; keep the slot only for a running session's activity ring. */
|
||||
[data-pinned-slot][data-orientation="horizontal"] [data-titlebar-tab]:not([data-status="busy"]) [data-slot="tab-close"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[data-pinned-slot][data-orientation="horizontal"] [data-slot="tab-close"] {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
/* Side tabs hang a group's sessions off a thin line running down from the center of its square (8px inset + 3px
|
||||
margin + half of 10px). */
|
||||
[data-component="pinned-group"][data-orientation="vertical"] [data-slot="pinned-group-sessions"]:not(:empty)::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset-block: 2px;
|
||||
inset-inline-start: 15.5px;
|
||||
width: 1px;
|
||||
border-radius: 1px;
|
||||
background: var(--v2-border-border-muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* A closed group whose hidden sessions need you: a dot on its square's corner, as on a tab's avatar. */
|
||||
[data-slot="pinned-group-mark"] {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
inset-inline-end: -3px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 9999px;
|
||||
background: var(--v2-background-bg-accent);
|
||||
pointer-events: none;
|
||||
|
||||
&[data-mark="attention"] {
|
||||
background: var(--v2-state-fg-warning);
|
||||
}
|
||||
}
|
||||
|
||||
[data-component="pinned-group"][data-orientation="vertical"] [data-slot="pinned-group-mark"] {
|
||||
inset-inline-end: 0;
|
||||
}
|
||||
@@ -0,0 +1,613 @@
|
||||
import { createEffect, createMemo, For, Match, Show, startTransition, Switch, type JSX } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { Key } from "@solid-primitives/keyed"
|
||||
import type { SessionInfo } from "@opencode/client/promise"
|
||||
import { createSimpleContext } from "@opencode/ui/context"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { TextInput } from "@opencode/ui/text-input"
|
||||
import { Tooltip } from "@opencode/ui/tooltip"
|
||||
import { uuid } from "@opencode/util/uuid"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { Persist, persisted } from "@/runtime/persistence/storage"
|
||||
import { ServerConnection } from "@/runtime/server/registry"
|
||||
import { useGlobal, type ServerCtx } from "@/runtime/server/runtime"
|
||||
import { sessionStatus, useSessionTabAvatarState } from "@/shell/layout/project-avatar-state"
|
||||
import { projectSettingsKey, useSettings } from "@/settings/model"
|
||||
import { tabHref, tabKey, useTabs, type Tab } from "@/shell/tabs/tabs"
|
||||
import {
|
||||
createGroup,
|
||||
EMPTY_PINS,
|
||||
groupOf,
|
||||
isPinned,
|
||||
moveToGroup,
|
||||
pin,
|
||||
pinKey,
|
||||
PinsStateSchema,
|
||||
prunePins,
|
||||
removeFromGroup,
|
||||
toggleGroup,
|
||||
ungroup,
|
||||
unpin,
|
||||
unpinGroup,
|
||||
updateGroup,
|
||||
type PinGroup,
|
||||
type PinRef,
|
||||
type PinsState,
|
||||
} from "@/shell/tabs/pins"
|
||||
import { AUTO_TAB_GROUP_COLORS, nextManualGroupColor, type TabGroupColor } from "./tab-groups"
|
||||
import { TabNavItem } from "./tab-nav"
|
||||
import { syncInactiveSession, type TabStripLeading } from "./tab-strip"
|
||||
import "./tab-groups.css"
|
||||
import "./pinned-area.css"
|
||||
|
||||
type Orientation = "horizontal" | "vertical"
|
||||
|
||||
/** Pinned sessions and their groups, shared by every tab position and the List layout. */
|
||||
export const { use: usePins, provider: PinsProvider } = createSimpleContext({
|
||||
name: "Pins",
|
||||
gate: false,
|
||||
init: (props: { currentTab: () => Tab | undefined }) => {
|
||||
const global = useGlobal()
|
||||
const settings = useSettings()
|
||||
const tabs = useTabs()
|
||||
const language = useLanguage()
|
||||
|
||||
const [state, setState, , ready] = persisted(Persist.global("navigation.pins"), PinsStateSchema, EMPTY_PINS)
|
||||
const [local, setLocal] = createStore<{ unread: Record<string, boolean> }>({ unread: {} })
|
||||
|
||||
const apply = (next: (current: PinsState) => PinsState) => {
|
||||
const current: PinsState = { items: state.items, collapsed: state.collapsed }
|
||||
const result = next(current)
|
||||
|
||||
if (result !== current) setState(result)
|
||||
}
|
||||
|
||||
const refOf = (tab: Tab | undefined): PinRef | undefined =>
|
||||
tab?.type === "session" ? { server: tab.server, sessionId: tab.sessionId } : undefined
|
||||
|
||||
const ctxOf = (ref: PinRef) => global.serverCtx(ServerConnection.Key.make(ref.server))
|
||||
|
||||
// The server context each pin's one load ran against, so a replaced context loads it again.
|
||||
const loads = new Map<string, ServerCtx>()
|
||||
|
||||
// Pins outside the loaded sessions load one at a time; a pin whose session is gone is dropped.
|
||||
createEffect(() => {
|
||||
if (!ready() || !settings.appearance.navigationPrototype()) return
|
||||
const missing = (ref: PinRef) => !!ctxOf(ref)?.data.session.missing(ref.sessionId)
|
||||
|
||||
apply((current) => prunePins(current, missing))
|
||||
state.items
|
||||
.flatMap((item) => (item.type === "session" ? [item] : item.sessions))
|
||||
.forEach((ref) => {
|
||||
const ctx = ctxOf(ref)
|
||||
const key = pinKey(ref)
|
||||
|
||||
if (!ctx || ctx.sdk.connection.status() !== "connected") return
|
||||
|
||||
if (ctx.data.session.get(ref.sessionId) || loads.get(key) === ctx) return
|
||||
loads.set(key, ctx)
|
||||
void ctx.data.session.sync(ref.sessionId).catch(() => {
|
||||
if (loads.get(key) === ctx) loads.delete(key)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const session = (ref: PinRef): SessionInfo | undefined => ctxOf(ref)?.data.session.get(ref.sessionId)
|
||||
|
||||
const current = createMemo(() => refOf(props.currentTab()))
|
||||
|
||||
const isCurrent = (ref: PinRef) => {
|
||||
const tab = current()
|
||||
|
||||
return !!tab && tab.server === ref.server && tab.sessionId === ref.sessionId
|
||||
}
|
||||
|
||||
// A closed group still shows the session you are in, so landing in it never hides where you are.
|
||||
const visible = (group: PinGroup) => (state.collapsed[group.id] ? group.sessions.filter(isCurrent) : group.sessions)
|
||||
|
||||
// What a closed group's hidden sessions need from you: an answer outranks unread work.
|
||||
const mark = (ref: PinRef) => {
|
||||
const ctx = ctxOf(ref)
|
||||
|
||||
if (!ctx) return
|
||||
const info = session(ref)
|
||||
|
||||
const value = sessionStatus(ctx, ref.sessionId, {
|
||||
root: true,
|
||||
autoApprove: settings.permissions.autoApproves(projectSettingsKey(ctx.sdk.scope, info?.projectID)),
|
||||
snapshot: info,
|
||||
})
|
||||
|
||||
if (value === "input") return "attention"
|
||||
|
||||
if (value === "unread" && !global.sessionPreferences.muted(ref.server, ref.sessionId)) return "unread"
|
||||
}
|
||||
|
||||
const hiddenMark = (group: PinGroup) => {
|
||||
if (!state.collapsed[group.id]) return
|
||||
const marks = group.sessions.filter((ref) => !isCurrent(ref)).map(mark)
|
||||
|
||||
if (marks.includes("attention")) return "attention"
|
||||
|
||||
if (marks.includes("unread")) return "unread"
|
||||
}
|
||||
|
||||
const keyOf = (ref: PinRef) =>
|
||||
tabKey({ type: "session", server: ServerConnection.Key.make(ref.server), sessionId: ref.sessionId })
|
||||
|
||||
const keys = createMemo(() =>
|
||||
state.items.flatMap((item) => (item.type === "session" ? [keyOf(item)] : visible(item).map(keyOf))),
|
||||
)
|
||||
|
||||
const open = (ref: PinRef) => {
|
||||
const ctx = ctxOf(ref)
|
||||
const info = session(ref)
|
||||
|
||||
void startTransition(() => {
|
||||
tabs.select(tabs.addSessionTab({ server: ServerConnection.Key.make(ref.server), sessionId: ref.sessionId }))
|
||||
|
||||
if (ctx && info) ctx.projects.touch(ctx.projects.forSession(info)?.worktree ?? info.location.directory)
|
||||
})
|
||||
}
|
||||
|
||||
const groupName = (number: number) => language.t("tabs.groups.unnamed", { number })
|
||||
|
||||
const groups = () => state.items.filter((item): item is PinGroup => item.type === "group")
|
||||
|
||||
return {
|
||||
ready,
|
||||
state,
|
||||
groups,
|
||||
refOf,
|
||||
session,
|
||||
isCurrent,
|
||||
visible,
|
||||
keyOf,
|
||||
keys,
|
||||
open,
|
||||
openKey: (key: string) => {
|
||||
const ref = state.items
|
||||
.flatMap((item) => (item.type === "session" ? [item] : item.sessions))
|
||||
.find((item) => keyOf(item) === key)
|
||||
|
||||
if (ref) open(ref)
|
||||
},
|
||||
currentKey: () => {
|
||||
const ref = current()
|
||||
|
||||
return ref && isPinned(state, ref) ? keyOf(ref) : undefined
|
||||
},
|
||||
/** Whether an open tab is shown in the pinned area instead of among the unpinned tabs. */
|
||||
holds: (tab: Tab) => {
|
||||
const ref = refOf(tab)
|
||||
|
||||
return !!ref && isPinned(state, ref)
|
||||
},
|
||||
pinned: (ref: PinRef) => isPinned(state, ref),
|
||||
groupOf: (ref: PinRef) => groupOf(state, ref),
|
||||
unread: (key: string) => !!local.unread[key],
|
||||
hiddenMark,
|
||||
setUnread: (key: string, value: boolean) => setLocal("unread", key, value),
|
||||
pin: (ref: PinRef) => apply((value) => pin(value, ref)),
|
||||
unpin: (ref: PinRef) => apply((value) => unpin(value, ref)),
|
||||
newGroup: (ref: PinRef) => {
|
||||
const existing = groups().map((group) => ({ id: group.id, name: group.name, color: group.color }))
|
||||
const taken = new Set(existing.map((group) => group.name))
|
||||
|
||||
const number = Array.from({ length: existing.length + 1 }, (_, index) => index + 1).find(
|
||||
(value) => !taken.has(groupName(value)),
|
||||
)
|
||||
|
||||
apply((value) =>
|
||||
createGroup(value, ref, {
|
||||
id: uuid(),
|
||||
name: groupName(number ?? existing.length + 1),
|
||||
color: nextManualGroupColor(existing),
|
||||
}),
|
||||
)
|
||||
},
|
||||
moveToGroup: (ref: PinRef, id: string) => apply((value) => moveToGroup(value, ref, id)),
|
||||
removeFromGroup: (ref: PinRef) => apply((value) => removeFromGroup(value, ref)),
|
||||
ungroup: (id: string) => apply((value) => ungroup(value, id)),
|
||||
unpinGroup: (id: string) => apply((value) => unpinGroup(value, id)),
|
||||
rename: (id: string, name: string) => apply((value) => updateGroup(value, id, { name })),
|
||||
recolor: (id: string, color: TabGroupColor) => apply((value) => updateGroup(value, id, { color })),
|
||||
toggle: (id: string) => apply((value) => toggleGroup(value, id)),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* Feeds the tab strip so pinned sessions share the ⌘1–9 numbers with the tabs after them. Side tabs render the pinned
|
||||
* area inside the strip's scroll; top tabs keep it outside, fixed while the tabs scroll (see `PinnedArea`).
|
||||
*/
|
||||
export function createPinnedLeading(orientation: Orientation): () => TabStripLeading | undefined {
|
||||
const pins = usePins()
|
||||
|
||||
const settings = useSettings()
|
||||
|
||||
// Built once here, so it only renders while the experiment is on.
|
||||
const content =
|
||||
orientation === "vertical" ? (
|
||||
<Show when={settings.appearance.navigationPrototype()}>
|
||||
<PinnedArea orientation="vertical" divider />
|
||||
</Show>
|
||||
) : undefined
|
||||
|
||||
return () =>
|
||||
pins.state.items.length === 0
|
||||
? undefined
|
||||
: {
|
||||
content,
|
||||
keys: pins.keys(),
|
||||
unread: pins.unread,
|
||||
navigate: pins.openKey,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pinned sessions and groups. Side layouts label it Pinned; side tabs (`divider`) end it with a divider before the
|
||||
* unpinned tabs, while List follows it with its own Recent section. Top tabs set it between two short dividers.
|
||||
*/
|
||||
export function PinnedArea(props: { orientation: Orientation; divider?: boolean }) {
|
||||
const pins = usePins()
|
||||
const tabs = useTabs()
|
||||
const language = useLanguage()
|
||||
|
||||
return (
|
||||
<div
|
||||
data-component="pinned-area"
|
||||
data-orientation={props.orientation}
|
||||
class="flex shrink-0"
|
||||
classList={{
|
||||
// The titlebar row drags the window; like the tab strip, the pinned area has to opt out to take clicks.
|
||||
"flex-row items-center gap-1 [app-region:no-drag]": props.orientation === "horizontal",
|
||||
"w-full flex-col gap-[3px]": props.orientation === "vertical",
|
||||
// In List, Recent's heading follows; leave room so the two sections read as separate.
|
||||
"pb-4": props.orientation === "vertical" && !props.divider,
|
||||
}}
|
||||
>
|
||||
<Show
|
||||
when={props.orientation === "vertical"}
|
||||
fallback={<div role="separator" aria-hidden="true" class="mx-1 h-4 w-px shrink-0 bg-v2-border-border-muted" />}
|
||||
>
|
||||
<SectionLabel label={language.t("sidebar.recent.pinned")} />
|
||||
</Show>
|
||||
<Key each={pins.state.items} by={(item) => (item.type === "session" ? pinKey(item) : `group:${item.id}`)}>
|
||||
{(item) => (
|
||||
<Switch>
|
||||
<Match when={sessionItem(item())}>
|
||||
{(ref) => <PinnedSession pin={ref()} orientation={props.orientation} />}
|
||||
</Match>
|
||||
<Match when={groupItem(item())}>
|
||||
{(group) => <PinnedGroupView group={group()} orientation={props.orientation} />}
|
||||
</Match>
|
||||
</Switch>
|
||||
)}
|
||||
</Key>
|
||||
<Show
|
||||
when={props.orientation === "horizontal"}
|
||||
fallback={
|
||||
<Show when={props.divider && tabs.store.some((tab) => !pins.holds(tab))}>
|
||||
<div role="separator" aria-hidden="true" class="mx-2 my-3 h-px shrink-0 bg-v2-border-border-muted" />
|
||||
</Show>
|
||||
}
|
||||
>
|
||||
<div role="separator" aria-hidden="true" class="mx-1 h-4 w-px shrink-0 bg-v2-border-border-muted" />
|
||||
</Show>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Renaming or recoloring a group replaces its object, so these unwrap the live item instead of keying on it, which
|
||||
// would remount the group and close its menu mid-edit.
|
||||
function sessionItem(item: PinsState["items"][number]) {
|
||||
return item.type === "session" ? item : undefined
|
||||
}
|
||||
|
||||
function groupItem(item: PinsState["items"][number]) {
|
||||
return item.type === "group" ? item : undefined
|
||||
}
|
||||
|
||||
function SectionLabel(props: { label: string; class?: string }) {
|
||||
return (
|
||||
<div
|
||||
class={`flex h-6 shrink-0 items-center px-2 text-[13px] leading-[var(--line-height-compact)] font-medium text-v2-text-text-muted ${props.class ?? ""}`}
|
||||
>
|
||||
<span class="min-w-0 truncate">{props.label}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function PinnedGroupView(props: { group: PinGroup; orientation: Orientation }) {
|
||||
const pins = usePins()
|
||||
const language = useLanguage()
|
||||
const [menu, setMenu] = createStore({ open: false })
|
||||
const open = () => !pins.state.collapsed[props.group.id]
|
||||
|
||||
const trigger = (
|
||||
<button
|
||||
type="button"
|
||||
data-slot="pinned-group-trigger"
|
||||
data-group-color={props.group.color}
|
||||
aria-expanded={open()}
|
||||
aria-label={props.group.name}
|
||||
class="flex shrink-0 items-center rounded-[6px] focus-visible:outline-none focus-visible:bg-v2-overlay-simple-overlay-hover"
|
||||
classList={{
|
||||
"size-7 justify-center hover:bg-v2-overlay-simple-overlay-hover": props.orientation === "horizontal",
|
||||
"h-7 w-full gap-2 ps-2 pe-8 text-start group-hover/row:bg-v2-overlay-simple-overlay-hover": props.orientation === "vertical",
|
||||
}}
|
||||
onClick={() => pins.toggle(props.group.id)}
|
||||
onContextMenu={(event) => {
|
||||
event.preventDefault()
|
||||
setMenu("open", true)
|
||||
}}
|
||||
>
|
||||
<span class="relative flex shrink-0">
|
||||
<GroupSquare color={props.group.color} />
|
||||
<Show when={pins.hiddenMark(props.group)}>
|
||||
{(value) => <span data-slot="pinned-group-mark" data-mark={value()} aria-hidden="true" />}
|
||||
</Show>
|
||||
</span>
|
||||
<Show when={props.orientation === "vertical"}>
|
||||
<span
|
||||
dir="auto"
|
||||
data-slot="pinned-group-label"
|
||||
class="min-w-0 truncate text-[13px] leading-[var(--line-height-compact)] font-medium"
|
||||
>
|
||||
{props.group.name}
|
||||
</span>
|
||||
<Icon
|
||||
name="fill-triangle-down"
|
||||
class="shrink-0 text-v2-icon-icon-muted transition-transform motion-reduce:transition-none"
|
||||
classList={{ "-rotate-90 rtl:rotate-90": !open() }}
|
||||
/>
|
||||
</Show>
|
||||
</button>
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
data-component="pinned-group"
|
||||
data-orientation={props.orientation}
|
||||
data-group-color={props.group.color}
|
||||
class="relative flex shrink-0"
|
||||
classList={{
|
||||
"flex-row items-center gap-1": props.orientation === "horizontal",
|
||||
"w-full flex-col gap-[3px]": props.orientation === "vertical",
|
||||
}}
|
||||
>
|
||||
<Menu
|
||||
modal={false}
|
||||
gutter={4}
|
||||
placement={props.orientation === "vertical" ? "bottom-end" : "bottom-start"}
|
||||
open={menu.open}
|
||||
onOpenChange={(value) => setMenu("open", value)}
|
||||
>
|
||||
{/* Side tabs open the menu from a ⋯ at the row's end too; right-click opens it in both layouts. */}
|
||||
<Show
|
||||
when={props.orientation === "horizontal"}
|
||||
fallback={
|
||||
<div data-slot="pinned-group-row" class="group/row relative flex w-full">
|
||||
{trigger}
|
||||
<Menu.Trigger
|
||||
as={IconButton}
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
icon={<Icon name="outline-dots" />}
|
||||
aria-label={language.t("navigation.group.options")}
|
||||
data-slot="pinned-group-options"
|
||||
class="absolute inset-y-0 end-1 my-auto opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100"
|
||||
classList={{ "!opacity-100": menu.open }}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Menu.Trigger as="span" aria-hidden="true" disabled class="pointer-events-none absolute size-px" />
|
||||
<Tooltip placement="bottom" value={props.group.name} class="flex shrink-0">
|
||||
{trigger}
|
||||
</Tooltip>
|
||||
</Show>
|
||||
<Menu.Portal>
|
||||
<Menu.Content class="w-48">
|
||||
<GroupEditor group={props.group} />
|
||||
<Menu.Separator />
|
||||
<Menu.Item onSelect={() => pins.ungroup(props.group.id)}>{language.t("tabs.groups.ungroup")}</Menu.Item>
|
||||
<Menu.Item onSelect={() => pins.unpinGroup(props.group.id)}>
|
||||
{language.t("navigation.group.unpin")}
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu>
|
||||
{/* Side tabs indent a group's sessions to its label, under a line from its square; top tabs keep them inline
|
||||
inside the group's border. */}
|
||||
<div
|
||||
data-slot="pinned-group-sessions"
|
||||
classList={{
|
||||
"relative flex flex-col gap-[3px] ps-6": props.orientation === "vertical",
|
||||
contents: props.orientation === "horizontal",
|
||||
}}
|
||||
>
|
||||
<For each={pins.visible(props.group)}>
|
||||
{(ref) => <PinnedSession pin={ref} orientation={props.orientation} grouped />}
|
||||
</For>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** The group's name, in the same bare field as the new session project search, then its color as a radio list. */
|
||||
function GroupEditor(props: { group: PinGroup }) {
|
||||
const pins = usePins()
|
||||
const language = useLanguage()
|
||||
|
||||
return (
|
||||
<>
|
||||
<div data-slot="pinned-group-name" onKeyDown={(event) => event.stopPropagation()}>
|
||||
<TextInput
|
||||
appearance="large"
|
||||
dir="auto"
|
||||
autocomplete="off"
|
||||
spellcheck={false}
|
||||
value={props.group.name}
|
||||
placeholder={language.t("tabs.groups.name.placeholder")}
|
||||
aria-label={language.t("tabs.groups.name.placeholder")}
|
||||
leadingIcon={<GroupSquare color={props.group.color} />}
|
||||
onFocusIn={(event) => event.stopPropagation()}
|
||||
onInput={(event) => pins.rename(props.group.id, event.currentTarget.value)}
|
||||
/>
|
||||
</div>
|
||||
<Menu.Separator />
|
||||
<Menu.RadioGroup
|
||||
value={props.group.color}
|
||||
onChange={(color) => {
|
||||
const next = AUTO_TAB_GROUP_COLORS.find((item) => item === color)
|
||||
|
||||
if (next) pins.recolor(props.group.id, next)
|
||||
}}
|
||||
aria-label={language.t("tabs.groups.color")}
|
||||
>
|
||||
<For each={AUTO_TAB_GROUP_COLORS}>
|
||||
{(color) => (
|
||||
<Menu.RadioItem value={color}>
|
||||
<GroupSquare color={color} />
|
||||
{language.t(`tabs.groups.color.${color}`)}
|
||||
</Menu.RadioItem>
|
||||
)}
|
||||
</For>
|
||||
</Menu.RadioGroup>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** A group's marker everywhere it shows: a small square of its color, styled like a project avatar. */
|
||||
export function GroupSquare(props: { color: TabGroupColor }) {
|
||||
return <span data-slot="pinned-group-rect" data-group-color={props.color} aria-hidden="true" />
|
||||
}
|
||||
|
||||
function PinnedSession(props: { pin: PinRef; orientation: Orientation; grouped?: boolean }) {
|
||||
const pins = usePins()
|
||||
const language = useLanguage()
|
||||
const server = () => ServerConnection.Key.make(props.pin.server)
|
||||
const key = () => pins.keyOf(props.pin)
|
||||
const session = () => pins.session(props.pin)
|
||||
const global = useGlobal()
|
||||
|
||||
const status = useSessionTabAvatarState(
|
||||
server,
|
||||
() => props.pin.sessionId,
|
||||
() => true,
|
||||
session,
|
||||
)
|
||||
|
||||
const muted = () => global.sessionPreferences.muted(props.pin.server, props.pin.sessionId)
|
||||
const unread = createMemo(() => status.unread() && !status.loading() && !muted())
|
||||
|
||||
createEffect(() => pins.setUnread(key(), unread()))
|
||||
|
||||
// A permission asked before this window connected only shows once loaded, as for an unselected tab.
|
||||
createEffect(() => {
|
||||
const ctx = global.serverCtx(server())
|
||||
|
||||
if (!ctx || pins.isCurrent(props.pin) || !status.loading() || ctx.sdk.connection.status() !== "connected") return
|
||||
syncInactiveSession(ctx, props.pin.sessionId)
|
||||
})
|
||||
|
||||
const shortcut = () => {
|
||||
const index = pins.keys().indexOf(key())
|
||||
|
||||
return index !== -1 && index < 9 ? index + 1 : undefined
|
||||
}
|
||||
|
||||
const menu = (rename: () => void): JSX.Element => (
|
||||
<>
|
||||
<PinMenuItems pin={props.pin} />
|
||||
<Menu.Separator />
|
||||
<Menu.Item onSelect={rename}>{language.t("common.rename")}</Menu.Item>
|
||||
</>
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
data-titlebar-tab-slot
|
||||
data-pinned-slot
|
||||
data-orientation={props.orientation}
|
||||
data-active={pins.isCurrent(props.pin)}
|
||||
class="relative flex shrink-0"
|
||||
classList={{ "w-7": props.orientation === "horizontal", "w-full": props.orientation === "vertical" }}
|
||||
>
|
||||
<TabNavItem
|
||||
href={tabHref({ type: "session", server: server(), sessionId: props.pin.sessionId })}
|
||||
server={server()}
|
||||
session={session()}
|
||||
preparing={false}
|
||||
muted={muted()}
|
||||
unread={unread()}
|
||||
attention={status.attention()}
|
||||
loading={status.loading()}
|
||||
shortcut={shortcut()}
|
||||
onNavigate={() => pins.open(props.pin)}
|
||||
active={pins.isCurrent(props.pin)}
|
||||
orientation={props.orientation}
|
||||
menu={menu}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Pin, unpin and group items, for pinned sessions and for an unpinned tab's menu. */
|
||||
export function PinMenuItems(props: { pin: PinRef }) {
|
||||
const pins = usePins()
|
||||
const language = useLanguage()
|
||||
const group = () => pins.groupOf(props.pin)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Menu.Item onSelect={() => (pins.pinned(props.pin) ? pins.unpin(props.pin) : pins.pin(props.pin))}>
|
||||
{language.t(pins.pinned(props.pin) ? "sidebar.recent.unpin" : "sidebar.recent.pin")}
|
||||
</Menu.Item>
|
||||
<Menu.Sub gutter={4} overflowPadding={16} overlap>
|
||||
<Menu.SubTrigger class="[&_[data-slot=menu-v2-item-chevron]]:text-v2-icon-icon-muted">
|
||||
<span>{language.t("tabs.groups.addToGroup")}</span>
|
||||
</Menu.SubTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.SubContent class="min-w-[164px]">
|
||||
<Menu.Item onSelect={() => pins.newGroup(props.pin)}>
|
||||
<Icon name="plus" />
|
||||
<span>{language.t("tabs.groups.new")}</span>
|
||||
</Menu.Item>
|
||||
<Show when={pins.groups().length > 0}>
|
||||
<Menu.Separator />
|
||||
</Show>
|
||||
<For each={pins.groups()}>
|
||||
{(item) => (
|
||||
<Menu.CheckboxItem
|
||||
closeOnSelect
|
||||
checked={group()?.id === item.id}
|
||||
onChange={(checked) =>
|
||||
checked ? pins.moveToGroup(props.pin, item.id) : pins.removeFromGroup(props.pin)
|
||||
}
|
||||
>
|
||||
<span data-group-color={item.color} class="inline-flex items-center">
|
||||
<span data-group-swatch class="size-2.5 shrink-0 rounded-full" />
|
||||
</span>
|
||||
<span class="min-w-0 truncate" dir="auto">
|
||||
{item.name}
|
||||
</span>
|
||||
</Menu.CheckboxItem>
|
||||
)}
|
||||
</For>
|
||||
<Show when={group()}>
|
||||
<Menu.Separator />
|
||||
<Menu.Item onSelect={() => pins.removeFromGroup(props.pin)}>
|
||||
<span>{language.t("tabs.groups.removeFromGroup")}</span>
|
||||
</Menu.Item>
|
||||
</Show>
|
||||
</Menu.SubContent>
|
||||
</Menu.Portal>
|
||||
</Menu.Sub>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import { Button } from "@opencode/ui/button"
|
||||
import { useDialog, useDialogLayer } from "@opencode/ui/context/dialog"
|
||||
import { Dialog, DialogFooter, DialogHeader, DialogTitleGroup } from "@opencode/ui/dialog"
|
||||
import { Loader } from "@opencode/ui/loader"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { displayName } from "@opencode/ui/project-avatar"
|
||||
import { Schema } from "effect"
|
||||
import { batch, createEffect, createMemo, onCleanup, Show, startTransition, untrack } from "solid-js"
|
||||
import { batch, createEffect, createMemo, onCleanup, Show, startTransition, untrack, type JSX } from "solid-js"
|
||||
import { createStore, produce, reconcile } from "solid-js/store"
|
||||
import { arrayMove } from "@/runtime/array-move"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
@@ -22,7 +24,9 @@ import { ServerConnection, useServers } from "@/runtime/server/registry"
|
||||
import { useGlobal, type ServerCtx } from "@/runtime/server/runtime"
|
||||
import { sessionTreeIDs } from "@/session/requests/session-request-tree"
|
||||
import { errorMessage } from "@/shell/layout/helpers"
|
||||
import { useSessionTabAvatarState } from "@/shell/layout/project-avatar-state"
|
||||
import { sessionStatus, useSessionTabAvatarState } from "@/shell/layout/project-avatar-state"
|
||||
import { projectSettingsKey, useSettings } from "@/settings/model"
|
||||
import { pathKey } from "@/workspaces/path-key"
|
||||
import { showToast } from "@/shell/notifications/toast"
|
||||
import { setSidebarUnread } from "@/shell/sidebar-peek"
|
||||
import { useLayout } from "@/shell/state/layout"
|
||||
@@ -54,6 +58,19 @@ import {
|
||||
type RecentPageState,
|
||||
type RecentSession,
|
||||
} from "./recent-sessions-model"
|
||||
import {
|
||||
DEFAULT_RECENT_VIEW,
|
||||
NO_PROJECT,
|
||||
RECENT_DATES,
|
||||
RECENT_STATUSES,
|
||||
RecentViewState,
|
||||
recentGroups,
|
||||
type RecentGroup,
|
||||
type RecentStatus,
|
||||
type RecentView,
|
||||
type RecentViewRow,
|
||||
} from "./recent-view"
|
||||
import { RecentViewMenu } from "./recent-view-menu"
|
||||
import { notifySessionTabsRemoved } from "./session-events"
|
||||
import { TabNavItem } from "./tab-nav"
|
||||
import { createSessionRowNavigation, syncInactiveSession } from "./tab-strip"
|
||||
@@ -70,7 +87,22 @@ type Connection = { conn: ServerConnection.Any; ctx: ServerCtx; server: ServerCo
|
||||
* The experimental Recent sessions sidebar: pinned sessions first, then every server's root sessions from the last
|
||||
* 7 days in one recency list, at most 30 until Show more reveals older ones. The desktop titlebar renders it in place of the side tabs only while the setting is on and available.
|
||||
*/
|
||||
export function RecentSessions() {
|
||||
export function RecentSessions(
|
||||
input: {
|
||||
/** The navigation prototype's pins and groups replace this list's own pins; their sessions leave the recent rows. */
|
||||
pinned?: {
|
||||
content: () => JSX.Element
|
||||
keys: () => string[]
|
||||
current: () => string | undefined
|
||||
unread: (key: string) => boolean
|
||||
navigate: (key: string) => void
|
||||
holds: (server: string, sessionID: string) => boolean
|
||||
toggle: (server: string, sessionID: string) => void
|
||||
}
|
||||
/** The navigation prototype's Group and sort menu on Recent's headings; View all opens the Sessions page. */
|
||||
organize?: { viewAll: () => void }
|
||||
} = {},
|
||||
) {
|
||||
const global = useGlobal()
|
||||
const servers = useServers()
|
||||
const language = useLanguage()
|
||||
@@ -79,8 +111,18 @@ export function RecentSessions() {
|
||||
const dialog = useDialog()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const settings = useSettings()
|
||||
|
||||
const [state, setState, , ready] = persisted(Persist.global("sidebar.recent"), RecentSidebarState, { pins: [] })
|
||||
|
||||
const [arrangementState, setArrangement] = persisted(
|
||||
Persist.global("navigation.recent-view"),
|
||||
RecentViewState,
|
||||
DEFAULT_RECENT_VIEW,
|
||||
)
|
||||
|
||||
const arrangement = (): RecentView => (input.organize ? arrangementState : DEFAULT_RECENT_VIEW)
|
||||
|
||||
const [pages, setPages] = createStore<Record<string, RecentPageState>>({})
|
||||
|
||||
const [hydration, setHydration] = createStore<Record<string, SessionInfo>>({})
|
||||
@@ -524,7 +566,7 @@ export function RecentSessions() {
|
||||
const partition = createMemo(() =>
|
||||
partitionRecentSessions({
|
||||
items: items(),
|
||||
pins: state.pins,
|
||||
pins: input.pinned ? [] : state.pins,
|
||||
endpoints: endpoints(),
|
||||
open: openSessions(),
|
||||
resolvePin: (key) => hydratedItems().get(key),
|
||||
@@ -535,16 +577,150 @@ export function RecentSessions() {
|
||||
|
||||
const pinned = () => partition().pinned
|
||||
|
||||
const recentSource = createMemo(() =>
|
||||
input.pinned
|
||||
? partition().recent.filter((item) => !input.pinned?.holds(item.server, item.session.id))
|
||||
: partition().recent,
|
||||
)
|
||||
|
||||
const windowed = createMemo(() =>
|
||||
windowRecentSessions({
|
||||
items: partition().recent,
|
||||
items: recentSource(),
|
||||
now: view.now,
|
||||
revealed: view.revealed,
|
||||
serversHaveMore: connections().some((item) => recentPageHasMore(pages[item.server])),
|
||||
}),
|
||||
)
|
||||
|
||||
const recent = () => windowed().visible
|
||||
// The same status the row's avatar shows; muted sessions never count as unread.
|
||||
const statusOf = (item: RecentSession): RecentStatus => {
|
||||
const ctx = ctxOf(item)
|
||||
|
||||
if (!ctx) return "read"
|
||||
const project = projectSettingsKey(ctx.sdk.scope, item.session.projectID)
|
||||
|
||||
const value = sessionStatus(ctx, item.session.id, {
|
||||
root: true,
|
||||
autoApprove: settings.permissions.autoApproves(project),
|
||||
snapshot: item.session,
|
||||
})
|
||||
|
||||
if (value === "input") return "attention"
|
||||
|
||||
if (value === "running") return "working"
|
||||
|
||||
if (value === "unread" && !global.sessionPreferences.muted(item.server, item.session.id)) return "unread"
|
||||
|
||||
return "read"
|
||||
}
|
||||
|
||||
// Status grouping is the old Inbox: whatever needs you or is running shows even when it is older than the window.
|
||||
const candidates = createMemo(() => {
|
||||
const visible = windowed().visible
|
||||
|
||||
if (arrangement().groupBy !== "status") return visible
|
||||
const shown = new Set(visible.map((item) => item.key))
|
||||
|
||||
return [
|
||||
...visible,
|
||||
...recentSource().filter((item) => {
|
||||
if (shown.has(item.key)) return false
|
||||
const status = statusOf(item)
|
||||
|
||||
return status === "attention" || status === "working"
|
||||
}),
|
||||
]
|
||||
})
|
||||
|
||||
const groups = createMemo(() =>
|
||||
recentGroups(
|
||||
candidates().map((item): RecentViewRow & { item: RecentSession } => {
|
||||
const project = ctxOf(item)?.projects.forSession(item.session)
|
||||
|
||||
return {
|
||||
key: item.key,
|
||||
item,
|
||||
title: sessionTabTitle(item.session.title, language.t("command.session.new")) ?? "",
|
||||
updated: item.session.time.updated ?? item.session.time.created,
|
||||
created: item.session.time.created,
|
||||
status: statusOf(item),
|
||||
project: project
|
||||
? { key: `${item.server}\u0000${pathKey(project.worktree)}`, label: displayName(project) }
|
||||
: undefined,
|
||||
server: item.server,
|
||||
}
|
||||
}),
|
||||
arrangement(),
|
||||
{
|
||||
now: view.now,
|
||||
servers: connections().map((entry) => ({ key: entry.server, label: servers.label(entry.conn) })),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
const collapsed = (group: RecentGroup<RecentViewRow>) =>
|
||||
arrangement().groupBy !== "none" && arrangement().collapsed.includes(group.key)
|
||||
|
||||
// A collapsed group still shows the session you're on, as a collapsed pinned group does.
|
||||
const shownRows = (group: RecentGroup<RecentViewRow & { item: RecentSession }>) =>
|
||||
group.rows.flatMap((entry) => (!collapsed(group) || selected(entry.item) ? [entry.item] : []))
|
||||
|
||||
// A collapsed group marks what its hidden rows need from you: an answer outranks unread work.
|
||||
const hiddenMark = (group: RecentGroup<RecentViewRow & { item: RecentSession }>) => {
|
||||
if (!collapsed(group)) return
|
||||
const statuses = group.rows.filter((entry) => !selected(entry.item)).map((entry) => entry.status)
|
||||
|
||||
if (statuses.includes("attention")) return "attention"
|
||||
|
||||
if (statuses.includes("unread")) return "unread"
|
||||
}
|
||||
|
||||
const toggleGroup = (key: string) =>
|
||||
setArrangement("collapsed", (current) =>
|
||||
current.includes(key) ? current.filter((entry) => entry !== key) : [...current, key],
|
||||
)
|
||||
|
||||
const groupLabel = (group: RecentGroup<RecentViewRow>) => {
|
||||
const by = arrangement().groupBy
|
||||
const date = RECENT_DATES.find((value) => value === group.id)
|
||||
const status = RECENT_STATUSES.find((value) => value === group.id)
|
||||
|
||||
if (by === "none") return language.t("sidebar.recent.section.recent")
|
||||
|
||||
if (by === "date" && date) return language.t(`sidebar.recent.group.date.${date}`)
|
||||
|
||||
if (by === "status" && status) return language.t(`sidebar.recent.group.status.${status}`)
|
||||
|
||||
if (by === "project" && group.id === NO_PROJECT) return language.t("sidebar.recent.group.project.none")
|
||||
|
||||
return group.label ?? group.id
|
||||
}
|
||||
|
||||
const meta = (item: RecentSession) => {
|
||||
if (!arrangement().metadata) return
|
||||
const status = statusOf(item)
|
||||
|
||||
if (status === "attention") return language.t("sidebar.recent.meta.attention")
|
||||
|
||||
if (status === "working") return language.t("sidebar.recent.meta.working")
|
||||
|
||||
const time =
|
||||
arrangement().sortBy === "created"
|
||||
? item.session.time.created
|
||||
: (item.session.time.updated ?? item.session.time.created)
|
||||
|
||||
const seconds = Math.max(0, Math.floor((view.now - time) / 1000))
|
||||
|
||||
if (seconds < 60) return language.t("sidebar.inbox.time.now")
|
||||
|
||||
if (seconds < 3600) return language.plural("sidebar.inbox.elapsed.minutes", Math.floor(seconds / 60))
|
||||
|
||||
if (seconds < 86_400) return language.plural("sidebar.inbox.elapsed.hours", Math.floor(seconds / 3600))
|
||||
|
||||
return language.plural("sidebar.inbox.elapsed.days", Math.floor(seconds / 86_400))
|
||||
}
|
||||
|
||||
const recent = () => (input.organize ? groups().flatMap(shownRows) : windowed().visible)
|
||||
const rows = createMemo(() => [...pinned(), ...recent()])
|
||||
|
||||
const firstPageLoading = createMemo(() => {
|
||||
@@ -689,11 +865,15 @@ export function RecentSessions() {
|
||||
// Rows take the side tabs' shortcuts, numbered and stepped through in the order shown.
|
||||
const rowRefs = new Map<string, HTMLDivElement>()
|
||||
|
||||
// The prototype's pinned rows are numbered first, so ⌘1–9 continue from them into these rows.
|
||||
const pinnedKeys = () => input.pinned?.keys() ?? []
|
||||
|
||||
const hints = createSessionRowNavigation({
|
||||
keys: () => rows().map((item) => item.key),
|
||||
current: () => rows().find(selected)?.key,
|
||||
unread: (key) => !!unread[key],
|
||||
keys: () => [...pinnedKeys(), ...rows().map((item) => item.key)],
|
||||
current: () => rows().find(selected)?.key ?? input.pinned?.current(),
|
||||
unread: (key) => (pinnedKeys().includes(key) ? !!input.pinned?.unread(key) : !!unread[key]),
|
||||
navigate: (key, reveal) => {
|
||||
if (pinnedKeys().includes(key)) return input.pinned?.navigate(key)
|
||||
const item = rows().find((entry) => entry.key === key)
|
||||
|
||||
if (!item) return
|
||||
@@ -792,14 +972,23 @@ export function RecentSessions() {
|
||||
const props = {
|
||||
item,
|
||||
selected: () => selected(item()),
|
||||
shortcut: () => (position() >= 0 && position() < 9 ? position() + 1 : undefined),
|
||||
shortcut: () => {
|
||||
const index = position() + pinnedKeys().length
|
||||
|
||||
return position() >= 0 && index < 9 ? index + 1 : undefined
|
||||
},
|
||||
ref: (element: HTMLDivElement) => rowRefs.set(key, element),
|
||||
onUnreadChange: (value: boolean) => setUnread(item().key, value),
|
||||
meta: () => meta(item()),
|
||||
hideAvatar: () => arrangement().groupBy === "project",
|
||||
pinned: index !== undefined,
|
||||
canMoveUp: () => index !== undefined && index() > 0,
|
||||
canMoveDown: () => index !== undefined && index() < pinned().length - 1,
|
||||
onOpen: () => open(item()),
|
||||
onPin: () => setState("pins", (current) => addPin(current, item().key)),
|
||||
onPin: () =>
|
||||
input.pinned
|
||||
? input.pinned.toggle(item().server, item().session.id)
|
||||
: setState("pins", (current) => addPin(current, item().key)),
|
||||
onUnpin: () => removePinKey(item().key),
|
||||
onMoveUp: () => movePin(item().key, -1),
|
||||
onMoveDown: () => movePin(item().key, 1),
|
||||
@@ -834,7 +1023,8 @@ export function RecentSessions() {
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Show when={pinned().length > 0}>
|
||||
{input.pinned?.content()}
|
||||
<Show when={!input.pinned && pinned().length > 0}>
|
||||
<div role="group" aria-labelledby="sidebar-recent-pinned" class="flex shrink-0 flex-col gap-2 pb-2.5">
|
||||
<SectionHeader id="sidebar-recent-pinned" label={language.t("sidebar.recent.pinned")} />
|
||||
<DragDropProvider
|
||||
@@ -865,7 +1055,56 @@ export function RecentSessions() {
|
||||
</DragDropProvider>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={recent().length > 0 || windowed().hasMore}>
|
||||
<Show
|
||||
when={
|
||||
input.organize &&
|
||||
(groups().some((group) => group.rows.length > 0 || arrangement().emptyGroups) || windowed().hasMore)
|
||||
}
|
||||
>
|
||||
<div data-slot="sidebar-recent-groups" class="flex shrink-0 flex-col gap-2.5 pb-2.5">
|
||||
<Key each={groups()} by={(group) => group.key}>
|
||||
{(group) => (
|
||||
<div
|
||||
role="group"
|
||||
aria-labelledby={`sidebar-recent-${group().key}`}
|
||||
class="flex shrink-0 flex-col gap-2"
|
||||
>
|
||||
<GroupHeader
|
||||
id={`sidebar-recent-${group().key}`}
|
||||
label={groupLabel(group())}
|
||||
count={
|
||||
arrangement().metadata && arrangement().groupBy !== "none" ? group().rows.length : undefined
|
||||
}
|
||||
collapsible={arrangement().groupBy !== "none"}
|
||||
collapsed={collapsed(group())}
|
||||
mark={hiddenMark(group())}
|
||||
onToggle={() => toggleGroup(group().key)}
|
||||
menu={
|
||||
<RecentViewMenu
|
||||
view={arrangement()}
|
||||
onChange={(next) => setArrangement((current) => ({ ...current, ...next }))}
|
||||
onViewAll={() => input.organize?.viewAll()}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Show when={shownRows(group()).length > 0}>
|
||||
<div data-titlebar-tab-list data-orientation="vertical" class="flex w-full min-w-0 flex-col">
|
||||
<Key each={shownRows(group())} by={(item) => item.key}>
|
||||
{(item) => row(item)}
|
||||
</Key>
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
)}
|
||||
</Key>
|
||||
<Show when={windowed().hasMore && !loadingMore()}>
|
||||
<Button variant="ghost-muted" size="normal" class="w-full justify-start px-2" onClick={showMore}>
|
||||
{language.t("sidebar.inbox.showMore")}
|
||||
</Button>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={!input.organize && (recent().length > 0 || windowed().hasMore)}>
|
||||
<div role="group" aria-labelledby="sidebar-recent-list" class="flex shrink-0 flex-col gap-2 pb-2.5">
|
||||
<SectionHeader id="sidebar-recent-list" label={language.t("sidebar.recent.section.recent")} />
|
||||
<div data-titlebar-tab-list data-orientation="vertical" class="flex w-full min-w-0 flex-col">
|
||||
@@ -903,6 +1142,67 @@ export function RecentSessions() {
|
||||
)
|
||||
}
|
||||
|
||||
/** A Recent heading. Grouped headings collapse their group; the Group and sort menu shows on hover. */
|
||||
function GroupHeader(props: {
|
||||
id: string
|
||||
label: string
|
||||
count: number | undefined
|
||||
collapsible: boolean
|
||||
collapsed: boolean
|
||||
mark: "attention" | "unread" | undefined
|
||||
onToggle: () => void
|
||||
menu: JSX.Element
|
||||
}) {
|
||||
return (
|
||||
<div class="group/header relative flex h-6 shrink-0 items-center">
|
||||
<Show
|
||||
when={props.collapsible}
|
||||
fallback={
|
||||
<div
|
||||
id={props.id}
|
||||
class="flex h-6 min-w-0 flex-1 items-center px-2 text-[13px] leading-4 font-medium text-v2-text-text-muted"
|
||||
>
|
||||
<span class="min-w-0 truncate">{props.label}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
id={props.id}
|
||||
aria-expanded={!props.collapsed}
|
||||
class="flex h-6 min-w-0 flex-1 items-center gap-1 rounded-[6px] ps-2 pe-8 text-start text-[13px] leading-4 font-medium text-v2-text-text-muted hover:text-v2-text-text-base focus-visible:bg-v2-overlay-simple-overlay-hover focus-visible:outline-none"
|
||||
onClick={props.onToggle}
|
||||
>
|
||||
<span class="min-w-0 truncate">{props.label}</span>
|
||||
<Show when={props.count !== undefined}>
|
||||
<span class="shrink-0 font-normal text-v2-text-text-faint tabular-nums">{props.count}</span>
|
||||
</Show>
|
||||
<Show when={props.mark}>
|
||||
{(value) => (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="size-1.5 shrink-0 rounded-full"
|
||||
classList={{
|
||||
"bg-v2-background-bg-accent": value() === "unread",
|
||||
"bg-v2-state-fg-warning": value() === "attention",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
<Icon
|
||||
name="fill-triangle-down"
|
||||
class="shrink-0 text-v2-icon-icon-muted transition-transform motion-reduce:transition-none"
|
||||
classList={{ "-rotate-90 rtl:rotate-90": props.collapsed }}
|
||||
/>
|
||||
</button>
|
||||
</Show>
|
||||
<div class="absolute inset-y-0 end-1 my-auto flex h-5 items-center opacity-0 group-hover/header:opacity-100 focus-within:opacity-100 [&:has([data-expanded])]:opacity-100">
|
||||
{props.menu}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SectionHeader(props: { id: string; label: string }) {
|
||||
return (
|
||||
<div
|
||||
@@ -920,6 +1220,8 @@ type RecentSessionTabProps = {
|
||||
shortcut: () => number | undefined
|
||||
ref: (element: HTMLDivElement) => void
|
||||
onUnreadChange: (unread: boolean) => void
|
||||
meta: () => string | undefined
|
||||
hideAvatar: () => boolean
|
||||
pinned: boolean
|
||||
canMoveUp: () => boolean
|
||||
canMoveDown: () => boolean
|
||||
@@ -1030,7 +1332,8 @@ function RecentSessionTab(props: RecentSessionTabProps & { dragging?: boolean })
|
||||
server={server()}
|
||||
session={item().session}
|
||||
preparing={false}
|
||||
label={muted() ? language.t("sidebar.recent.muted") : undefined}
|
||||
label={muted() ? language.t("sidebar.recent.muted") : props.meta()}
|
||||
hideAvatar={props.hideAvatar()}
|
||||
unread={unread()}
|
||||
attention={status.attention()}
|
||||
loading={status.loading()}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { For, type JSX } from "solid-js"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import {
|
||||
DEFAULT_RECENT_VIEW,
|
||||
RECENT_DIRECTIONS,
|
||||
RECENT_GROUP_BYS,
|
||||
RECENT_SORT_BYS,
|
||||
type RecentView,
|
||||
} from "./recent-view"
|
||||
|
||||
/** Recent's Group and sort menu, opened from the icon on its headings. */
|
||||
export function RecentViewMenu(props: {
|
||||
view: RecentView
|
||||
onChange: (next: Partial<RecentView>) => void
|
||||
onViewAll: () => void
|
||||
}): JSX.Element {
|
||||
const language = useLanguage()
|
||||
|
||||
const isDefault = () =>
|
||||
props.view.groupBy === DEFAULT_RECENT_VIEW.groupBy &&
|
||||
props.view.sortBy === DEFAULT_RECENT_VIEW.sortBy &&
|
||||
props.view.direction === DEFAULT_RECENT_VIEW.direction &&
|
||||
props.view.metadata === DEFAULT_RECENT_VIEW.metadata &&
|
||||
props.view.emptyGroups === DEFAULT_RECENT_VIEW.emptyGroups &&
|
||||
props.view.collapsed.length === 0
|
||||
|
||||
return (
|
||||
<Menu gutter={4} modal={false} placement="bottom-end">
|
||||
<Menu.Trigger
|
||||
as={IconButton}
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
data-slot="recent-view-trigger"
|
||||
aria-label={language.t("sidebar.recent.view.options")}
|
||||
icon={<Icon name="sliders" />}
|
||||
/>
|
||||
<Menu.Portal>
|
||||
<Menu.Content class="min-w-[200px]">
|
||||
<Menu.Sub gutter={4} overflowPadding={16} overlap>
|
||||
<SubTrigger label={language.t("sidebar.recent.view.groupBy")}>
|
||||
{language.t(`sidebar.recent.view.groupBy.${props.view.groupBy}`)}
|
||||
</SubTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.SubContent class="w-max min-w-[160px]">
|
||||
<Menu.RadioGroup
|
||||
value={props.view.groupBy}
|
||||
onChange={(value) => {
|
||||
const next = value === "none" ? value : RECENT_GROUP_BYS.find((item) => item === value)
|
||||
|
||||
if (next) props.onChange({ groupBy: next })
|
||||
}}
|
||||
>
|
||||
<For each={RECENT_GROUP_BYS}>
|
||||
{(value) => (
|
||||
<Menu.RadioItem value={value}>
|
||||
{language.t(`sidebar.recent.view.groupBy.${value}`)}
|
||||
</Menu.RadioItem>
|
||||
)}
|
||||
</For>
|
||||
<Menu.Separator />
|
||||
<Menu.RadioItem value="none">{language.t("sidebar.recent.view.groupBy.none")}</Menu.RadioItem>
|
||||
</Menu.RadioGroup>
|
||||
</Menu.SubContent>
|
||||
</Menu.Portal>
|
||||
</Menu.Sub>
|
||||
<Menu.Sub gutter={4} overflowPadding={16} overlap>
|
||||
<SubTrigger label={language.t("sidebar.recent.view.sortBy")}>
|
||||
{language.t(`sidebar.recent.view.sortBy.${props.view.sortBy}`)}
|
||||
</SubTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.SubContent class="w-max min-w-[160px]">
|
||||
<Menu.RadioGroup
|
||||
value={props.view.sortBy}
|
||||
onChange={(value) => {
|
||||
const next = RECENT_SORT_BYS.find((item) => item === value)
|
||||
|
||||
if (next) props.onChange({ sortBy: next })
|
||||
}}
|
||||
>
|
||||
<For each={RECENT_SORT_BYS}>
|
||||
{(value) => (
|
||||
<Menu.RadioItem value={value}>{language.t(`sidebar.recent.view.sortBy.${value}`)}</Menu.RadioItem>
|
||||
)}
|
||||
</For>
|
||||
</Menu.RadioGroup>
|
||||
<Menu.Separator />
|
||||
<Menu.RadioGroup
|
||||
value={props.view.direction}
|
||||
onChange={(value) => {
|
||||
const next = RECENT_DIRECTIONS.find((item) => item === value)
|
||||
|
||||
if (next) props.onChange({ direction: next })
|
||||
}}
|
||||
>
|
||||
<For each={RECENT_DIRECTIONS}>
|
||||
{(value) => (
|
||||
<Menu.RadioItem value={value}>
|
||||
{language.t(`sidebar.recent.view.direction.${value}`)}
|
||||
</Menu.RadioItem>
|
||||
)}
|
||||
</For>
|
||||
</Menu.RadioGroup>
|
||||
</Menu.SubContent>
|
||||
</Menu.Portal>
|
||||
</Menu.Sub>
|
||||
<Menu.Sub gutter={4} overflowPadding={16} overlap>
|
||||
<SubTrigger label={language.t("sidebar.recent.view.show")} />
|
||||
<Menu.Portal>
|
||||
<Menu.SubContent class="w-max min-w-[160px]">
|
||||
<Menu.CheckboxItem
|
||||
checked={props.view.metadata}
|
||||
onChange={(value) => props.onChange({ metadata: value })}
|
||||
>
|
||||
{language.t("sidebar.recent.view.show.metadata")}
|
||||
</Menu.CheckboxItem>
|
||||
<Menu.CheckboxItem
|
||||
checked={props.view.emptyGroups}
|
||||
onChange={(value) => props.onChange({ emptyGroups: value })}
|
||||
>
|
||||
{language.t("sidebar.recent.view.show.emptyGroups")}
|
||||
</Menu.CheckboxItem>
|
||||
</Menu.SubContent>
|
||||
</Menu.Portal>
|
||||
</Menu.Sub>
|
||||
<Menu.Separator />
|
||||
<Menu.Item disabled={isDefault()} onSelect={() => props.onChange(DEFAULT_RECENT_VIEW)}>
|
||||
{language.t("sidebar.recent.view.reset")}
|
||||
</Menu.Item>
|
||||
<Menu.Item onSelect={props.onViewAll}>{language.t("sidebar.recent.view.viewAll")}</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
function SubTrigger(props: { label: string; children?: JSX.Element }) {
|
||||
return (
|
||||
<Menu.SubTrigger class="[&_[data-slot=menu-v2-item-chevron]]:text-v2-icon-icon-muted">
|
||||
<span class="min-w-0 truncate">{props.label}</span>
|
||||
<span class="ms-auto shrink-0 ps-4 text-v2-text-text-faint">{props.children}</span>
|
||||
</Menu.SubTrigger>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { DEFAULT_RECENT_VIEW, recentGroups, type RecentView, type RecentViewRow } from "./recent-view"
|
||||
|
||||
const now = new Date(2026, 10, 18, 15).getTime()
|
||||
|
||||
const day = 24 * 60 * 60 * 1000
|
||||
|
||||
function row(key: string, input: Partial<RecentViewRow> = {}): RecentViewRow {
|
||||
return {
|
||||
key,
|
||||
title: key,
|
||||
updated: now,
|
||||
created: now,
|
||||
status: "read",
|
||||
project: undefined,
|
||||
server: "local",
|
||||
...input,
|
||||
}
|
||||
}
|
||||
|
||||
const context = {
|
||||
now,
|
||||
servers: [
|
||||
{ key: "local", label: "This computer" },
|
||||
{ key: "remote", label: "Remote" },
|
||||
],
|
||||
}
|
||||
|
||||
const view = (input: Partial<RecentView>) => ({ ...DEFAULT_RECENT_VIEW, ...input })
|
||||
|
||||
const membership = (groups: ReturnType<typeof recentGroups>) =>
|
||||
groups.map((group) => [group.id, group.rows.map((item) => item.key)])
|
||||
|
||||
describe("recentGroups", () => {
|
||||
test("none lists every row in one group, newest first", () => {
|
||||
const groups = recentGroups(
|
||||
[row("a", { updated: now - 2 }), row("b", { updated: now - 1 })],
|
||||
DEFAULT_RECENT_VIEW,
|
||||
context,
|
||||
)
|
||||
|
||||
expect(membership(groups)).toEqual([["all", ["b", "a"]]])
|
||||
})
|
||||
|
||||
test("sorts by name and creation in either direction", () => {
|
||||
const rows = [row("b", { created: now - 1 }), row("a", { created: now - 2 }), row("c", { created: now - 3 })]
|
||||
|
||||
expect(membership(recentGroups(rows, view({ sortBy: "name", direction: "asc" }), context))).toEqual([
|
||||
["all", ["a", "b", "c"]],
|
||||
])
|
||||
expect(membership(recentGroups(rows, view({ sortBy: "created" }), context))).toEqual([["all", ["b", "a", "c"]]])
|
||||
})
|
||||
|
||||
test("date groups follow the sort direction and hide empty ones unless asked", () => {
|
||||
const rows = [row("old", { updated: now - 40 * day }), row("today"), row("yesterday", { updated: now - day })]
|
||||
|
||||
expect(membership(recentGroups(rows, view({ groupBy: "date" }), context))).toEqual([
|
||||
["today", ["today"]],
|
||||
["yesterday", ["yesterday"]],
|
||||
["older", ["old"]],
|
||||
])
|
||||
expect(
|
||||
recentGroups(rows, view({ groupBy: "date", direction: "asc", emptyGroups: true }), context).map((g) => g.id),
|
||||
).toEqual(["older", "week", "yesterday", "today"])
|
||||
})
|
||||
|
||||
test("status groups keep their fixed order whatever the sort", () => {
|
||||
const rows = [row("read"), row("working", { status: "working" }), row("attention", { status: "attention" })]
|
||||
|
||||
expect(membership(recentGroups(rows, view({ groupBy: "status", direction: "asc" }), context))).toEqual([
|
||||
["attention", ["attention"]],
|
||||
["working", ["working"]],
|
||||
["read", ["read"]],
|
||||
])
|
||||
})
|
||||
|
||||
test("project groups go A to Z with sessions outside a project last", () => {
|
||||
const rows = [
|
||||
row("loose"),
|
||||
row("z", { project: { key: "local:/z", label: "zeta" } }),
|
||||
row("a", { project: { key: "local:/a", label: "alpha" } }),
|
||||
]
|
||||
|
||||
expect(membership(recentGroups(rows, view({ groupBy: "project", emptyGroups: true }), context))).toEqual([
|
||||
["local:/a", ["a"]],
|
||||
["local:/z", ["z"]],
|
||||
["none", ["loose"]],
|
||||
])
|
||||
})
|
||||
|
||||
test("server groups follow the server order and can show empty servers", () => {
|
||||
const rows = [row("r", { server: "remote" })]
|
||||
|
||||
expect(membership(recentGroups(rows, view({ groupBy: "server", emptyGroups: true }), context))).toEqual([
|
||||
["local", []],
|
||||
["remote", ["r"]],
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,183 @@
|
||||
import { Schema } from "effect"
|
||||
import { Persistence } from "@/runtime/persistence/schema"
|
||||
|
||||
export const RECENT_GROUP_BYS = ["date", "status", "project", "server"] as const
|
||||
|
||||
export const RECENT_SORT_BYS = ["updated", "created", "name"] as const
|
||||
|
||||
export const RECENT_DIRECTIONS = ["desc", "asc"] as const
|
||||
|
||||
/** The order Status lists its groups in: what needs you first, then what's running, then what you haven't read. */
|
||||
export const RECENT_STATUSES = ["attention", "working", "unread", "read"] as const
|
||||
|
||||
export const RECENT_DATES = ["today", "yesterday", "week", "older"] as const
|
||||
|
||||
export type RecentGroupBy = (typeof RECENT_GROUP_BYS)[number] | "none"
|
||||
|
||||
export type RecentSortBy = (typeof RECENT_SORT_BYS)[number]
|
||||
|
||||
export type RecentDirection = (typeof RECENT_DIRECTIONS)[number]
|
||||
|
||||
export type RecentStatus = (typeof RECENT_STATUSES)[number]
|
||||
|
||||
export type RecentDate = (typeof RECENT_DATES)[number]
|
||||
|
||||
export const RecentViewState = Persistence.struct({
|
||||
groupBy: Schema.Literals(["none", ...RECENT_GROUP_BYS]),
|
||||
sortBy: Schema.Literals(RECENT_SORT_BYS),
|
||||
direction: Schema.Literals(RECENT_DIRECTIONS),
|
||||
metadata: Schema.Boolean,
|
||||
emptyGroups: Schema.Boolean,
|
||||
/** Collapsed group IDs, as `${groupBy}:${group id}`, so each grouping remembers its own. */
|
||||
collapsed: Persistence.array(Schema.String),
|
||||
})
|
||||
|
||||
export type RecentView = (typeof RecentViewState)["Type"]
|
||||
|
||||
export const DEFAULT_RECENT_VIEW: RecentView = {
|
||||
groupBy: "none",
|
||||
sortBy: "updated",
|
||||
direction: "desc",
|
||||
metadata: false,
|
||||
emptyGroups: false,
|
||||
collapsed: [],
|
||||
}
|
||||
|
||||
export type RecentViewRow = {
|
||||
key: string
|
||||
title: string
|
||||
updated: number
|
||||
created: number
|
||||
status: RecentStatus
|
||||
/** `undefined` for a session outside any known project. */
|
||||
project: { key: string; label: string } | undefined
|
||||
server: string
|
||||
}
|
||||
|
||||
export type RecentGroup<R extends RecentViewRow> = {
|
||||
key: string
|
||||
id: string
|
||||
/** The project or server name; date and status groups take their label from their ID. */
|
||||
label: string | undefined
|
||||
rows: R[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts and groups Recent's rows. Date groups follow the sort direction; Status groups keep their fixed order, Project
|
||||
* groups go A to Z with sessions outside a project last, and Server groups follow `servers`. Empty groups only show for
|
||||
* the fixed sets (date, status, server) and only when asked for.
|
||||
*/
|
||||
export function recentGroups<R extends RecentViewRow>(
|
||||
rows: readonly R[],
|
||||
view: RecentView,
|
||||
context: { now: number; servers: readonly { key: string; label: string }[] },
|
||||
): RecentGroup<R>[] {
|
||||
const sorted = rows.toSorted(comparator(view))
|
||||
|
||||
if (view.groupBy === "none") return [{ key: "none:all", id: "all", label: undefined, rows: sorted }]
|
||||
|
||||
if (view.groupBy === "date") {
|
||||
const bucket = dateBucket(context.now)
|
||||
const time = (row: R) => (view.sortBy === "created" ? row.created : row.updated)
|
||||
const ids = view.direction === "asc" ? RECENT_DATES.toReversed() : RECENT_DATES
|
||||
|
||||
return fixed(
|
||||
view,
|
||||
ids.map((id) => ({ id, label: undefined })),
|
||||
sorted,
|
||||
(row) => bucket(time(row)),
|
||||
)
|
||||
}
|
||||
|
||||
if (view.groupBy === "status")
|
||||
return fixed(
|
||||
view,
|
||||
RECENT_STATUSES.map((id) => ({ id, label: undefined })),
|
||||
sorted,
|
||||
(row) => row.status,
|
||||
)
|
||||
|
||||
if (view.groupBy === "server")
|
||||
return fixed(
|
||||
view,
|
||||
context.servers.map((server) => ({ id: server.key, label: server.label })),
|
||||
sorted,
|
||||
(row) => row.server,
|
||||
)
|
||||
|
||||
const projects = new Map<string, { id: string; label: string | undefined }>()
|
||||
|
||||
sorted.forEach((row) => {
|
||||
const id = row.project?.key ?? NO_PROJECT
|
||||
|
||||
if (!projects.has(id)) projects.set(id, { id, label: row.project?.label })
|
||||
})
|
||||
|
||||
const order = [...projects.values()].toSorted((a, b) => {
|
||||
if (a.id === NO_PROJECT) return 1
|
||||
|
||||
if (b.id === NO_PROJECT) return -1
|
||||
|
||||
return (a.label ?? "").localeCompare(b.label ?? "", undefined, { numeric: true, sensitivity: "base" })
|
||||
})
|
||||
|
||||
return fixed({ ...view, emptyGroups: false }, order, sorted, (row) => row.project?.key ?? NO_PROJECT)
|
||||
}
|
||||
|
||||
export const NO_PROJECT = "none"
|
||||
|
||||
function fixed<R extends RecentViewRow>(
|
||||
view: RecentView,
|
||||
groups: readonly { id: string; label: string | undefined }[],
|
||||
rows: readonly R[],
|
||||
groupOf: (row: R) => string,
|
||||
): RecentGroup<R>[] {
|
||||
const byGroup = Map.groupBy(rows, groupOf)
|
||||
|
||||
return groups.flatMap((group) => {
|
||||
const members = byGroup.get(group.id) ?? []
|
||||
|
||||
if (members.length === 0 && !view.emptyGroups) return []
|
||||
|
||||
return [{ key: `${view.groupBy}:${group.id}`, id: group.id, label: group.label, rows: members }]
|
||||
})
|
||||
}
|
||||
|
||||
function comparator(view: RecentView) {
|
||||
const sign = view.direction === "asc" ? -1 : 1
|
||||
|
||||
return (a: RecentViewRow, b: RecentViewRow) => {
|
||||
const primary = difference(view.sortBy, a, b)
|
||||
|
||||
if (primary !== 0) return sign * primary
|
||||
|
||||
if (a.updated !== b.updated) return b.updated - a.updated
|
||||
|
||||
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0
|
||||
}
|
||||
}
|
||||
|
||||
function difference(sortBy: RecentSortBy, a: RecentViewRow, b: RecentViewRow) {
|
||||
if (sortBy === "name") return b.title.localeCompare(a.title, undefined, { numeric: true, sensitivity: "base" })
|
||||
|
||||
if (sortBy === "created") return b.created - a.created
|
||||
|
||||
return b.updated - a.updated
|
||||
}
|
||||
|
||||
function dateBucket(now: number) {
|
||||
const today = new Date(now)
|
||||
today.setHours(0, 0, 0, 0)
|
||||
const start = today.getTime()
|
||||
const day = (offset: number) => new Date(today.getFullYear(), today.getMonth(), today.getDate() - offset).getTime()
|
||||
|
||||
return (time: number): RecentDate => {
|
||||
if (time >= start) return "today"
|
||||
|
||||
if (time >= day(1)) return "yesterday"
|
||||
|
||||
if (time >= day(7)) return "week"
|
||||
|
||||
return "older"
|
||||
}
|
||||
}
|
||||
@@ -669,8 +669,10 @@ export function TitlebarTabStrip(props: {
|
||||
tabMenu?: (tab: SessionTab) => JSX.Element
|
||||
/** Vertical only: whether a session tab is muted, which swaps its unread dot for a muted mark. */
|
||||
tabMuted?: (tab: SessionTab) => boolean
|
||||
/** Vertical only: rows rendered above the tabs that share their shortcuts, numbered first (e.g. pinned sessions). */
|
||||
/** Rows that share the tabs' shortcuts and are numbered first (e.g. pinned sessions). Side tabs only render `content`. */
|
||||
leading?: TabStripLeading
|
||||
/** Open tabs shown elsewhere (e.g. pinned), kept in the tab order but not rendered here. */
|
||||
hidden?: (tab: Tab) => boolean
|
||||
currentTab: Tab | undefined
|
||||
onNavigate: (tab: Tab, el?: HTMLDivElement) => void
|
||||
onClose: (tab: Tab) => void
|
||||
@@ -684,7 +686,11 @@ export function TitlebarTabStrip(props: {
|
||||
const sections = () => (vertical() ? props.sections : undefined)
|
||||
const customDrag = () => (vertical() ? props.customVerticalDrag : undefined)
|
||||
|
||||
const displayTabs = createMemo(() => sections()?.flatMap((section) => section.tabs) ?? props.tabs)
|
||||
const displayTabs = createMemo(
|
||||
() =>
|
||||
sections()?.flatMap((section) => section.tabs) ??
|
||||
(props.hidden ? props.tabs.filter((tab) => !props.hidden?.(tab)) : props.tabs),
|
||||
)
|
||||
|
||||
const sectionOf = createMemo(
|
||||
() => new Map(sections()?.flatMap((section) => section.tabs.map((tab) => [tabKey(tab), section.key] as const))),
|
||||
@@ -821,7 +827,7 @@ export function TitlebarTabStrip(props: {
|
||||
|
||||
const visibleTabIds = () => visibleTabs().map(tabKey)
|
||||
|
||||
const leading = () => (vertical() ? props.leading : undefined)
|
||||
const leading = () => props.leading
|
||||
|
||||
const leadingKeys = () => leading()?.keys ?? []
|
||||
|
||||
@@ -976,7 +982,7 @@ export function TitlebarTabStrip(props: {
|
||||
customDrag()?.onPointerDown(event, listRef, scrollRef)
|
||||
}}
|
||||
>
|
||||
<Show when={sections()} fallback={<For each={props.tabs}>{(tab) => renderTab(tab)}</For>}>
|
||||
<Show when={sections()} fallback={<For each={displayTabs()}>{(tab) => renderTab(tab)}</For>}>
|
||||
{(list) => (
|
||||
<Key each={list()} by={(section) => section.key}>
|
||||
{(section) => (
|
||||
@@ -1069,7 +1075,7 @@ export function TitlebarTabStrip(props: {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{leading()?.content}
|
||||
{vertical() ? leading()?.content : undefined}
|
||||
<Show
|
||||
when={!customDrag()}
|
||||
fallback={renderList()}
|
||||
|
||||
@@ -19,17 +19,19 @@ import { useProjectStart } from "@/home/projects/start"
|
||||
import { WindowsAppMenu } from "./windows-menu"
|
||||
import { createTitlebarHistory } from "./history"
|
||||
import { TitlebarTabStrip } from "@/shell/titlebar/tab-strip"
|
||||
import { createPinnedLeading, PinMenuItems, PinnedArea, PinsProvider, usePins } from "@/shell/titlebar/pinned-area"
|
||||
import { macVerticalTrafficLights, SidebarToggle } from "@/shell/sidebar-toggle"
|
||||
import { SidebarInbox } from "@/shell/titlebar/inbox"
|
||||
import { SidebarCustomized, type SidebarStripGrouping } from "@/shell/titlebar/sidebar-customized"
|
||||
import { SidebarOrganized } from "@/shell/titlebar/sidebar-organized"
|
||||
import { RecentSessions } from "@/shell/titlebar/recent-sessions"
|
||||
import { createNavigationSwitch } from "@/shell/tabs/navigation-switch"
|
||||
import { makeEventListener } from "@solid-primitives/event-listener"
|
||||
import { createMediaQuery } from "@solid-primitives/media"
|
||||
import { readSessionTabsRemovedDetail, SESSION_TABS_REMOVED_EVENT } from "@/shell/titlebar/session-events"
|
||||
import { useGlobal } from "@/runtime/server/runtime"
|
||||
import { ServerConnection } from "@/runtime/server/registry"
|
||||
import { tabKey, useTabs } from "@/shell/tabs/tabs"
|
||||
import { tabKey, useTabs, type Tab } from "@/shell/tabs/tabs"
|
||||
import type { ComposerState } from "@/composer/persistence"
|
||||
import "./titlebar.css"
|
||||
import { MobileDrawer, MobileDrawerContent, MobileDrawerLabel, MobileDrawerTrigger } from "@/shell/mobile-drawer"
|
||||
@@ -268,6 +270,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
const preparing = routeSync.preparing
|
||||
const session = routeSync.session
|
||||
const currentTab = routeSync.currentTab
|
||||
createNavigationSwitch(currentTab)
|
||||
|
||||
makeEventListener(window, SESSION_TABS_REMOVED_EVENT, (event) => {
|
||||
const detail = readSessionTabsRemovedDetail(event)
|
||||
@@ -388,6 +391,11 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
/>
|
||||
)
|
||||
|
||||
const homeLabel = () =>
|
||||
language.t(settings.appearance.navigationPrototype() ? "sidebar.sessions" : "home.title")
|
||||
|
||||
const homeIcon = () => (settings.appearance.navigationPrototype() ? "sessions-stack" : "grid-plus")
|
||||
|
||||
const homeButton = (vertical = false) => (
|
||||
<Show
|
||||
when={vertical}
|
||||
@@ -396,7 +404,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
placement="bottom"
|
||||
value={
|
||||
<>
|
||||
{language.t("home.title")}
|
||||
{homeLabel()}
|
||||
<Keybind keys={command.keybindParts("home.toggle")} variant="neutral" />
|
||||
</>
|
||||
}
|
||||
@@ -407,10 +415,10 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
class="!w-9 shrink-0"
|
||||
icon={<Icon name="grid-plus" />}
|
||||
icon={<Icon name={homeIcon()} />}
|
||||
state={layout.route().type === "home" ? "pressed" : undefined}
|
||||
onClick={toggleHome}
|
||||
aria-label={language.t("home.title")}
|
||||
aria-label={homeLabel()}
|
||||
aria-pressed={layout.route().type === "home"}
|
||||
/>
|
||||
</Tooltip>
|
||||
@@ -418,8 +426,8 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
>
|
||||
<SidebarAction
|
||||
action="vertical-tabs-home"
|
||||
icon="grid-plus"
|
||||
label={language.t("home.title")}
|
||||
icon={homeIcon()}
|
||||
label={homeLabel()}
|
||||
keybind={command.keybindParts("home.toggle")}
|
||||
pressed={layout.route().type === "home"}
|
||||
onClick={toggleHome}
|
||||
@@ -483,7 +491,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
}
|
||||
|
||||
const firstSidebarAction = () => (
|
||||
<Show when={projectNavigation()} fallback={homeButton(true)}>
|
||||
<Show when={projectNavigation() || settings.appearance.navigationPrototype()} fallback={homeButton(true)}>
|
||||
{newSessionButton()}
|
||||
</Show>
|
||||
)
|
||||
@@ -508,6 +516,13 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
category: language.t("command.category.session"),
|
||||
keybind: "mod+shift+f",
|
||||
onSelect: async () => {
|
||||
// The navigation prototype searches on Home, whose search field takes focus when it opens.
|
||||
if (settings.appearance.navigationPrototype()) {
|
||||
if (layout.route().type !== "home") return void toggleHome()
|
||||
|
||||
return void command.trigger("session.search")
|
||||
}
|
||||
|
||||
const { DialogSessionSearch } = await import("@/shell/commands/session-search")
|
||||
void dialog.show(() => <DialogSessionSearch />)
|
||||
},
|
||||
@@ -644,8 +659,62 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
|
||||
return (
|
||||
<TabGroupsProvider currentTab={currentTab}>
|
||||
<PinsProvider currentTab={currentTab}>
|
||||
{(() => {
|
||||
const tabGroups = useTabGroups()
|
||||
const pins = usePins()
|
||||
const prototype = () => settings.appearance.navigationPrototype()
|
||||
const pinnedTop = createPinnedLeading("horizontal")
|
||||
const pinnedSide = createPinnedLeading("vertical")
|
||||
|
||||
const pinMenu = (tab: Tab) => {
|
||||
const ref = pins.refOf(tab)
|
||||
|
||||
return ref ? <PinMenuItems pin={ref} /> : undefined
|
||||
}
|
||||
|
||||
const listPins = {
|
||||
content: () => (
|
||||
<Show when={pins.state.items.length > 0}>
|
||||
<PinnedArea orientation="vertical" />
|
||||
</Show>
|
||||
),
|
||||
keys: pins.keys,
|
||||
current: pins.currentKey,
|
||||
unread: pins.unread,
|
||||
navigate: pins.openKey,
|
||||
holds: (server: string, sessionId: string) =>
|
||||
pins.pinned({ server: ServerConnection.Key.make(server), sessionId }),
|
||||
toggle: (server: string, sessionId: string) => {
|
||||
const ref = { server: ServerConnection.Key.make(server), sessionId }
|
||||
|
||||
if (pins.pinned(ref)) return pins.unpin(ref)
|
||||
pins.pin(ref)
|
||||
},
|
||||
}
|
||||
|
||||
const pinnedVerticalStrip = () => (
|
||||
<TitlebarTabStrip
|
||||
orientation="vertical"
|
||||
leading={pinnedSide()}
|
||||
hidden={pins.holds}
|
||||
tabContextMenu={pinMenu}
|
||||
tabs={tabsStore}
|
||||
currentTab={currentTab()}
|
||||
onNavigate={(tab, el) => {
|
||||
tabs.select(tab)
|
||||
el?.scrollIntoView({ behavior: "instant", block: "nearest" })
|
||||
}}
|
||||
onClose={(tab) => {
|
||||
const index = tabsStore.findIndex((item) => tabKey(item) === tabKey(tab))
|
||||
|
||||
if (index !== -1) tabsStoreActions.closeTab(index)
|
||||
}}
|
||||
onCloseTabs={(items, keep) => tabsStoreActions.closeTabs(items.map(tabKey), keep)}
|
||||
onReorder={(keys) => tabsStoreActions.reorder(keys)}
|
||||
/>
|
||||
)
|
||||
|
||||
const verticalSections = createVerticalTabGroupSections()
|
||||
|
||||
const defaultVerticalTabStrip = () => (
|
||||
@@ -700,7 +769,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
{/* Pulls the first tab's avatar 10px from Search, past the row gap plus the tab's own inset. */}
|
||||
<div class="-me-0.5 flex shrink-0 items-center gap-0.5">
|
||||
{homeButton()}
|
||||
{searchButton()}
|
||||
<Show when={!settings.appearance.navigationPrototype()}>{searchButton()}</Show>
|
||||
</div>
|
||||
</Show>
|
||||
|
||||
@@ -836,7 +905,13 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
when={props.verticalTabs}
|
||||
fallback={
|
||||
<>
|
||||
<Show when={prototype() && pins.state.items.length > 0}>
|
||||
<PinnedArea orientation="horizontal" />
|
||||
</Show>
|
||||
<TitlebarTabStrip
|
||||
leading={prototype() ? pinnedTop() : undefined}
|
||||
hidden={prototype() ? pins.holds : undefined}
|
||||
tabContextMenu={prototype() ? pinMenu : undefined}
|
||||
tabs={tabsStore}
|
||||
currentTab={currentTab()}
|
||||
onNavigate={(tab, el) => {
|
||||
@@ -904,8 +979,18 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
</Show>
|
||||
<div class="flex w-full shrink-0 flex-col gap-[3px]">
|
||||
<Show when={!actionInSidebarHeader()}>{firstSidebarAction()}</Show>
|
||||
{searchButton(true)}
|
||||
<Show when={projectNavigation()} fallback={newSessionButton()}>
|
||||
<Show
|
||||
when={settings.appearance.navigationPrototype()}
|
||||
fallback={
|
||||
<>
|
||||
{searchButton(true)}
|
||||
<Show when={projectNavigation()} fallback={newSessionButton()}>
|
||||
{settingsButton()}
|
||||
</Show>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{homeButton(true)}
|
||||
{settingsButton()}
|
||||
</Show>
|
||||
</div>
|
||||
@@ -917,6 +1002,17 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
</Show>
|
||||
<div class="flex min-h-0 flex-1 flex-col gap-1">
|
||||
<Switch fallback={defaultVerticalTabStrip()}>
|
||||
<Match when={prototype() && settings.appearance.navigation() === "list"}>
|
||||
<RecentSessions
|
||||
organize={{
|
||||
viewAll: () => {
|
||||
if (layout.route().type !== "home") toggleHome()
|
||||
},
|
||||
}}
|
||||
pinned={listPins}
|
||||
/>
|
||||
</Match>
|
||||
<Match when={prototype()}>{pinnedVerticalStrip()}</Match>
|
||||
<Match when={settings.appearance.tabLayout() === "inbox"}>
|
||||
<SidebarInbox />
|
||||
</Match>
|
||||
@@ -955,6 +1051,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
</PinsProvider>
|
||||
</TabGroupsProvider>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -141,6 +141,7 @@ export type AppIconName =
|
||||
| "select-element"
|
||||
| "selector"
|
||||
| "server"
|
||||
| "sessions-stack"
|
||||
| "settings-gear"
|
||||
| "share"
|
||||
| "shield"
|
||||
|
||||
@@ -390,6 +390,10 @@ const icons = {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M10.5 2.5V6.5L11.3571 8.5M10.5 2.5H5.5M10.5 2.5H12.5M5.5 2.5V6.5L4.21429 9.5M5.5 2.5H3.5M4.21429 9.5L2.5 13.5H13.5L11.3571 8.5M4.21429 9.5L11.3571 8.5" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/>`,
|
||||
},
|
||||
"sessions-stack": {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M3.5 3.5H12.5M1.5 5.5V12.5H14.5V5.5H12.5H3.5H1.5Z" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/>`,
|
||||
},
|
||||
"grid-plus": {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M13.9948 11.668H9.32812M11.6641 9.33203V13.9987M6.66667 9.33203V13.9987H2V9.33203H6.66667ZM6.66667 2V6.66667H2V2H6.66667ZM13.9948 2V6.66667H9.32812V2H13.9948Z" stroke="currentColor" stroke-miterlimit="10" stroke-linecap="square"/>`,
|
||||
|
||||
Reference in New Issue
Block a user