diff --git a/ui/desktop/src/components/SessionPills.tsx b/ui/desktop/src/components/SessionPills.tsx index c95eb01f9..085583f3e 100644 --- a/ui/desktop/src/components/SessionPills.tsx +++ b/ui/desktop/src/components/SessionPills.tsx @@ -16,38 +16,45 @@ const useCombinedSessions = (workingDir: string) => { const getCombinedSessions = () => { if (sessions.length === 0 && latestSessions.length === 0) { - return []; + return { currentDirSessions: [], otherLocationSessions: [] }; } - const combinedSessions = []; + const currentDirSessions = []; + const otherLocationSessions = []; const seenNames = new Set(); - // Add at least one latest session if available - if (latestSessions.length > 0) { - const latest = latestSessions[0]; - combinedSessions.push({ ...latest, isLatest: true }); - seenNames.add(latest.name); - } - - // Add remaining latest sessions (up to 5 total) - for (let i = 1; i < latestSessions.length && combinedSessions.length < 5; i++) { - const session = latestSessions[i]; + // Process latest sessions first + for (const session of latestSessions) { if (!seenNames.has(session.name)) { - combinedSessions.push({ ...session, isLatest: true }); + if (session.directory === workingDir) { + currentDirSessions.push({ ...session, isLatest: true }); + } else { + otherLocationSessions.push({ ...session, isLatest: true }); + } seenNames.add(session.name); } } - // Fill remaining slots with regular sessions (up to 5 total) + // Process regular sessions for (const session of sessions) { - if (combinedSessions.length >= 5) break; if (!seenNames.has(session.name)) { - combinedSessions.push({ ...session, isLatest: false }); + if (session.directory === workingDir) { + currentDirSessions.push({ ...session, isLatest: false }); + } else { + otherLocationSessions.push({ ...session, isLatest: false }); + } seenNames.add(session.name); } } - return combinedSessions; + // Sort sessions by name + currentDirSessions.sort((a, b) => a.name.localeCompare(b.name)); + otherLocationSessions.sort((a, b) => a.name.localeCompare(b.name)); + + return { + currentDirSessions: currentDirSessions.slice(0, 5), + otherLocationSessions: otherLocationSessions.slice(0, 5) + }; }; return getCombinedSessions(); @@ -55,31 +62,52 @@ const useCombinedSessions = (workingDir: string) => { export default function SessionPills() { const workingDir = window.appConfig.get("GOOSE_WORKING_DIR"); - const combinedSessions = useCombinedSessions(workingDir); + const { currentDirSessions, otherLocationSessions } = useCombinedSessions(workingDir); - if (combinedSessions.length === 0) { + if (currentDirSessions.length === 0 && otherLocationSessions.length === 0) { return null; } + const SessionPill = ({ session }) => ( +
{ + window.electron.createChatWindow(undefined, session.directory, session.name); + }} + title={session.directory} + > +
{`${session.name.slice(0, 50)}`}
+ {session.directory !== workingDir && ( +
{session.directory}
+ )} +
+ ); + return ( -
-
- {combinedSessions.map((session) => ( -
{ - window.electron.createChatWindow(undefined, session.directory, session.name); - }} - title={session.directory} - > - {`${session.name.slice(0, 50)}`} - {session.isLatest && !(session.directory === workingDir) && ( - (recent) +
+ {currentDirSessions.length > 0 && ( +
+

Recent sessions in + this directory

+
+ {currentDirSessions.map((session) => ( + + ))} +
+
)} -
- ))} -
-
- ) -} \ No newline at end of file + {otherLocationSessions.length > 0 && ( +
+

Recent sessions in other + locations

+
+ {otherLocationSessions.map((session) => ( + + ))} +
+
+ )} +
+ ); +} diff --git a/ui/desktop/src/components/Splash.tsx b/ui/desktop/src/components/Splash.tsx index 10dc19326..575e5b136 100644 --- a/ui/desktop/src/components/Splash.tsx +++ b/ui/desktop/src/components/Splash.tsx @@ -30,13 +30,14 @@ export default function Splash({ append }) {
- - -
- -
+ -
+
+
+ +
{ window.electron.directoryChooser(); @@ -55,4 +56,3 @@ export default function Splash({ append }) {
) } -