Skip to content

Commit a2621b9

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

18 files changed

+907
-178
lines changed

eslint.config.mjs

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

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)