fix: sync pending changes with active directory
Uses the effective directory for composer git status Prevents stale pending changes after commit or push Keeps the dropdown aligned with the git panel
This commit is contained in:
@@ -64,6 +64,7 @@ import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
|||||||
import { useSkillsStore } from '@/stores/useSkillsStore';
|
import { useSkillsStore } from '@/stores/useSkillsStore';
|
||||||
import { useCommandsStore } from '@/stores/useCommandsStore';
|
import { useCommandsStore } from '@/stores/useCommandsStore';
|
||||||
import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs';
|
import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs';
|
||||||
|
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
|
||||||
import { createWorktreeDraft } from '@/lib/worktreeSessionCreator';
|
import { createWorktreeDraft } from '@/lib/worktreeSessionCreator';
|
||||||
import { buildSessionTargetOptions } from '@/sync/session-worktree-contract';
|
import { buildSessionTargetOptions } from '@/sync/session-worktree-contract';
|
||||||
import { usePermissionStore } from '@/stores/permissionStore';
|
import { usePermissionStore } from '@/stores/permissionStore';
|
||||||
@@ -988,7 +989,8 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
|||||||
Promise.resolve((useSessionUIStore.getState().sendMessage as (...a: unknown[]) => unknown)(...args)),
|
Promise.resolve((useSessionUIStore.getState().sendMessage as (...a: unknown[]) => unknown)(...args)),
|
||||||
).current;
|
).current;
|
||||||
const currentSessionId = useSessionUIStore((s) => s.currentSessionId);
|
const currentSessionId = useSessionUIStore((s) => s.currentSessionId);
|
||||||
const currentDirectory = useDirectoryStore((s) => s.currentDirectory);
|
const fallbackDirectory = useDirectoryStore((s) => s.currentDirectory);
|
||||||
|
const currentDirectory = useEffectiveDirectory() ?? fallbackDirectory;
|
||||||
const currentSessionDirectoryForSync = useSessionUIStore(
|
const currentSessionDirectoryForSync = useSessionUIStore(
|
||||||
React.useCallback((s) => currentSessionId ? s.getDirectoryForSession(currentSessionId) : null, [currentSessionId]),
|
React.useCallback((s) => currentSessionId ? s.getDirectoryForSession(currentSessionId) : null, [currentSessionId]),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
|
||||||
import { useGitStore, useIsGitRepo } from '@/stores/useGitStore';
|
import { useGitStore, useIsGitRepo } from '@/stores/useGitStore';
|
||||||
import { useUIStore } from '@/stores/useUIStore';
|
import { useUIStore } from '@/stores/useUIStore';
|
||||||
import { RuntimeAPIContext } from '@/contexts/runtimeAPIContext';
|
import { RuntimeAPIContext } from '@/contexts/runtimeAPIContext';
|
||||||
import { useMobileAppActions } from '@/apps/mobileAppContext';
|
import { useMobileAppActions } from '@/apps/mobileAppContext';
|
||||||
|
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
|
||||||
import { Icon } from "@/components/icon/Icon";
|
import { Icon } from "@/components/icon/Icon";
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import {
|
import {
|
||||||
@@ -20,7 +20,7 @@ export const PendingChangesBar: React.FC = React.memo(() => {
|
|||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const [isExpanded, setIsExpanded] = React.useState(false);
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
||||||
const popoverRef = React.useRef<HTMLDivElement>(null);
|
const popoverRef = React.useRef<HTMLDivElement>(null);
|
||||||
const currentDirectory = useDirectoryStore((s) => s.currentDirectory);
|
const currentDirectory = useEffectiveDirectory() ?? null;
|
||||||
const runtime = React.useContext(RuntimeAPIContext);
|
const runtime = React.useContext(RuntimeAPIContext);
|
||||||
const isGitRepo = useIsGitRepo(currentDirectory);
|
const isGitRepo = useIsGitRepo(currentDirectory);
|
||||||
const gitStatus = useGitStore((s) =>
|
const gitStatus = useGitStore((s) =>
|
||||||
@@ -43,7 +43,7 @@ export const PendingChangesBar: React.FC = React.memo(() => {
|
|||||||
}, [isExpanded]);
|
}, [isExpanded]);
|
||||||
|
|
||||||
const gitChangedFiles = React.useMemo<GitChangedFile[]>(() => {
|
const gitChangedFiles = React.useMemo<GitChangedFile[]>(() => {
|
||||||
if (isGitRepo !== true || !gitStatus || gitStatus.isClean) return [];
|
if (!currentDirectory || isGitRepo !== true || !gitStatus || gitStatus.isClean) return [];
|
||||||
return extractGitChangedFiles(gitStatus.files, gitStatus.diffStats, currentDirectory);
|
return extractGitChangedFiles(gitStatus.files, gitStatus.diffStats, currentDirectory);
|
||||||
}, [isGitRepo, gitStatus, currentDirectory]);
|
}, [isGitRepo, gitStatus, currentDirectory]);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export const PendingChangesBar: React.FC = React.memo(() => {
|
|||||||
return { totalAdded: added, totalRemoved: removed };
|
return { totalAdded: added, totalRemoved: removed };
|
||||||
}, [gitChangedFiles]);
|
}, [gitChangedFiles]);
|
||||||
|
|
||||||
if (isGitRepo !== true) return null;
|
if (!currentDirectory || isGitRepo !== true) return null;
|
||||||
if (gitChangedFiles.length === 0) return null;
|
if (gitChangedFiles.length === 0) return null;
|
||||||
|
|
||||||
const handleOpenFile = (file: ChangedFileEntry) => {
|
const handleOpenFile = (file: ChangedFileEntry) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user