Repository navigation
Fix moved session project context - #88
Conversation
PR Review: Fix moved session project contextConfidence Score: 4/5 The PR is well-structured with thorough test coverage. The architecture cleanly separates the concept of a session's "native" (original) project directory from its "assigned" (moved-to) directory, with optimistic UI updates and a system-append notice mechanism for context changes. Issues Detected1. Race condition in optimistic meta cleanup ( The cleanup effect compares committed // Only compares 3 fields - but meta has 11+ fields
if (
committedMeta?.originMode === optimisticMeta.originMode &&
normalizeProjectPath(committedMeta?.assignedProjectDir ?? "") ===
normalizeProjectPath(optimisticMeta.assignedProjectDir ?? "") &&
committedMeta?.detachedFromProject === optimisticMeta.detachedFromProject
) {
delete next[sessionId];
}2. UI flicker during rapid re-moves (
// Error from stale in-flight op clears the latest optimistic meta
} catch (error) {
setOptimisticSessionMeta((current) => {
const { [sessionId]: _removed, ...rest } = current;
return rest;
});
throw error;
}3. Missing The returned // Returns only directory + workspaceId — no baseUrl
export function getSessionProjectTarget(
session: Session | undefined | null,
meta?: SessionMeta,
): ProjectTarget | null {
const directory = getEffectiveSessionDirectory(session, meta);
if (!directory) return null;
return {
directory,
workspaceId: getSessionWorkspaceId(session) ?? undefined,
};
}4.
const lookup = (sessionId: string) => {
const state = getState();
return getSessionLookup(
state.sessions.find((session) => session.id === sessionId),
state.sessionMeta, // from same snapshot — OK for single call
);
};5. The // Only clears the flag when the notice is generated
metaPatch: {
pendingDirectoryChangeNotice: false,
hideSystemAppendBlocks: true,
}Suggestions
|

Summary
Testing