fix(sessions): create session in the same scope the list reads (#10)
Root cause of the empty-sessions-after-connect bug, caught by the now-live E2E smoke: createSession() created via the plain connection client (server CWD), while loadSessions() lists home-scoped when the connection has no explicit directory. When CWD != home the new session was invisible to the list. Fix: createSession now mirrors loadSessions' directory scoping (home-scoped client when no explicit directory), so a freshly created session reliably appears. No change for connections with an explicit directory. Verified by the connect-and-verify-sessions CUA smoke on push. Refs #10.
This commit is contained in:
@@ -185,12 +185,25 @@ export const useSessions = create<SessionsState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
createSession: async (title) => {
|
createSession: async (title) => {
|
||||||
const client = useConnections.getState().client
|
const connState = useConnections.getState()
|
||||||
if (!client) {
|
if (!connState.client) {
|
||||||
set({ error: "No active connection" })
|
set({ error: "No active connection" })
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the session in the SAME directory scope that loadSessions reads from.
|
||||||
|
// loadSessions lists home-scoped sessions when the connection has no explicit
|
||||||
|
// directory; creating via the plain connection client targets the server's CWD
|
||||||
|
// instead. When CWD != home the new session was invisible to the list (#10:
|
||||||
|
// "sessions tab empty after connect / create"). Mirror the list's scoping so a
|
||||||
|
// freshly created session reliably shows up.
|
||||||
|
const hasExplicitDirectory = Boolean(connState.activeConnection?.directory)
|
||||||
|
const home = connState.serverHome
|
||||||
|
const client =
|
||||||
|
!hasExplicitDirectory && home
|
||||||
|
? connState.clientForDirectory(home) || connState.client
|
||||||
|
: connState.client
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const session = await client.session.create({ title })
|
const session = await client.session.create({ title })
|
||||||
// Don't optimistically add to sessions list — let loadSessions() handle it
|
// Don't optimistically add to sessions list — let loadSessions() handle it
|
||||||
|
|||||||
Reference in New Issue
Block a user