fix(app): refine open file tab (#46736)

This commit is contained in:
Brendan Allan 2026-09-02 15:10:25 +08:00 committed by GitHub
parent b4447e6be8
commit fbcc2d9855
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View file

@ -93,11 +93,18 @@ test("opens and searches project files inline", async ({ page }) => {
await contextButton.click()
await expect(panel.getByRole("tab", { name: "Context", selected: true })).toBeVisible()
await panel.getByRole("button", { name: "Open file" }).click()
await expect(panel.getByRole("tab", { name: "Open file", selected: true })).toBeVisible()
const openFileTab = panel.getByRole("tab", { name: "Open file" })
const openFileTabClose = openFileTab.locator("..").getByRole("button", { name: "Close tab" })
await expect(openFileTab).toHaveAttribute("data-selected", "")
await expect(openFileTab.locator("use")).toHaveAttribute("href", "#opencode-v2-icon-file-tree")
await expect(openFileTab.getByText("Open file", { exact: true }).locator("..")).not.toHaveClass(/italic/)
await expect(openFileTabClose).toHaveAttribute("data-variant", "ghost-muted")
await expect(openFileTabClose).toHaveCSS("opacity", "1")
await expect(sidebarToggle).toBeDisabled()
await expect(sidebar).toBeVisible()
await contextButton.click()
await expect(panel.getByRole("tab", { name: "Context", selected: true })).toBeVisible()
await expect(openFileTabClose).toHaveCSS("opacity", "0")
await expect(sidebar).toBeHidden()
await panel.getByRole("button", { name: "Open file" }).click()
const filter = panel.getByRole("combobox", { name: "Filter files" })

View file

@ -359,6 +359,7 @@ export function SessionSidePanel(props: {
>
<Tabs.Trigger
value={SESSION_OPEN_FILE_TAB}
class="group"
onMiddleClick={() => tabs().close(SESSION_OPEN_FILE_TAB)}
closeButton={
<Tooltip
@ -373,16 +374,29 @@ export function SessionSidePanel(props: {
placement="bottom"
gutter={10}
>
<Tabs.CloseButton
onClick={() => tabs().close(SESSION_OPEN_FILE_TAB)}
<IconButton
size="small"
variant="ghost-muted"
class="hover-reveal relative z-10 group-hover:opacity-100"
classList={{ "opacity-100": activeTab() === SESSION_OPEN_FILE_TAB }}
onPointerDown={(event) => {
event.preventDefault()
event.stopPropagation()
}}
onClick={(event) => {
event.preventDefault()
event.stopPropagation()
tabs().close(SESSION_OPEN_FILE_TAB)
}}
icon={<Icon name="xmark-small" />}
aria-label={language.t("common.closeTab")}
/>
</Tooltip>
}
hideCloseButton
>
<div class="flex items-center gap-1.5 italic">
<Icon name="open-file" size="small" />
<div class="flex items-center gap-1.5">
<Icon name="file-tree" size="small" />
<span>{language.t("command.file.open")}</span>
</div>
</Tabs.Trigger>