fix: simplify walkthrough prompt requests (#1660)
* fix: simplify walkthrough prompt requests * fix: address walkthrough review feedback
This commit is contained in:
@@ -27,8 +27,6 @@ import {
|
||||
buildRepoNameById,
|
||||
} from "./changes-panel-helpers";
|
||||
import type { OpenDiffOptions } from "./changes-diff-target";
|
||||
import type { WalkthroughPromptFile } from "@/lib/walkthrough-request";
|
||||
import { buildWalkthroughPromptFiles } from "@/lib/walkthrough-prompt-files";
|
||||
|
||||
function useChangesPanelStoreData() {
|
||||
const activeTaskId = useAppStore((state) => state.tasks.activeTaskId);
|
||||
@@ -211,6 +209,10 @@ function useChangesPanelPRData() {
|
||||
return { prDiffFiles, prCommitsList, hasPRFiles, hasPRCommits, prFiles };
|
||||
}
|
||||
|
||||
function hasCumulativeFiles(files: Record<string, unknown> | null | undefined): boolean {
|
||||
return Object.keys(files ?? {}).length > 0;
|
||||
}
|
||||
|
||||
export function useChangesPanelData() {
|
||||
const { activeTaskId, activeSessionId, baseBranch, existingPrUrl } = useChangesPanelStoreData();
|
||||
const baseBranchByRepo = useBaseBranchByRepo(activeTaskId);
|
||||
@@ -244,16 +246,11 @@ export function useChangesPanelData() {
|
||||
() => buildPrByRepoMap(taskPRsForMap, repoNameById, pendingByRepo),
|
||||
[taskPRsForMap, repoNameById, pendingByRepo],
|
||||
);
|
||||
const walkthroughPromptFiles = useMemo<WalkthroughPromptFile[]>(
|
||||
() =>
|
||||
buildWalkthroughPromptFiles({
|
||||
unstagedFiles,
|
||||
stagedFiles,
|
||||
committedFiles: git.statusLoaded ? git.cumulativeDiff?.files : null,
|
||||
prFiles: prData.prFiles,
|
||||
}),
|
||||
[git.cumulativeDiff?.files, git.statusLoaded, prData.prFiles, stagedFiles, unstagedFiles],
|
||||
);
|
||||
const walkthroughRequestReady =
|
||||
unstagedFiles.length > 0 ||
|
||||
stagedFiles.length > 0 ||
|
||||
(git.statusLoaded && hasCumulativeFiles(git.cumulativeDiff?.files)) ||
|
||||
prData.prFiles.length > 0;
|
||||
return {
|
||||
activeTaskId,
|
||||
activeSessionId,
|
||||
@@ -272,7 +269,7 @@ export function useChangesPanelData() {
|
||||
repoDisplayName,
|
||||
prByRepo,
|
||||
existingPrUrl,
|
||||
walkthroughPromptFiles,
|
||||
walkthroughRequestReady,
|
||||
...prData,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ const ChangesPanel = memo(function ChangesPanel(props: ChangesPanelProps) {
|
||||
const requestWalkthrough = useRequestChangesWalkthrough({
|
||||
taskId: data.activeTaskId,
|
||||
sessionId: data.activeSessionId,
|
||||
files: data.walkthroughPromptFiles,
|
||||
ready: data.walkthroughRequestReady,
|
||||
});
|
||||
if (isArchived) return <ArchivedPanelPlaceholder />;
|
||||
return (
|
||||
@@ -44,7 +44,7 @@ const ChangesPanel = memo(function ChangesPanel(props: ChangesPanelProps) {
|
||||
onOpenDiffAll={props.onOpenDiffAll}
|
||||
onOpenReview={props.onOpenReview}
|
||||
onRequestWalkthrough={requestWalkthrough}
|
||||
requestWalkthroughDisabled={data.walkthroughPromptFiles.length === 0}
|
||||
requestWalkthroughDisabled={!data.walkthroughRequestReady}
|
||||
repoNames={data.git.repoNames}
|
||||
perRepoStatus={data.git.perRepoStatus}
|
||||
onRepoPull={data.repoCallbacks.onRepoPull}
|
||||
|
||||
@@ -38,7 +38,7 @@ export const MobileChangesPanel = memo(function MobileChangesPanel({
|
||||
const requestWalkthrough = useRequestChangesWalkthrough({
|
||||
taskId: data.activeTaskId,
|
||||
sessionId: data.activeSessionId,
|
||||
files: data.walkthroughPromptFiles,
|
||||
ready: data.walkthroughRequestReady,
|
||||
});
|
||||
|
||||
// Track the previous selectedDiff to detect changes
|
||||
@@ -107,7 +107,7 @@ export const MobileChangesPanel = memo(function MobileChangesPanel({
|
||||
onOpenDiffAll={handleOpenDiffAll}
|
||||
onOpenReview={handleOpenReview}
|
||||
onRequestWalkthrough={requestWalkthrough}
|
||||
requestWalkthroughDisabled={data.walkthroughPromptFiles.length === 0}
|
||||
requestWalkthroughDisabled={!data.walkthroughRequestReady}
|
||||
repoNames={data.git.repoNames}
|
||||
perRepoStatus={data.git.perRepoStatus}
|
||||
onRepoPull={data.repoCallbacks.onRepoPull}
|
||||
|
||||
@@ -169,15 +169,12 @@ function persistAutoMarkSetting(checked: boolean) {
|
||||
updateUserSettings(payload, { cache: "no-store" }).catch(() => {});
|
||||
}
|
||||
|
||||
function useReviewWalkthroughRequest(
|
||||
activeSessionId: string | null | undefined,
|
||||
allFiles: ReviewFile[],
|
||||
) {
|
||||
function useWalkthroughRequest(activeSessionId: string | null | undefined, allFiles: ReviewFile[]) {
|
||||
const activeTaskId = useAppStore((s) => s.tasks.activeTaskId);
|
||||
return useRequestChangesWalkthrough({
|
||||
taskId: activeTaskId,
|
||||
sessionId: activeSessionId,
|
||||
files: allFiles,
|
||||
ready: allFiles.length > 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -485,7 +482,7 @@ const TaskChangesPanel = memo(function TaskChangesPanel({
|
||||
handleToggleAutoMark,
|
||||
handleFixComments,
|
||||
} = useChangesActions(activeSessionId, allFiles, wordWrapProp);
|
||||
const handleRequestWalkthrough = useReviewWalkthroughRequest(activeSessionId, allFiles);
|
||||
const handleRequestWalkthrough = useWalkthroughRequest(activeSessionId, allFiles);
|
||||
const { visibleFiles, visibleFileRefs, reviewedCount, totalCount, progressPercent } =
|
||||
useVisibleDiffState({
|
||||
allFiles,
|
||||
|
||||
Reference in New Issue
Block a user