GeezerVison is showing github.com — feat(app): group sessions and tabs by project by liambreen · Pull Request #57888 · anomalyco/opencode
feat(app): group sessions and tabs by project
#57888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5786d7e
feat(app): group Home sessions by project
liambreen Oct 21, 2026
60d66f5
fix(app): nest grouped session rows under project headers
liambreen Oct 21, 2026
3218f26
feat(app): group session tabs by project
liambreen Oct 21, 2026
52807ec
test(app): default an invalid tab grouping preference
liambreen Oct 21, 2026
dc838a4
feat(app): Edge-style tab group badges, compact vertical groups, grou…
liambreen Oct 21, 2026
0997c64
test(app): cover grouped drag boundaries, document index sync
liambreen Oct 21, 2026
e75cf8d
feat(app): one-char group badges and compressed grouped lists
liambreen Oct 21, 2026
be88a5a
fix(ui): span tooltip triggers inside buttons
liambreen Oct 21, 2026
d0b1555
refactor(app): read grouping prefs directly and polish tab groups
liambreen Oct 21, 2026
d592ad3
refactor(ui): type tooltip trigger ref as element
liambreen Oct 21, 2026
File filter
Filter by extension
.ts
(6)
.tsx
(5)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
feat(app): group session tabs by project
An opt-in Settings > General preference clusters session tabs under
their project in the tab strip, in both horizontal and vertical layouts,
like browser tab groups. Group headers show the project avatar and name
and collapse individually per window; collapsed members leave the
visible-tab cycle. Membership derives from each tab's session directory
(or the draft's directory), so groups need no management: the grouped
view is a stable partition of the persisted order and drag-reorder
pauses while grouping is on, restoring the user's own order when off.
Refs #51759
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit 3218f26ed2df3f82bb0dbb47c0010aff5305234f
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1355,6 +1355,18 @@ test("the tab layout preference switches to vertical tabs and survives reload",
await expect(page.locator('[data-slot="titlebar-tabs"]')).toHaveCount(0)
})
test("the tab grouping preference selects project groups and survives reload", async ({ page }) => {
const { settings } = await open(page)
const grouping = settings.locator('[data-action="settings-tab-groups"]')
await expect(grouping).toContainText("Off")
await grouping.click()
await page.getByRole("option", { name: "By project" }).click()
await expect(grouping).toContainText("By project")
await page.reload()
await expect(grouping).toContainText("By project")
})
for (const viewport of [
{ name: "desktop", width: 1280, height: 720, bottom: false },
{ name: "mobile", width: 390, height: 844, bottom: true },
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
import { expect, test, type Page } from "@playwright/test"
import { expect, test, type Locator, type Page } from "@playwright/test"
import type { OpenCodeEvent, SessionMessageInfo } from "@opencode/client/promise"
import {
NO_PROVIDER,
Expand Down
Expand Up
@@ -188,6 +188,92 @@ test("option arrows move to the previous or next tab, and with shift to the next
await expectPath(page, sessionHref(c.id))
})
for (const row of [{ tabLayout: "horizontal", width: 1440 }, { tabLayout: "vertical", width: 1440 }] as const) {
test(`session tabs cluster under collapsible project groups (${row.tabLayout})`, async ({ page }) => {
await page.setViewportSize({ width: row.width, height: 900 })
const second = "C:/OpenCode/TabGroups"
const secondProject = "proj_tab_groups"
const x = { id: "ses_tab_x", title: "Tab X session", directory: second, projectID: secondProject }
const y = { id: "ses_tab_y", title: "Tab Y session", directory: second, projectID: secondProject }
const workspace = await mockWorkspace(page, {
name: "Tabs",
projects: [
project({ id: "proj_tabs", directory: "C:/OpenCode/Tabs", name: "Tabs" }),
project({ id: secondProject, directory: second, name: "TabGroups" }),
],
sessions: [a, x, b, y],
seed: {
tabs: [a.id, x.id, { draft: "draft_tab_group", directory: "C:/OpenCode/Tabs" }, b.id, y.id],
settings: { appearance: { tabLayout: row.tabLayout, tabGroups: "project" } },
projects: {
local: [
{ worktree: "C:/OpenCode/Tabs", expanded: true },
{ worktree: second, expanded: true },
],
},
},
})
await page.goto(sessionHref(a.id, workspace.server))
const headers = page.locator('[data-component="titlebar-tab-group"]')
const tabsHeader = page.getByRole("button", { name: "Tabs", exact: true })
const groupsHeader = page.getByRole("button", { name: "TabGroups", exact: true })
const slot = (href: string) => page.locator(`[data-titlebar-tab-slot]:has(a[href="${href}"])`)
const hrefs = {
a: sessionHref(a.id, workspace.server),
draft: `/new-session?draftId=draft_tab_group`,
b: sessionHref(b.id, workspace.server),
x: sessionHref(x.id, workspace.server),
y: sessionHref(y.id, workspace.server),
}
await expect(headers).toHaveCount(2)
await expect(slot(hrefs.a)).toBeVisible()
await expect(slot(hrefs.y)).toBeVisible()
// Groups partition the strip in visual order even though the persisted
// order interleaves the two projects.
const axis = row.tabLayout === "vertical" ? "y" : "x"
const position = async (locator: Locator) => (await locator.boundingBox())![axis]
expect(await position(tabsHeader)).toBeLessThan(await position(slot(hrefs.a)))
expect(await position(slot(hrefs.a))).toBeLessThan(await position(slot(hrefs.draft)))
expect(await position(slot(hrefs.draft))).toBeLessThan(await position(slot(hrefs.b)))
expect(await position(slot(hrefs.b))).toBeLessThan(await position(groupsHeader))
expect(await position(groupsHeader)).toBeLessThan(await position(slot(hrefs.x)))
expect(await position(slot(hrefs.x))).toBeLessThan(await position(slot(hrefs.y)))
// Collapsing one group hides exactly its members, draft included.
await expect(tabsHeader).toHaveAttribute("aria-expanded", "true")
await tabsHeader.click()
await expect(tabsHeader).toHaveAttribute("aria-expanded", "false")
await expect(slot(hrefs.a)).not.toBeAttached()
await expect(slot(hrefs.draft)).not.toBeAttached()
await expect(slot(hrefs.b)).not.toBeAttached()
await expect(slot(hrefs.x)).toBeVisible()
// Tab cycling skips the collapsed group's members.
await page.locator(`a[data-titlebar-tab-link][href="${hrefs.x}"]`).click()
await expectPath(page, sessionHref(x.id, workspace.server))
await page.keyboard.press("Alt+ArrowDown")
await expectPath(page, sessionHref(y.id, workspace.server))
await page.keyboard.press("Alt+ArrowUp")
await expectPath(page, sessionHref(x.id, workspace.server))
// Both the grouping mode and the collapsed group survive a reload.
await page.reload()
await expect(tabsHeader).toHaveAttribute("aria-expanded", "false")
await expect(slot(hrefs.x)).toBeVisible()
await expect(slot(hrefs.a)).not.toBeAttached()
// Expanding restores the hidden members.
await tabsHeader.click()
await expect(slot(hrefs.a)).toBeVisible()
})
}
for (const row of [
{ tabLayout: "horizontal", width: 360, hasTouch: false, direction: "ltr" },
{ tabLayout: "vertical", width: 390, hasTouch: true, direction: "rtl" },
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -830,7 +830,7 @@ function HomeProjectNavButton(props: JSX.ButtonHTMLAttributes<HTMLButtonElement>
)
}
export function HomeProjectAvatar(props: { project: LocalProject; outline?: boolean }) {
function HomeProjectAvatar(props: { project: LocalProject; outline?: boolean }) {
const name = createMemo(() => displayName(props.project))
return (
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -13,8 +13,8 @@ import { Tooltip } from "@opencode/ui/tooltip"
import { useLanguage } from "@/runtime/i18n/language"
import { ServerConnection } from "@/runtime/server/registry"
import { SessionTabAvatarView } from "@/shell/layout/session-tab-avatar"
import { ProjectIcon } from "@/shell/layout/project-icon"
import { sessionLabel } from "@/session/title"
import { HomeProjectAvatar } from "../projects/view"
import { shouldOpenSessionInBackground } from "./open"
import { createAltHold } from "./alt-hold"
import "./view.css"
Expand Down
Expand Up
@@ -572,7 +572,7 @@ function HomeSessionProjectGroupHeader(props: {
</span>
<span class="flex min-w-0 items-center gap-1.5" style={{ opacity: props.titleOpacity }}>
<span aria-hidden="true" class="flex shrink-0">
<Show when={props.group.project}>{(project) => <HomeProjectAvatar project={project()} />}</Show>
<Show when={props.group.project}>{(project) => <ProjectIcon project={project()} />}</Show>
</span>
<span class={`${HOME_SECTION_LABEL} min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`}>
{props.group.title}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -721,6 +721,10 @@ export const dict = {
"settings.appearance.row.tabs.description": "Choose how session tabs are arranged",
"settings.appearance.row.tabs.horizontal": "Horizontal",
"settings.appearance.row.tabs.vertical": "Vertical",
"settings.appearance.row.tabGroups.title": "Group tabs by project",
"settings.appearance.row.tabGroups.description": "Cluster session tabs under their project in the tab strip",
"settings.appearance.row.tabGroups.off": "Off",
"settings.appearance.row.tabGroups.project": "By project",
"settings.notifications.description": "Choose when to receive notifications and hear sounds",
"settings.shortcuts.description": "Customize shortcuts for common actions",
"settings.servers.description": "Manage server connections",
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -217,6 +217,35 @@ const TabLayoutSetting = () => {
)
}
const tabGroupsOptions: ("off" | "project")[] = ["off", "project"]
const TabGroupsSetting = () => {
const language = useLanguage()
const settings = useSettings()
return (
<SettingsRow
title={language.t("settings.appearance.row.tabGroups.title")}
description={language.t("settings.appearance.row.tabGroups.description")}
>
<Select
data-action="settings-tab-groups"
options={tabGroupsOptions}
current={tabGroupsOptions.find((option) => option === settings.appearance.tabGroups())}
aria-label={language.t("settings.appearance.row.tabGroups.title")}
placement="bottom-end"
gutter={6}
label={(option) =>
option === "off"
? language.t("settings.appearance.row.tabGroups.off")
: language.t("settings.appearance.row.tabGroups.project")
}
onSelect={(option) => option && settings.appearance.setTabGroups(option)}
/>
</SettingsRow>
)
}
export const SettingsGeneral: Component = () => {
const language = useLanguage()
const platform = usePlatform()
Expand Down
Expand Up
@@ -244,6 +273,7 @@ export const SettingsGeneral: Component = () => {
<SettingsList>
<LanguageSetting />
<TabLayoutSetting />
<TabGroupsSetting />
<WorkspaceDestinationSetting />
<AutoApprovePermissionsSetting />
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -104,6 +104,7 @@ describe("settings schema", () => {
sans: "",
terminal: "",
tabLayout: "horizontal",
tabGroups: "off",
},
keybinds: {},
permissions: { autoApprove: false, autoApproveProjects: {} },
Expand Down
Expand Up
@@ -149,6 +150,7 @@ describe("settings schema", () => {
sans: "",
terminal: "",
tabLayout: "vertical",
tabGroups: "off",
})
expect(settings.permissions).toEqual({ autoApprove: true, autoApproveProjects: { on: true, off: false } })
expect(settings.workspaces).toEqual({ defaultDestination: "new", lastUsed: { good: "workspace" } })
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -19,6 +19,8 @@ export type FollowUpBehavior = Settings["general"]["followUpBehavior"]
export type TabLayout = Settings["appearance"]["tabLayout"]
export type TabGroups = Settings["appearance"]["tabGroups"]
export type NotificationSettings = Settings["notifications"]
export type SoundSettings = Settings["sounds"]
Expand Down
Expand Up
@@ -130,6 +132,7 @@ const appearanceSchema = Persistence.struct({
sans: Schema.String,
terminal: Schema.String,
tabLayout: Schema.Literals(["horizontal", "vertical"]),
tabGroups: Schema.Literals(["off", "project"]),
})
const permissionsSchema = Persistence.struct({
Expand Down
Expand Up
@@ -284,7 +287,7 @@ export const defaultSettings: Settings = {
terminalPlacement: "side",
followUpBehavior: "steer",
},
appearance: { fontSize: 14, mono: "", sans: "", terminal: "", tabLayout: "horizontal" },
appearance: { fontSize: 14, mono: "", sans: "", terminal: "", tabLayout: "horizontal", tabGroups: "off" },
keybinds: {},
permissions: { autoApprove: false, autoApproveProjects: {} },
workspaces: { defaultDestination: "last-used", lastUsed: {} },
Expand Down
Expand Up
@@ -401,6 +404,10 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
setTabLayout(value: TabLayout) {
setStore("appearance", "tabLayout", value)
},
tabGroups: withFallback(() => store.appearance?.tabGroups, defaultSettings.appearance.tabGroups),
setTabGroups(value: TabGroups) {
setStore("appearance", "tabGroups", value)
},
},
keybinds: {
get: (action: string) => store.keybinds?.[action],
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,58 @@
import { describe, expect, test } from "bun:test"
import type { Tab } from "@/shell/tabs/tabs"
import { groupTabsByProject, type TabGroup } from "./tab-groups"
const sessionTab = (id: string, server = "local"): Tab => ({
type: "session",
server: server as Tab["server"],
sessionId: `ses_${id}`,
})
const draftTab = (id: string): Tab => ({ type: "draft", draftID: id, server: "local" as Tab["server"], directory: "/d" })
describe("groupTabsByProject", () => {
test("keeps first-occurrence group order and within-group order", () => {
const group = (tab: Tab) =>
tab.type === "session" && tab.sessionId.endsWith("1")
? { id: "a", title: "Project A" }
: tab.type === "session"
? { id: "b", title: "Project B" }
: undefined
const { groups, ungrouped } = groupTabsByProject(
[sessionTab("x1"), sessionTab("y2"), draftTab("d3"), sessionTab("z1"), sessionTab("w2")],
group,
)
expect(groups.map((item) => item.id)).toEqual(["a", "b"])
expect(groups[0].tabs.filter((tab) => tab.type === "session").map((tab) => tab.sessionId)).toEqual([
"ses_x1",
"ses_z1",
])
expect(groups[1].tabs.filter((tab) => tab.type === "session").map((tab) => tab.sessionId)).toEqual([
"ses_y2",
"ses_w2",
])
expect(ungrouped.map((tab) => tab.type)).toEqual(["draft"])
})
test("merges tabs of the same project across the strip and trails unresolvable tabs", () => {
const group = (tab: Tab) =>
tab.type === "session" ? { id: tab.sessionId.slice(-1)!, title: `Project ${tab.sessionId.slice(-1)}` } : undefined
const { groups, ungrouped } = groupTabsByProject([sessionTab("a1"), draftTab("d"), sessionTab("b2"), sessionTab("c1")], group)
expect(groups.map((item: TabGroup) => item.id)).toEqual(["1", "2"])
expect(groups[1].title).toBe("Project 2")
expect(ungrouped.map((tab) => tab.type)).toEqual(["draft"])
})
test("keys groups per server so the same directory on two servers stays separate", () => {
const group = (tab: Tab) =>
tab.type === "session" ? { id: `${tab.server}\0${tab.sessionId.slice(-1)}`, title: tab.server } : undefined
const { groups } = groupTabsByProject([sessionTab("a1", "local"), sessionTab("b1", "remote")], group)
expect(groups).toHaveLength(2)
})
})
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,26 @@
import type { LocalProject } from "@/shell/state/layout"
import type { Tab } from "@/shell/tabs/tabs"
export type TabGroup = {
id: string
title: string
project?: LocalProject
tabs: Tab[]
}
// Stable partition of the strip order: groups appear in first-occurrence
// order, each keeps its members' relative order, and tabs the resolver cannot
// place trail every group so loading tabs never block the grouped view.
export function groupTabsByProject(tabs: Tab[], group: (tab: Tab) => Omit<TabGroup, "tabs"> | undefined) {
const keyed = Map.groupBy(
tabs.map((tab) => ({ tab, info: group(tab) })),
(item) => item.info?.id,
)
return {
groups: [...keyed.entries()].flatMap(([, items]) =>
items[0].info ? [{ ...items[0].info, tabs: items.map((item) => item.tab) }] : [],
),
ungrouped: (keyed.get(undefined) ?? []).map((item) => item.tab),
}
}
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.