mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
fix(frontend): compare the active session's server before closing the picker sheet
This commit is contained in:
1 parent
651b9b9995
commit
81fb2d4033
3 files changed
+43
-10
No files matched your search
@@ -353,7 +353,37 @@ describe('SessionPickerSheet', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('opens an activity row of another linked server than the selected one', async () => {
|
||||
it('opens a remote activity row of the same session id that is open on another server', async () => {
|
||||
useSidebarServerStore.setState({ serverId: 'srv_kitchen' })
|
||||
mocks.activeWorkGroups = {
|
||||
needsInput: [],
|
||||
running: [],
|
||||
recent: [activeWorkItem('ses_shared', '/home/me/hall', { id: 'srv_hall', name: 'Hall' })],
|
||||
}
|
||||
|
||||
const { onClose } = renderSheet(['/servers/srv_kitchen/sessions/ses_shared?mobileTab=sessions'])
|
||||
|
||||
fireEvent.mouseDown(screen.getByRole('tab', { name: 'Activity' }))
|
||||
fireEvent.click(await screen.findByRole('option', { name: /Active ses_shared/ }))
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
expect(screen.getByTestId('location')).toHaveTextContent(
|
||||
'/servers/srv_hall/sessions/ses_shared REPLACE',
|
||||
)
|
||||
})
|
||||
|
||||
it('opens a local session row that shares the id of the open remote session', async () => {
|
||||
mocks.sessionsData = [session('ses_shared', 'Shared session', '/w/a')]
|
||||
|
||||
const { onClose } = renderSheet(['/servers/srv_kitchen/sessions/ses_shared?mobileTab=sessions'])
|
||||
|
||||
fireEvent.click(await screen.findByRole('option', { name: /Shared session/ }))
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
expect(screen.getByTestId('location')).toHaveTextContent('/repos/1/sessions/ses_shared REPLACE')
|
||||
})
|
||||
|
||||
it('opens a session row of another linked server than the selected one', async () => {
|
||||
useSidebarServerStore.setState({ serverId: 'srv_kitchen' })
|
||||
mocks.activeWorkGroups = {
|
||||
needsInput: [],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { LOCAL_OPENCODE_SERVER_ID } from '@opencode-manager/shared/schemas'
|
||||
import type { Repo, Session } from '@/api/types'
|
||||
import { BottomSheet } from '@/components/ui/bottom-sheet'
|
||||
import { LinkedServersNav } from '@/components/navigation/LinkedServersNav'
|
||||
@@ -17,7 +18,7 @@ interface SessionPickerSheetProps {
|
||||
export function SessionPickerSheet({ isOpen, onClose }: SessionPickerSheetProps) {
|
||||
const navigate = useNavigate()
|
||||
const [addRepoOpen, setAddRepoOpen] = useState(false)
|
||||
const { currentRepo, activeSessionID, remote } = useSessionPickerRouteScope(isOpen)
|
||||
const { currentRepo, activeSessionID, activeServerId, remote } = useSessionPickerRouteScope(isOpen)
|
||||
|
||||
const navigateReplacing = useCallback(
|
||||
(path: string) => {
|
||||
@@ -28,24 +29,24 @@ export function SessionPickerSheet({ isOpen, onClose }: SessionPickerSheetProps)
|
||||
|
||||
const handleSelectSession = useCallback(
|
||||
(session: Session, repo: Repo) => {
|
||||
if (session.id === activeSessionID) {
|
||||
if (session.id === activeSessionID && activeServerId === LOCAL_OPENCODE_SERVER_ID) {
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
navigateReplacing(getSessionPath(repo.id, session.id))
|
||||
},
|
||||
[activeSessionID, navigateReplacing, onClose],
|
||||
[activeServerId, activeSessionID, navigateReplacing, onClose],
|
||||
)
|
||||
|
||||
const handleSelectRemoteSession = useCallback(
|
||||
(session: Session, serverId: string) => {
|
||||
if (session.id === activeSessionID) {
|
||||
if (session.id === activeSessionID && serverId === activeServerId) {
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
navigateReplacing(getServerSessionPath(serverId, session.id))
|
||||
},
|
||||
[activeSessionID, navigateReplacing, onClose],
|
||||
[activeServerId, activeSessionID, navigateReplacing, onClose],
|
||||
)
|
||||
|
||||
const handleDeleteActiveSession = useCallback(() => {
|
||||
|
||||
Reference in new issue
Block a user