A desktop coding agent with free access to frontier models.
TypeScript
fix: in-app replace confirm and agent hand-off before a chat exists
ogsamrat5c4f8d271720
diff --git a/apps/app/src/react-app/domains/session/editor/chat-context.ts b/apps/app/src/react-app/domains/session/editor/chat-context.tsindex d145727d..0916f4ae 100644--- a/apps/app/src/react-app/domains/session/editor/chat-context.ts+++ b/apps/app/src/react-app/domains/session/editor/chat-context.ts@@ -8,6 +8,9 @@import { useComposerStateStore } from "../surface/composer-state-store";import { useEditorStore } from "./editor-store";+/** Fired with the text for the new-task composer; the composer calls preventDefault() when it took it. */+export const NEW_TASK_PREFILL_EVENT = "omnirush:new-task-prefill";+export type ChatContextChip = {/** What the chip shows: `src/orders.ts L5–6 · selection` (no square brackets). */label: string;@@ -18,7 +21,16 @@ export type ChatContextChip = {export type ChatHandoffResult = { ok: true } | { ok: false; reason: string };export function sendToChat(sessionId: string | null, instruction: string, chips: ChatContextChip[]): ChatHandoffResult {- if (!sessionId) return { ok: false, reason: "Open or start a chat first." };+ if (!sessionId) {+ // No chat yet: the new-task composer takes it as plain text (it has no chips). Unhandled = no composer on screen.+ const text = [instruction, ...chips.map((chip) => chip.text)].filter(Boolean).join("\n\n");+ const event = new CustomEvent(NEW_TASK_PREFILL_EVENT, { detail: text, cancelable: true });+ if (!window.dispatchEvent(event)) {+ useEditorStore.getState().setIdeChatCollapsed(false);+ return { ok: true };+ }+ return { ok: false, reason: "Open or start a chat first." };+ }const store = useComposerStateStore.getState();const state = store.sessions[sessionId];const draft = state?.draft ?? "";diff --git a/apps/app/src/react-app/domains/session/editor/search-view.tsx b/apps/app/src/react-app/domains/session/editor/search-view.tsxindex 7b9faf73..0491a31e 100644--- a/apps/app/src/react-app/domains/session/editor/search-view.tsx+++ b/apps/app/src/react-app/domains/session/editor/search-view.tsx@@ -12,6 +12,7 @@ import type { OmniRushEditorSearchResult, OmniRushServerClient } from "@/app/libimport { Button } from "@/components/ui/button";import { toast } from "@/components/ui/sonner";import { cn } from "@/lib/utils";+import { ConfirmModal } from "@/react-app/design-system/modals/confirm-modal";import type { EditorDocuments } from "./editor-models";type Flags = { regex: boolean; caseSensitive: boolean; wholeWord: boolean };@@ -59,6 +60,7 @@ export function SearchView(props: {const [rerun, setRerun] = useState(0);const [collapsed, setCollapsed] = useState<Record<string, true>>({});const [dismissed, setDismissed] = useState<Record<string, true>>({});+ const [confirming, setConfirming] = useState(false);const inputRef = useRef<HTMLInputElement | null>(null);const abortRef = useRef<AbortController | null>(null);@@ -173,8 +175,10 @@ export function SearchView(props: {const replaceAll = () => {if (!total) return;- const files = visible.length;- if (!window.confirm(`Replace ${total} match${total === 1 ? "" : "es"} in ${files} file${files === 1 ? "" : "s"} with "${replace}"? Each file can be undone in the editor.`)) return;+ setConfirming(true);+ };+ const confirmReplaceAll = () => {+ setConfirming(false);void apply(visible.flatMap((file) => file.matches.map((match) => absoluteTarget(file.path, match))));};@@ -194,6 +198,15 @@ export function SearchView(props: {return (<div className="flex h-full min-h-0 flex-col text-xs" data-editor-search>+ <ConfirmModal+ open={confirming}+ title="Replace all?"+ message={`Replace ${total} match${total === 1 ? "" : "es"} in ${visible.length} file${visible.length === 1 ? "" : "s"} with "${replace}"? The files are saved; each one can be undone in the editor.`}+ confirmLabel="Replace all"+ cancelLabel="Cancel"+ onConfirm={confirmReplaceAll}+ onCancel={() => setConfirming(false)}+ /><div className="flex shrink-0 flex-col gap-1 p-2"><div className="flex items-start gap-1"><button