Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Double clicking items in explorer nav should persist their tabs (#50558)

Joshen Lim45381bf857c5
diff --git a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavChats.tsx b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavChats.tsx
index f6473b6038b..5635f23d706 100644
--- a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavChats.tsx
+++ b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavChats.tsx
@@ -8,6 +8,7 @@ import { ExplorerNavResourceWrapper, rowClassName } from './ExplorerLayout.const
import { useCreateChat } from '@/components/interfaces/Explorer/hooks'
import type { ChatSession } from '@/state/ai-assistant-state'
import { useAiAssistantChatList } from '@/state/ai-assistant-state'
+import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
const getVisibleChats = (chats: ChatSession[], search: string): ChatSession[] => {
const normalizedSearch = search.trim().toLowerCase()
@@ -24,6 +25,7 @@ export const ExplorerNavChats = () => {
const { id } = useParams()
const { openChat } = useCreateChat()
const chatList = useAiAssistantChatList()
+ const tabs = useTabsStateSnapshot()
const chats = getVisibleChats(chatList, search)
@@ -45,6 +47,7 @@ export const ExplorerNavChats = () => {
tabIndex={0}
className={rowClassName(isActive)}
onClick={() => openChat(chat.id)}
+ onDoubleClick={() => tabs.makeTabPermanent(createTabId('chat', { id: chat.id }))}
>
<MessageSquare
size={14}
diff --git a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
index ba8b4789867..d0f78e92216 100644
--- a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
+++ b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
@@ -16,6 +16,7 @@ import { useCreateChat, useCreateQuery } from '@/components/interfaces/Explorer/
import { useContentCountQuery } from '@/data/content/content-count-query'
import { useNotebooksInfiniteQuery } from '@/data/content/notebooks/notebooks-infinite-query'
import { useAiAssistantChatList } from '@/state/ai-assistant-state'
+import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
export const ExplorerNavHome = ({
onSelectSection,
@@ -24,6 +25,7 @@ export const ExplorerNavHome = ({
}) => {
const { ref } = useParams()
const { openChat } = useCreateChat()
+ const tabs = useTabsStateSnapshot()
const { createQuery } = useCreateQuery()
const { data: notebooksData } = useNotebooksInfiniteQuery({ projectRef: ref, limit: 100 })
@@ -113,6 +115,7 @@ export const ExplorerNavHome = ({
tabIndex={0}
className={rowClassName(false)}
onClick={() => openChat(item.id)}
+ onDoubleClick={() => tabs.makeTabPermanent(createTabId('chat', { id: item.id }))}
>
{content}
</button>
@@ -121,6 +124,9 @@ export const ExplorerNavHome = ({
key={item.id}
href={`/project/${ref}/explorer/notebook/${item.id}`}
className={rowClassName(false)}
+ onDoubleClick={() =>
+ tabs.makeTabPermanent(createTabId('notebook', { id: item.id }))
+ }
>
{content}
</Link>
diff --git a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavNotebooks.tsx b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavNotebooks.tsx
index 27861712c45..b9abcf2191d 100644
--- a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavNotebooks.tsx
+++ b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavNotebooks.tsx
@@ -17,6 +17,7 @@ import {
NotebookRow,
useNotebooksInfiniteQuery,
} from '@/data/content/notebooks/notebooks-infinite-query'
+import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
const NOTEBOOK_ROW_HEIGHT = 28
@@ -32,12 +33,14 @@ const NotebookListItem = ({
activeNotebookId,
}: NotebookListItemProps) => {
const isActive = activeNotebookId === notebook.id
+ const tabs = useTabsStateSnapshot()
return (
<Link
href={`/project/${projectRef}/explorer/notebook/${notebook.id}`}
className={rowClassName(isActive)}
style={style}
+ onDoubleClick={() => tabs.makeTabPermanent(createTabId('notebook', { id: notebook.id }))}
>
<NotebookText size={14} className={cn('shrink-0', isActive && 'text-foreground')} />
<span className="truncate text-left">{notebook.name}</span>