Repository navigation
feat: add dynamic right-panel shell tabs #110
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7741519
feat: add right panel shell tab state
Astro-Han bf131de
feat: add shell tab layout API
Astro-Han 841fa55
feat: render dynamic shell tabs
Astro-Han 0f93721
fix: route session callers through shell tabs
Astro-Han c35da0b
fix: avoid skipToken query option import
Astro-Han 0c47281
test: align shell tab e2e smoke flows
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| export { SessionHeader } from "./session-header" | ||
| export { SessionContextTab } from "./session-context-tab" | ||
| export { SortableTab, FileVisual } from "./session-sortable-tab" | ||
| export { ShellTab, SortableShellTab } from "./session-sortable-shell-tab" | ||
| export { SortableTerminalTab } from "./session-sortable-terminal-tab" | ||
| export { NewSessionView } from "./session-new-view" |
68 changes: 68 additions & 0 deletions
68
packages/app/src/components/session/session-sortable-shell-tab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import type { JSX } from "solid-js" | ||
| import { createSortable } from "@thisbeyond/solid-dnd" | ||
| import { IconButton } from "@opencode-ai/ui/icon-button" | ||
| import { Tabs } from "@opencode-ai/ui/tabs" | ||
| import { Tooltip } from "@opencode-ai/ui/tooltip" | ||
| import { useLanguage } from "@/context/language" | ||
| import type { RightPanelTab } from "@/pages/session/right-panel-tabs" | ||
|
|
||
| export function ShellTab(props: { | ||
| value: RightPanelTab | ||
| label: string | ||
| closable: boolean | ||
| onClose: (tab: RightPanelTab) => void | ||
| children: JSX.Element | ||
| }): JSX.Element { | ||
| const language = useLanguage() | ||
| const close = () => { | ||
| if (!props.closable) return | ||
| props.onClose(props.value) | ||
| } | ||
|
|
||
| return ( | ||
| <div class="h-full flex items-center"> | ||
| <Tabs.Trigger | ||
| value={props.value} | ||
| class="shrink-0 h-7" | ||
| classes={{ | ||
| button: | ||
| "h-7 min-h-7 inline-flex items-center whitespace-nowrap rounded-md text-12-medium text-text-weak gap-1.5 px-2.5", | ||
| }} | ||
| closeButton={ | ||
| props.closable ? ( | ||
| <Tooltip value={language.t("common.closeTab")} placement="bottom" gutter={10}> | ||
| <IconButton | ||
| icon="close-small" | ||
| variant="ghost" | ||
| class="h-5 w-5" | ||
| onClick={close} | ||
| aria-label={language.t("common.closeTab")} | ||
| /> | ||
| </Tooltip> | ||
| ) : undefined | ||
| } | ||
| hideCloseButton | ||
| onMiddleClick={close} | ||
| aria-label={props.label} | ||
| > | ||
| {props.children} | ||
| </Tabs.Trigger> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export function SortableShellTab(props: { | ||
| value: RightPanelTab | ||
| label: string | ||
| closable: boolean | ||
| onClose: (tab: RightPanelTab) => void | ||
| children: JSX.Element | ||
| }): JSX.Element { | ||
| const sortable = createSortable(props.value) | ||
|
|
||
| return ( | ||
| <div use:sortable class="h-full flex items-center" classList={{ "opacity-0": sortable.isActiveDraggable }}> | ||
| <ShellTab {...props} /> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
|
|
||
| import { | ||
| closeShellTab, | ||
| moveShellTab, | ||
| normalizeShellTabs, | ||
| openShellTab, | ||
| toggleShellTab, | ||
| } from "@/pages/session/right-panel-tabs" | ||
|
|
||
| describe("shell tab transitions", () => { | ||
| const base = normalizeShellTabs({ openShellTabs: ["status"], sidePanelTab: "status" }) | ||
|
|
||
| test("openShellTab appends to end and sets active", () => { | ||
| expect(openShellTab(base, "files")).toEqual({ openShellTabs: ["status", "files"], sidePanelTab: "files" }) | ||
| }) | ||
|
|
||
| test("openShellTab on existing tab only sets active", () => { | ||
| const start = openShellTab(openShellTab(base, "files"), "review") | ||
| const next = openShellTab(start, "files") | ||
| expect(next.openShellTabs).toEqual(["status", "files", "review"]) | ||
| expect(next.sidePanelTab).toBe("files") | ||
| }) | ||
|
|
||
| test("closeShellTab status is no-op", () => { | ||
| expect(closeShellTab(base, "status")).toEqual(base) | ||
| }) | ||
|
|
||
| test("closeShellTab on active falls back to left neighbor", () => { | ||
| const start = openShellTab(openShellTab(base, "files"), "review") | ||
| expect(closeShellTab(start, "review")).toEqual({ openShellTabs: ["status", "files"], sidePanelTab: "files" }) | ||
| }) | ||
|
|
||
| test("closeShellTab on active with no left neighbor falls back to status", () => { | ||
| const start = openShellTab(base, "files") | ||
| expect(closeShellTab(start, "files")).toEqual({ openShellTabs: ["status"], sidePanelTab: "status" }) | ||
| }) | ||
|
|
||
| test("closeShellTab on non-active preserves active", () => { | ||
| const start = openShellTab(openShellTab(base, "files"), "review") | ||
| expect(closeShellTab(start, "files")).toEqual({ openShellTabs: ["status", "review"], sidePanelTab: "review" }) | ||
| }) | ||
|
|
||
| test("toggleShellTab opens when not in list", () => { | ||
| const next = toggleShellTab(base, "files", true) | ||
| expect(next.closePanel).toBe(false) | ||
| expect(next.state).toEqual({ openShellTabs: ["status", "files"], sidePanelTab: "files" }) | ||
| }) | ||
|
|
||
| test("toggleShellTab on inactive in-list tab only activates", () => { | ||
| const start = openShellTab(openShellTab(base, "files"), "review") | ||
| const next = toggleShellTab(start, "files", true) | ||
| expect(next.closePanel).toBe(false) | ||
| expect(next.state.openShellTabs).toEqual(["status", "files", "review"]) | ||
| expect(next.state.sidePanelTab).toBe("files") | ||
| }) | ||
|
|
||
| test("toggleShellTab on active but panel closed activates", () => { | ||
| const start = openShellTab(base, "files") | ||
| const next = toggleShellTab(start, "files", false) | ||
| expect(next.closePanel).toBe(false) | ||
| expect(next.state.sidePanelTab).toBe("files") | ||
| }) | ||
|
|
||
| test("toggleShellTab on active and panel open closes the panel without removing the tab", () => { | ||
| const start = openShellTab(base, "files") | ||
| const next = toggleShellTab(start, "files", true) | ||
| expect(next.closePanel).toBe(true) | ||
| expect(next.state.openShellTabs).toEqual(["status", "files"]) | ||
| expect(next.state.sidePanelTab).toBe("files") | ||
| }) | ||
|
|
||
| test("toggleShellTab status never closes", () => { | ||
| const next = toggleShellTab(base, "status", true) | ||
| expect(next.closePanel).toBe(false) | ||
| expect(next.state).toEqual(base) | ||
| }) | ||
|
|
||
| test("moveShellTab reorders non-status tabs and keeps active", () => { | ||
| const start = openShellTab(openShellTab(openShellTab(base, "files"), "review"), "terminal") | ||
| expect(moveShellTab(start, "terminal", 1)).toEqual({ | ||
| openShellTabs: ["status", "terminal", "files", "review"], | ||
| sidePanelTab: "terminal", | ||
| }) | ||
| }) | ||
|
|
||
| test("moveShellTab cannot move status", () => { | ||
| const start = openShellTab(base, "files") | ||
| expect(moveShellTab(start, "status", 1)).toEqual(start) | ||
| }) | ||
|
|
||
| test("moveShellTab clamps negative indexes after the pinned status tab", () => { | ||
| const start = openShellTab(openShellTab(openShellTab(base, "files"), "review"), "terminal") | ||
| expect(moveShellTab(start, "review", -1).openShellTabs).toEqual(["status", "review", "files", "terminal"]) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.