Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- When the user says "add, commit", group all existing changes into logical sets, stage and commit each group, and repeat until every change is committed and the working tree is clean.
- Always make changes on a descriptively named task branch, never on `main`. At the start of every new work request, check the current Git branch before changing any file; if the current branch is `main`, create and switch to the task branch first.
- Never push work directly to `main`. If `main` already contains uncommitted changes or commits that have not been pushed, create the task branch from its current state so all of that work moves forward on the new branch, then continue the normal workflow there.
- Treat "release" as exactly equivalent to "add, commit, push, pr, merge" and complete the same full delivery workflow.
- When the user says "add, commit, push, pr, merge" or otherwise confirms that the work is ready, complete the delivery workflow in order: group and commit all changes until the tree is clean, run `bun run ci` for the exact commit being delivered, push the task branch, open a pull request targeting `main`, and merge the pull request without depending on GitHub Actions while it is unavailable. If local CI fails or the pull request cannot merge, fix the problem on the same task branch and repeat the relevant steps.
- Keep React component modules compatible with Vite Fast Refresh: export only React components from component files, and move non-component runtime exports such as constants, helpers, and metadata into separate modules to avoid incompatible-export invalidations.
- Record every new user-facing feature in the README as part of implementing it.
8 changes: 1 addition & 7 deletions src/components/session-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function SessionHistory({
selectSession: selectHistorySession,
summaries,
total,
} = useSessionHistory(open, requestedSessionId);
} = useSessionHistory(open, requestedSessionId, onSelectSessionId);
const [storedHistoryView, setStoredHistoryView] =
useState<SessionHistoryView>(loadSessionHistoryView);
const historyView = requestedView ?? storedHistoryView;
Expand Down Expand Up @@ -128,12 +128,6 @@ export function SessionHistory({
const navigationSummaries =
historyView === SESSION_HISTORY_VIEW.CALENDAR ? calendarSummaries : summaries;

useEffect(() => {
if (open && selected) {
onSelectSessionId?.(selected.id);
}
}, [onSelectSessionId, open, selected]);

useEffect(() => {
if (!open) {
setDeleteConfirmationOpen(false);
Expand Down
22 changes: 16 additions & 6 deletions src/hooks/use-session-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import type { SavedSession, SavedSessionSummary } from '../types';

const PAGE_SIZE = 30;

export function useSessionHistory(open: boolean, preferredSessionId?: string) {
export function useSessionHistory(
open: boolean,
preferredSessionId?: string,
onSelectSessionId?: (sessionId: string) => void
) {
const [summaries, setSummaries] = useState<SavedSessionSummary[]>([]);
const [total, setTotal] = useState(0);
const [selected, setSelected] = useState<SavedSession>();
Expand All @@ -40,11 +44,17 @@ export function useSessionHistory(open: boolean, preferredSessionId?: string) {
const historyLoadGeneration = useRef(0);
const historyInitialized = useRef(false);

const rememberSelectedSession = useCallback((id: string | undefined) => {
selectedIdRef.current = id;
setSelectedId(id);
saveSelectedSessionId(id);
}, []);
const rememberSelectedSession = useCallback(
(id: string | undefined) => {
selectedIdRef.current = id;
setSelectedId(id);
saveSelectedSessionId(id);
if (id) {
onSelectSessionId?.(id);
}
},
[onSelectSessionId]
);

const selectSession = useCallback(
async (id: string) => {
Expand Down