Skip to content

Commit ac956ea

Browse files
committed
wip
Change-Id: I0ed1e02bbf9e2400a7bd15e7a2954d21351719cf Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 0ea1447 commit ac956ea

18 files changed

+910
-165
lines changed

eslint.config.mjs

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,208 @@ export default defineConfig([
365365
message:
366366
"Frontend code cannot import from utils/main/ (contains Node.js APIs). Move shared code to utils/ or use IPC.",
367367
},
368+
{
369+
group: ["node:*"],
370+
message:
371+
"Frontend code cannot import Node.js built-in modules (node:* imports). These modules are only available in the main process. Use window.api IPC calls to access Node.js functionality.",
372+
},
373+
],
374+
paths: [
375+
{
376+
name: "assert",
377+
message:
378+
"Frontend code cannot import Node.js 'assert' module. Use window.api IPC calls to access Node.js functionality.",
379+
},
380+
{
381+
name: "assert/strict",
382+
message:
383+
"Frontend code cannot import Node.js 'assert/strict' module. Use window.api IPC calls to access Node.js functionality.",
384+
},
385+
{
386+
name: "buffer",
387+
message:
388+
"Frontend code cannot import Node.js 'buffer' module. Use window.api IPC calls to access Node.js functionality.",
389+
},
390+
{
391+
name: "child_process",
392+
message:
393+
"Frontend code cannot import Node.js 'child_process' module. Use window.api IPC calls to access Node.js functionality.",
394+
},
395+
{
396+
name: "cluster",
397+
message:
398+
"Frontend code cannot import Node.js 'cluster' module. Use window.api IPC calls to access Node.js functionality.",
399+
},
400+
{
401+
name: "crypto",
402+
message:
403+
"Frontend code cannot import Node.js 'crypto' module. Use window.api IPC calls to access Node.js functionality.",
404+
},
405+
{
406+
name: "dgram",
407+
message:
408+
"Frontend code cannot import Node.js 'dgram' module. Use window.api IPC calls to access Node.js functionality.",
409+
},
410+
{
411+
name: "dns",
412+
message:
413+
"Frontend code cannot import Node.js 'dns' module. Use window.api IPC calls to access Node.js functionality.",
414+
},
415+
{
416+
name: "domain",
417+
message:
418+
"Frontend code cannot import Node.js 'domain' module. Use window.api IPC calls to access Node.js functionality.",
419+
},
420+
{
421+
name: "events",
422+
message:
423+
"Frontend code cannot import Node.js 'events' module. Use window.api IPC calls to access Node.js functionality.",
424+
},
425+
{
426+
name: "fs",
427+
message:
428+
"Frontend code cannot import Node.js 'fs' module. Use window.api IPC calls to access Node.js functionality.",
429+
},
430+
{
431+
name: "fs/promises",
432+
message:
433+
"Frontend code cannot import Node.js 'fs/promises' module. Use window.api IPC calls to access Node.js functionality.",
434+
},
435+
{
436+
name: "http",
437+
message:
438+
"Frontend code cannot import Node.js 'http' module. Use window.api IPC calls to access Node.js functionality.",
439+
},
440+
{
441+
name: "http2",
442+
message:
443+
"Frontend code cannot import Node.js 'http2' module. Use window.api IPC calls to access Node.js functionality.",
444+
},
445+
{
446+
name: "https",
447+
message:
448+
"Frontend code cannot import Node.js 'https' module. Use window.api IPC calls to access Node.js functionality.",
449+
},
450+
{
451+
name: "inspector",
452+
message:
453+
"Frontend code cannot import Node.js 'inspector' module. Use window.api IPC calls to access Node.js functionality.",
454+
},
455+
{
456+
name: "module",
457+
message:
458+
"Frontend code cannot import Node.js 'module' module. Use window.api IPC calls to access Node.js functionality.",
459+
},
460+
{
461+
name: "net",
462+
message:
463+
"Frontend code cannot import Node.js 'net' module. Use window.api IPC calls to access Node.js functionality.",
464+
},
465+
{
466+
name: "os",
467+
message:
468+
"Frontend code cannot import Node.js 'os' module. Use window.api IPC calls to access Node.js functionality.",
469+
},
470+
{
471+
name: "path",
472+
message:
473+
"Frontend code cannot import Node.js 'path' module. Use window.api IPC calls to access Node.js functionality.",
474+
},
475+
{
476+
name: "perf_hooks",
477+
message:
478+
"Frontend code cannot import Node.js 'perf_hooks' module. Use window.api IPC calls to access Node.js functionality.",
479+
},
480+
{
481+
name: "process",
482+
message:
483+
"Frontend code cannot import Node.js 'process' module. Use window.api IPC calls to access Node.js functionality.",
484+
},
485+
{
486+
name: "punycode",
487+
message:
488+
"Frontend code cannot import Node.js 'punycode' module. Use window.api IPC calls to access Node.js functionality.",
489+
},
490+
{
491+
name: "querystring",
492+
message:
493+
"Frontend code cannot import Node.js 'querystring' module. Use window.api IPC calls to access Node.js functionality.",
494+
},
495+
{
496+
name: "readline",
497+
message:
498+
"Frontend code cannot import Node.js 'readline' module. Use window.api IPC calls to access Node.js functionality.",
499+
},
500+
{
501+
name: "repl",
502+
message:
503+
"Frontend code cannot import Node.js 'repl' module. Use window.api IPC calls to access Node.js functionality.",
504+
},
505+
{
506+
name: "stream",
507+
message:
508+
"Frontend code cannot import Node.js 'stream' module. Use window.api IPC calls to access Node.js functionality.",
509+
},
510+
{
511+
name: "string_decoder",
512+
message:
513+
"Frontend code cannot import Node.js 'string_decoder' module. Use window.api IPC calls to access Node.js functionality.",
514+
},
515+
{
516+
name: "sys",
517+
message:
518+
"Frontend code cannot import Node.js 'sys' module. Use window.api IPC calls to access Node.js functionality.",
519+
},
520+
{
521+
name: "timers",
522+
message:
523+
"Frontend code cannot import Node.js 'timers' module. Use window.api IPC calls to access Node.js functionality.",
524+
},
525+
{
526+
name: "tls",
527+
message:
528+
"Frontend code cannot import Node.js 'tls' module. Use window.api IPC calls to access Node.js functionality.",
529+
},
530+
{
531+
name: "trace_events",
532+
message:
533+
"Frontend code cannot import Node.js 'trace_events' module. Use window.api IPC calls to access Node.js functionality.",
534+
},
535+
{
536+
name: "tty",
537+
message:
538+
"Frontend code cannot import Node.js 'tty' module. Use window.api IPC calls to access Node.js functionality.",
539+
},
540+
{
541+
name: "url",
542+
message:
543+
"Frontend code cannot import Node.js 'url' module. Use window.api IPC calls to access Node.js functionality.",
544+
},
545+
{
546+
name: "util",
547+
message:
548+
"Frontend code cannot import Node.js 'util' module. Use window.api IPC calls to access Node.js functionality.",
549+
},
550+
{
551+
name: "v8",
552+
message:
553+
"Frontend code cannot import Node.js 'v8' module. Use window.api IPC calls to access Node.js functionality.",
554+
},
555+
{
556+
name: "vm",
557+
message:
558+
"Frontend code cannot import Node.js 'vm' module. Use window.api IPC calls to access Node.js functionality.",
559+
},
560+
{
561+
name: "worker_threads",
562+
message:
563+
"Frontend code cannot import Node.js 'worker_threads' module. Use window.api IPC calls to access Node.js functionality.",
564+
},
565+
{
566+
name: "zlib",
567+
message:
568+
"Frontend code cannot import Node.js 'zlib' module. Use window.api IPC calls to access Node.js functionality.",
569+
},
368570
],
369571
},
370572
],

src/components/GitStatusIndicator.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React, { useCallback, useEffect, useRef, useState } from "react";
1+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
22
import type { GitStatus } from "@/types/workspace";
33
import { GitStatusIndicatorView } from "./GitStatusIndicatorView";
44
import { useGitBranchDetails } from "./hooks/useGitBranchDetails";
5-
import { strict as assert } from "node:assert";
5+
import { assert } from "@/utils/assert";
6+
import { getSendOptionsFromStorage } from "@/utils/messages/sendOptions";
67

78
interface GitStatusIndicatorProps {
89
gitStatus: GitStatus | null;
@@ -31,6 +32,8 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
3132
const containerRef = useRef<HTMLSpanElement | null>(null);
3233
const [isRebasing, setIsRebasing] = useState(false);
3334
const [rebaseError, setRebaseError] = useState<string | null>(null);
35+
const [isAgentResolving, setIsAgentResolving] = useState(false);
36+
const [agentConflictFiles, setAgentConflictFiles] = useState<string[]>([]);
3437

3538
const trimmedWorkspaceId = workspaceId.trim();
3639
assert(
@@ -41,6 +44,13 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
4144
const { branchHeaders, commits, dirtyFiles, isLoading, errorMessage, invalidateCache, refresh } =
4245
useGitBranchDetails(trimmedWorkspaceId, gitStatus, showTooltip);
4346

47+
// Get send message options to pass to auto-triggered agent on rebase failure
48+
// Uses storage directly (no context) to work in sidebar without ThinkingProvider
49+
const sendMessageOptions = useMemo(
50+
() => getSendOptionsFromStorage(trimmedWorkspaceId),
51+
[trimmedWorkspaceId]
52+
);
53+
4454
const cancelHideTimeout = () => {
4555
if (hideTimeoutRef.current) {
4656
clearTimeout(hideTimeoutRef.current);
@@ -98,7 +108,7 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
98108
setRebaseError(null);
99109

100110
try {
101-
const result = await window.api?.workspace?.rebase?.(trimmedWorkspaceId);
111+
const result = await window.api?.workspace?.rebase?.(trimmedWorkspaceId, sendMessageOptions);
102112

103113
assert(
104114
typeof result !== "undefined",
@@ -120,6 +130,15 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
120130

121131
invalidateCache();
122132

133+
// If agent is resolving, don't show error - let user know agent is working
134+
if (result.status === "resolving") {
135+
setIsAgentResolving(true);
136+
setAgentConflictFiles(result.conflictFiles ?? []);
137+
// Don't show error - agent is handling it
138+
return;
139+
}
140+
141+
// Only show errors for conflicts/aborted if agent is NOT resolving
123142
if (result.status === "conflicts") {
124143
setRebaseError(
125144
result.error ??
@@ -142,6 +161,7 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
142161
refresh,
143162
showTooltip,
144163
trimmedWorkspaceId,
164+
sendMessageOptions,
145165
]);
146166

147167
const triggerRebase = useCallback(() => {
@@ -160,6 +180,21 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
160180
}
161181
}, [gitStatus]);
162182

183+
// Clear resolving state when agent finishes (streaming stops)
184+
useEffect(() => {
185+
if (isAgentResolving && !isStreaming) {
186+
// Agent finished streaming - check if rebase succeeded
187+
setIsAgentResolving(false);
188+
setAgentConflictFiles([]); // Clear conflict files
189+
190+
// If still behind after agent finished, it failed to resolve
191+
if (gitStatus && gitStatus.behind > 0) {
192+
setRebaseError("Agent couldn't fully resolve the conflicts. Check chat for details.");
193+
}
194+
// If behind === 0, agent succeeded - git status effect will clear error
195+
}
196+
}, [isAgentResolving, isStreaming, gitStatus]);
197+
163198
return (
164199
<GitStatusIndicatorView
165200
gitStatus={gitStatus}
@@ -178,6 +213,8 @@ export const GitStatusIndicator: React.FC<GitStatusIndicatorProps> = ({
178213
onContainerRef={handleContainerRef}
179214
canRebase={canRebase}
180215
isRebasing={isRebasing}
216+
isAgentResolving={isAgentResolving}
217+
agentConflictFiles={isAgentResolving ? agentConflictFiles : null}
181218
onRebaseClick={triggerRebase}
182219
rebaseError={rebaseError}
183220
/>

0 commit comments

Comments
 (0)