MCPcopy
hub / github.com/21st-dev/1code / ChangesView

Function ChangesView

src/renderer/features/changes/changes-view.tsx:269–1102  ·  view source on GitHub ↗
({
	worktreePath,
	activeTab: controlledActiveTab,
	selectedFilePath,
	onFileSelect: onFileSelectProp,
	onFileOpenPinned,
	onCreatePr,
	onCommitSuccess,
	onDiscardSuccess,
	subChats = [],
	initialSubChatFilter = null,
	chatId,
	selectedCommitHash,
	onCommitSelect,
	onCommitFileSelect,
	onActiveTabChange,
	pushCount,
}: ChangesViewProps)

Source from the content-addressed store, hash-verified

267}
268
269export function ChangesView({
270 worktreePath,
271 activeTab: controlledActiveTab,
272 selectedFilePath,
273 onFileSelect: onFileSelectProp,
274 onFileOpenPinned,
275 onCreatePr,
276 onCommitSuccess,
277 onDiscardSuccess,
278 subChats = [],
279 initialSubChatFilter = null,
280 chatId,
281 selectedCommitHash,
282 onCommitSelect,
283 onCommitFileSelect,
284 onActiveTabChange,
285 pushCount,
286}: ChangesViewProps) {
287 useFileChangeListener(worktreePath);
288
289 // Viewed files state from agents diff view (for showing eye icon and toggling)
290 const [viewedFiles, setViewedFiles] = useAtom(viewedFilesAtomFamily(chatId || ""));
291
292 const { baseBranch } = useChangesStore();
293 const { data: branchData } = trpc.changes.getBranches.useQuery(
294 { worktreePath: worktreePath || "" },
295 { enabled: !!worktreePath },
296 );
297
298 const effectiveBaseBranch = baseBranch ?? branchData?.defaultBranch ?? "main";
299
300 const {
301 data: status,
302 isLoading,
303 refetch,
304 } = trpc.changes.getStatus.useQuery(
305 { worktreePath: worktreePath || "", defaultBranch: effectiveBaseBranch },
306 {
307 enabled: !!worktreePath,
308 refetchOnWindowFocus: true,
309 // Use default staleTime (5000ms) - GitWatcher handles real-time invalidation
310 },
311 );
312
313 const { pr, refetch: refetchPRStatus } = usePRStatus({
314 worktreePath,
315 refetchInterval: 10000,
316 });
317
318 const handleRefresh = () => {
319 refetch();
320 refetchPRStatus();
321 };
322
323 // Handle successful commit - reset local state and notify parent
324 const handleCommitSuccess = useCallback(() => {
325 // Clear commit selection without re-initializing auto-select
326 // (prevents remaining files from being re-selected after commit)

Callers

nothing calls this directly

Calls 12

useFileChangeListenerFunction · 0.90
usePRStatusFunction · 0.90
handleFileSelectFunction · 0.85
handleCheckboxChangeFunction · 0.85
handleFileDoubleClickFunction · 0.70
handleCopyPathFunction · 0.70
handleCopyRelativePathFunction · 0.70
handleRevealInFinderFunction · 0.70
handleOpenInFilePreviewFunction · 0.70
hasMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected