Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/app/src/pages/session/session-side-panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,19 @@ describe("makeRightPanelResizeHandler", () => {
expect(received).toBe(280)
})
})

describe("shouldShowReviewFileOpenButton", () => {
test("hides the file-open button while the Review tab is active", async () => {
const { shouldShowReviewFileOpenButton } = await import("./session-side-panel")

expect(shouldShowReviewFileOpenButton("review")).toBe(false)
})

test("keeps the file-open button for non-review tabs in the same panel", async () => {
const { shouldShowReviewFileOpenButton } = await import("./session-side-panel")

expect(shouldShowReviewFileOpenButton("empty")).toBe(true)
expect(shouldShowReviewFileOpenButton("context")).toBe(true)
expect(shouldShowReviewFileOpenButton("file:///tmp/example.ts")).toBe(true)
})
})
61 changes: 29 additions & 32 deletions packages/app/src/pages/session/session-side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function makeRightPanelResizeHandler(
}
}

export function shouldShowReviewFileOpenButton(activeTab: string | undefined): boolean {
return activeTab !== "review"
}

type RightPanelShellIconName = "status" | "folder" | "review" | "terminal"

function RightPanelShellIcon(props: { icon: RightPanelShellIconName }) {
Expand Down Expand Up @@ -188,6 +192,27 @@ export function SessionSidePanel(props: {
})
}

const fileOpenButton = (className: string) => (
<Show when={shouldShowReviewFileOpenButton(activeTab())}>
<div class={className}>
<TooltipKeybind
title={language.t("command.file.open")}
keybind={command.keybind("file.open")}
class="flex items-center"
>
<IconButton
icon="plus-small"
variant="ghost"
iconSize="large"
class="!rounded-md"
onClick={() => openFilePicker(showAllFiles)}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
</div>
</Show>
)
Comment on lines +195 to +214

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In SolidJS, it is more idiomatic to define reusable UI pieces as components (capitalized) rather than functions that return JSX. This improves readability and follows the project's convention (e.g., RightPanelShellIcon). Additionally, using the class prop name is more consistent with SolidJS than className.

Suggested change
const fileOpenButton = (className: string) => (
<Show when={shouldShowReviewFileOpenButton(activeTab())}>
<div class={className}>
<TooltipKeybind
title={language.t("command.file.open")}
keybind={command.keybind("file.open")}
class="flex items-center"
>
<IconButton
icon="plus-small"
variant="ghost"
iconSize="large"
class="!rounded-md"
onClick={() => openFilePicker(showAllFiles)}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
</div>
</Show>
)
const FileOpenButton = (props: { class: string }) => (
<Show when={shouldShowReviewFileOpenButton(activeTab())}>
<div class={props.class}>
<TooltipKeybind
title={language.t("command.file.open")}
keybind={command.keybind("file.open")}
class="flex items-center"
>
<IconButton
icon="plus-small"
variant="ghost"
iconSize="large"
class="!rounded-md"
onClick={() => openFilePicker(showAllFiles)}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
</div>
</Show>
)


createEffect(() => {
if (!file.ready()) return

Expand Down Expand Up @@ -292,22 +317,7 @@ export function SessionSidePanel(props: {
<Show
when={showSecondaryReviewTabs()}
fallback={
<div class="w-full bg-background-stronger flex items-center justify-end px-3 py-1.5">
<TooltipKeybind
title={language.t("command.file.open")}
keybind={command.keybind("file.open")}
class="flex items-center"
>
<IconButton
icon="plus-small"
variant="ghost"
iconSize="large"
class="!rounded-md"
onClick={() => openFilePicker(showAllFiles)}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
</div>
fileOpenButton("w-full bg-background-stronger flex items-center justify-end px-3 py-1.5")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the refactored FileOpenButton component here.

Suggested change
fileOpenButton("w-full bg-background-stronger flex items-center justify-end px-3 py-1.5")
<FileOpenButton class="w-full bg-background-stronger flex items-center justify-end px-3 py-1.5" />

}
>
<Tabs.List
Expand Down Expand Up @@ -357,22 +367,9 @@ export function SessionSidePanel(props: {
<SortableProvider ids={openedTabs()}>
<For each={openedTabs()}>{(tab) => <SortableTab tab={tab} onTabClose={tabs().close} />}</For>
</SortableProvider>
<div class="bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3">
<TooltipKeybind
title={language.t("command.file.open")}
keybind={command.keybind("file.open")}
class="flex items-center"
>
<IconButton
icon="plus-small"
variant="ghost"
iconSize="large"
class="!rounded-md"
onClick={() => openFilePicker(showAllFiles)}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
</div>
{fileOpenButton(
"bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3",
)}
Comment on lines +370 to +372

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the refactored FileOpenButton component here.

Suggested change
{fileOpenButton(
"bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3",
)}
<FileOpenButton
class="bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3"
/>

</Tabs.List>
</Show>
</div>
Expand Down
Loading