fix(sessions): keep created-session scope through navigation and send (#10)
createSession now stamps the scope directory onto the returned session, and the create-session navigation passes that directory to the detail screen. Previously a freshly created home-scoped session was opened/addressed with the default (CWD) client because the route carried no directory param — the same scope mismatch class as #10, on the open/send path instead of the list path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -188,7 +188,10 @@ export default function SessionsScreen() {
|
|||||||
const onCreateSession = async () => {
|
const onCreateSession = async () => {
|
||||||
const session = await createSession()
|
const session = await createSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
router.push(`/session/${session.id}`)
|
router.push({
|
||||||
|
pathname: `/session/[id]`,
|
||||||
|
params: { id: session.id, ...(session.directory ? { directory: session.directory } : {}) },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +230,10 @@ export default function SessionsScreen() {
|
|||||||
setShowNewSession(false)
|
setShowNewSession(false)
|
||||||
setCustomDir("")
|
setCustomDir("")
|
||||||
if (session) {
|
if (session) {
|
||||||
router.push(`/session/${session.id}`)
|
router.push({
|
||||||
|
pathname: `/session/[id]`,
|
||||||
|
params: { id: session.id, ...(session.directory ? { directory: session.directory } : {}) },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,12 @@ export const useSessions = create<SessionsState>((set, get) => ({
|
|||||||
const client = scopeDir ? connState.clientForDirectory(scopeDir) || connState.client : connState.client
|
const client = scopeDir ? connState.clientForDirectory(scopeDir) || connState.client : connState.client
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const session = await client.session.create({ title })
|
const created = await client.session.create({ title })
|
||||||
|
// Stamp the scope we created in onto the session so every downstream path
|
||||||
|
// (navigation params, selectSession, sendMessage's clientFor) addresses it
|
||||||
|
// in the SAME scope. Without this, opening/sending to a freshly created
|
||||||
|
// home-scoped session via the default client would hit the wrong scope (#10).
|
||||||
|
const session = scopeDir && !created.directory ? { ...created, directory: scopeDir } : created
|
||||||
// Don't optimistically add to sessions list — let loadSessions() handle it
|
// Don't optimistically add to sessions list — let loadSessions() handle it
|
||||||
// to avoid duplicate key errors from race conditions
|
// to avoid duplicate key errors from race conditions
|
||||||
set({
|
set({
|
||||||
|
|||||||
Reference in New Issue
Block a user