fix: scope session assist to session directory

This commit is contained in:
Bohdan Triapitsyn
2026-07-06 20:00:53 +03:00
parent 18d1c9111a
commit 1824b51155
6 changed files with 52 additions and 12 deletions
@@ -267,7 +267,7 @@ const ChatViewport = React.memo(({
</div>
)}
<SessionRecapNote sessionId={currentSessionId} isMobile={isMobile} />
<SessionRecapNote sessionId={currentSessionId} directory={directory} isMobile={isMobile} />
<div className="mb-3">
<StatusRowContainer />
@@ -4758,6 +4758,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
<div className="flex flex-col">
<SessionSuggestionChip
sessionId={currentSessionId}
directory={currentSessionDirectoryForSync ?? currentDirectory}
hidden={hasContent || newSessionDraftOpen}
onApply={applyAssistSuggestion}
className="mb-1.5"
@@ -4841,6 +4842,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
<>
<SessionSuggestionChip
sessionId={currentSessionId}
directory={currentSessionDirectoryForSync ?? currentDirectory}
hidden={hasContent || newSessionDraftOpen}
onApply={applyAssistSuggestion}
className="mb-1.5"
@@ -4,14 +4,15 @@ import { useI18n } from '@/lib/i18n';
interface SessionRecapNoteProps {
sessionId: string;
directory?: string;
isMobile: boolean;
}
// Quiet one-paragraph recap of the agent's last reply, rendered right under
// the last message (above the reserved bottom gap). Appears only after the
// 5-minute quiet window, so the layout shift happens off-screen in practice.
export const SessionRecapNote: React.FC<SessionRecapNoteProps> = React.memo(({ sessionId, isMobile }) => {
const { visibleRecap } = useSessionAssistState(sessionId);
export const SessionRecapNote: React.FC<SessionRecapNoteProps> = React.memo(({ sessionId, directory, isMobile }) => {
const { visibleRecap } = useSessionAssistState(sessionId, directory);
const { t } = useI18n();
if (!visibleRecap) {
@@ -8,6 +8,7 @@ import { useI18n } from '@/lib/i18n';
interface SessionSuggestionChipProps {
sessionId: string | null;
directory?: string;
/** The composer already has content — the suggestion must stay out of the way. */
hidden: boolean;
onApply: (text: string) => void;
@@ -20,8 +21,8 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>
// One small-model-suggested follow-up message, styled like the draft starter
// chips. Tapping it fills the composer (no auto-send); the X patches the
// suggestion out of the session metadata so it stays dismissed everywhere.
export const SessionSuggestionChip: React.FC<SessionSuggestionChipProps> = React.memo(({ sessionId, hidden, onApply, className }) => {
const { suggestion } = useSessionAssistState(sessionId ?? '');
export const SessionSuggestionChip: React.FC<SessionSuggestionChipProps> = React.memo(({ sessionId, directory, hidden, onApply, className }) => {
const { suggestion } = useSessionAssistState(sessionId ?? '', directory);
const { t } = useI18n();
const { currentTheme } = useThemeSystem();
const [dismissing, setDismissing] = React.useState(false);
+6 -6
View File
@@ -13,8 +13,8 @@ interface LastMessageSnapshot {
}
/** Narrow subscription to the last message of a session (id/role/time only). */
function useLastMessageSnapshot(sessionId: string): LastMessageSnapshot | null {
const store = useDirectoryStore();
function useLastMessageSnapshot(sessionId: string, directory?: string): LastMessageSnapshot | null {
const store = useDirectoryStore(directory);
const cacheRef = React.useRef<LastMessageSnapshot | null>(null);
const getSnapshot = React.useCallback((): LastMessageSnapshot | null => {
@@ -56,10 +56,10 @@ export interface SessionAssistState {
suggestion: string | null;
}
export function useSessionAssistState(sessionId: string): SessionAssistState {
const session = useSession(sessionId);
const status = useSessionStatus(sessionId);
const lastMessage = useLastMessageSnapshot(sessionId);
export function useSessionAssistState(sessionId: string, directory?: string): SessionAssistState {
const session = useSession(sessionId, directory);
const status = useSessionStatus(sessionId, directory);
const lastMessage = useLastMessageSnapshot(sessionId, directory);
const isIdle = !status || status.type === 'idle';
const payload = getSessionAssist(session);