A desktop coding agent with free access to frontier models.
TypeScript
fix: work chats drop coding extras and stay out of code mode
ogsamrat03b9e52e3242
diff --git a/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx b/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsxindex 81cc0061..ac59b278 100644--- a/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx+++ b/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx@@ -15,6 +15,7 @@ import { Button } from "@/components/ui/button";import { t } from "@/i18n";import { displayRuntimeBrand } from "@/lib/display-runtime-brand";import type { PendingPermission } from "@/app/types";+import { workToolPermission } from "@/react-app/domains/work/work-mode";type PermissionPresentation = {title: string;@@ -250,6 +251,19 @@ function describePermissionRequest(permission: PendingPermission): PermissionPre};}+ // Work connector tools (domains/work): the action and the account in words, not `omnirush-work_gmail_send` and `*`.+ const work = workToolPermission(permission.permission);+ if (work) {+ return {+ title: t("session.permission_title_generic", undefined, { permission: work.label }),+ message: t("session.permission_message"),+ permissionLabel: work.label,+ scopeLabel: t("session.scope_label"),+ scopeValue: work.scope,+ isDoomLoop: false,+ note: null,+ };+ }const copy = permissionCopy(permission.permission);return {title: copy.title,diff --git a/apps/app/src/react-app/domains/session/chat/session-page.tsx b/apps/app/src/react-app/domains/session/chat/session-page.tsxindex 42459b2f..4fdd7c98 100644--- a/apps/app/src/react-app/domains/session/chat/session-page.tsx+++ b/apps/app/src/react-app/domains/session/chat/session-page.tsx@@ -1947,6 +1947,7 @@ export function SessionPage(props: SessionPageProps) {safeStringify={props.safeStringify}onOpenTarget={props.surface?.onOpenTarget ?? openTarget}onOpenSubagentSession={openSubagentSession}+ workChat={props.workChat}/></div></div>diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsxindex e6a4472e..ed08c11f 100644--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx@@ -587,6 +587,8 @@ function createImageLightboxEvalMessages(sessionId: string): UIMessage[] {}export type SessionSurfaceProps = {+ /** A Work mode chat (domains/work): no coding checklist and no sub-agent model picker. */+ workChat?: boolean;/** OmniRush GUI has no MCP capability. */mcpDisabled?: boolean;client: OmniRushServerClient;@@ -3677,7 +3679,7 @@ export function SessionSurface(props: SessionSurfaceProps) {onCheckAcceptance={() => void checkUnknownAdmission(true)}onStop={async () => { await handleAbort(); }}/>- <GoodSessionChecklistBar+ {props.workChat ? null : <GoodSessionChecklistBarsessionId={props.sessionId}messages={renderedMessages}workspaceRoot={props.workspaceRoot}@@ -3686,7 +3688,7 @@ export function SessionSurface(props: SessionSurfaceProps) {onFinishIt={handleMessageListSetPrompt}onAutoRetry={handleAutoRetry}client={props.client}- />+ />}<PlacementTurnFootersessionId={props.sessionId}turnRunning={chatStreaming || (effectiveActivityStatus !== "idle" && effectiveActivityStatus !== "error")}@@ -3696,7 +3698,7 @@ export function SessionSurface(props: SessionSurfaceProps) {runModeControl={<WorkspaceRunModeMenu client={props.client} workspaceId={props.workspaceId} busy={chatStreaming || preparingCloudTools || Boolean(props.activePermission || props.activeQuestion)} />}fullPermissionsControl={<FullPermissionsToggle client={props.client} workspaceId={props.workspaceId} />}sandboxControl={<SandboxStatusChip client={props.client} workspaceId={props.workspaceId} sessionId={props.sessionId ?? null} model={props.selectedModel?.providerID === "omnirush" ? props.selectedModel.modelID : null} onOpenSettings={() => props.onOpenSettingsSection?.("sandbox")} />}- subagentModelControl={<SubagentModelMenu client={props.client} chatModel={props.selectedModel?.providerID === "omnirush" ? props.selectedModel.modelID : null} />}+ subagentModelControl={props.workChat ? undefined : <SubagentModelMenu client={props.client} chatModel={props.selectedModel?.providerID === "omnirush" ? props.selectedModel.modelID : null} />}voiceClient={props.client}voiceWorkspaceId={props.workspaceId}draft={autoSendPayload ? draft : autoSending ? "" : draft}diff --git a/apps/app/src/react-app/domains/work/work-mode.ts b/apps/app/src/react-app/domains/work/work-mode.tsindex 8b912348..f4ab9290 100644--- a/apps/app/src/react-app/domains/work/work-mode.ts+++ b/apps/app/src/react-app/domains/work/work-mode.ts@@ -91,3 +91,37 @@ export const WORK_TEMPLATES = [prompt: "List unpaid and overdue invoices, and match recent payments and bills against them. Flag anything that doesn't reconcile.",},] as const;++/** "1 record", "2 records". */+export const countLabel = (count: number, noun: string) => `${count.toLocaleString()} ${noun}${count === 1 ? "" : "s"}`;++/** Which workspaces a mode lists: Work lists only the Work workspace; Code, and the whole app while Work is off, never do. */+export const shownInMode = (workspace: { preset?: string | null }, workEnabled: boolean, mode: AppMode) =>+ (workspace.preset === WORK_PRESET) === (workEnabled && mode === "work");++/** The engine's name for the hosted connector server's tools: `omnirush-work_<tool>`. */+export const WORK_TOOL_PREFIX = "omnirush-work_";++const WORK_APPS: Record<string, string> = {+ gmail: "Gmail", calendar: "Google Calendar", drive: "Google Drive", outlook: "Outlook", onedrive: "OneDrive", teams: "Teams",+ slack: "Slack", hubspot: "HubSpot", qbo: "QuickBooks", notion: "Notion", jira: "Jira", confluence: "Confluence",+ linear: "Linear", github: "GitHub", mock: "Test source",+};+const WORK_ACTIONS: Record<string, string> = {+ send: "Send e-mail", draft: "Draft e-mail", post: "Post a message", create: "Create an event", note: "Add a note",+ create_task: "Create a task", update_deal: "Update a deal", create_invoice_draft: "Create an invoice draft",+ create_page: "Create a page", comment: "Add a comment", create_issue: "Create an issue",+};++/** An approval's tool and scope in words for a Work connector tool (`omnirush-work_gmail_send` → "Send e-mail (Gmail)",+ * "Your Gmail account"); null for any other permission. */+export function workToolPermission(permission: string): { label: string; scope: string } | null {+ if (!permission.startsWith(WORK_TOOL_PREFIX)) return null;+ const tool = permission.slice(WORK_TOOL_PREFIX.length);+ if (tool === "work_remember") return { label: "Save to company knowledge", scope: "Your Work knowledge" };+ if (tool === "work_forget") return { label: "Forget saved knowledge", scope: "Your Work knowledge" };+ const [app, ...rest] = tool.split("_");+ const action = WORK_ACTIONS[rest.join("_")] ?? (rest.join(" ") || tool).replace(/^./, (c) => c.toUpperCase());+ const name = WORK_APPS[app] ?? app;+ return { label: `${action} (${name})`, scope: `Your ${name} account` };+}diff --git a/apps/app/src/react-app/domains/work/work-views.tsx b/apps/app/src/react-app/domains/work/work-views.tsxindex 0e3abb76..29a3339e 100644--- a/apps/app/src/react-app/domains/work/work-views.tsx+++ b/apps/app/src/react-app/domains/work/work-views.tsx@@ -21,7 +21,7 @@ import {LayoutSectionItemTitle,} from "@/react-app/domains/settings/settings-layout";-import { connectSettled, useWorkState, visibleConnectors, WORK_CONNECTORS_ROUTE, WORK_TEMPLATES, workConnectorsKey, type AppMode, type WorkClient } from "./work-mode";+import { connectSettled, countLabel, useWorkState, visibleConnectors, WORK_CONNECTORS_ROUTE, WORK_TEMPLATES, workConnectorsKey, type AppMode, type WorkClient } from "./work-mode";const TEMPLATE_ICONS: Record<(typeof WORK_TEMPLATES)[number]["id"], ReactNode> = {inbox: <Inbox />,@@ -187,7 +187,7 @@ export function ConnectorRow(props: {{row.status === "error"? errorText(row.error): connected- ? [row.account, `${row.records.toLocaleString()} records`, lastSync(row.last_sync_at)].filter(Boolean).join(" · ")+ ? [row.account, countLabel(row.records, "record"), lastSync(row.last_sync_at)].filter(Boolean).join(" · "): "Connect to let the agent search and use it."}</div></div>diff --git a/apps/app/src/react-app/shell/session-route.tsx b/apps/app/src/react-app/shell/session-route.tsxindex b3df1119..76c860b1 100644--- a/apps/app/src/react-app/shell/session-route.tsx+++ b/apps/app/src/react-app/shell/session-route.tsx@@ -114,7 +114,7 @@ import {type SessionPagePaneRuntime,} from "@/react-app/domains/session/chat/session-page";import { AutomationsPage } from "@/react-app/domains/automations/automations-page";-import { isWorkModeShortcut, useWorkModeStore, useWorkState, WORK_CONNECTORS_ROUTE, WORK_HOME_ROUTE, WORK_PRESET, type AppMode } from "@/react-app/domains/work/work-mode";+import { isWorkModeShortcut, shownInMode, useWorkModeStore, useWorkState, WORK_CONNECTORS_ROUTE, WORK_HOME_ROUTE, WORK_PRESET, type AppMode } from "@/react-app/domains/work/work-mode";import { WorkConnectorsPage, WorkHome, WorkModeToggle } from "@/react-app/domains/work/work-views";import { AppsPage } from "@/react-app/domains/apps/apps-page";import { DashboardPage } from "@/react-app/domains/dashboard/dashboard-page";@@ -558,10 +558,17 @@ export function SessionRoute() {navigate("/session", { replace: true });return;}+ // Work off: its workspace is no project; leave it for a Code one (never open it with the IDE).+ if (!workEnabled && selectedWorkspace?.preset === WORK_PRESET) {+ const codeWorkspace = workspaces.find((workspace) => workspace.preset !== WORK_PRESET && !workspace.task);+ if (codeWorkspace) navigateToWorkspaceSession(codeWorkspace.id, readLastSessionFor(codeWorkspace.id));+ else navigate("/session", { replace: true });+ return;+ }if (appModeRestored.current || !workEnabled) return;appModeRestored.current = true;if (storedAppMode === "work" && appMode === "code" && !routeWorkspaceId) navigate(WORK_HOME_ROUTE, { replace: true });- }, [appMode, navigate, routeWorkspaceId, storedAppMode, workEnabled, workRouteRequested, workState.isPending]);+ }, [appMode, navigate, navigateToWorkspaceSession, routeWorkspaceId, selectedWorkspace?.preset, storedAppMode, workEnabled, workRouteRequested, workState.isPending, workspaces]);// The Work workspace is made on the first visit to Work (the server picks its folder).const workWorkspaceRequested = useRef(false);useEffect(() => {@@ -847,8 +854,8 @@ export function SessionRoute() {const sidebarWorkspaceSessionGroups = useMemo(() => workspaceSessionGroups.filter((group) => !group.workspace.task || group.workspace.id === selectedWorkspaceId)- // Work lists only the Work workspace's chats; Code never lists it.- .filter((group) => !workEnabled || (group.workspace.preset === WORK_PRESET) === (appMode === "work")),+ // Work lists only the Work workspace's chats; Code (and the app while Work is off) never lists it.+ .filter((group) => shownInMode(group.workspace, workEnabled, appMode)),[appMode, selectedWorkspaceId, workEnabled, workspaceSessionGroups],);const tasksBoardWorkspaceId = selectedWorkspace?.task && workspaces.some((workspace) => workspace.id === selectedWorkspace.task?.parentWorkspaceId)@@ -2874,8 +2881,9 @@ export function SessionRoute() {}, [handleOpenProviderAuth]);const paletteSessionOptions = useMemo(- () => buildCommandPaletteSessions(workspaces, sessionsByWorkspaceId, selectedWorkspaceId),- [sessionsByWorkspaceId, selectedWorkspaceId, workspaces],+ // Chats of the mode in view only (recent chats on the start screen, the palette).+ () => buildCommandPaletteSessions(workspaces.filter((workspace) => shownInMode(workspace, workEnabled, appMode)), sessionsByWorkspaceId, selectedWorkspaceId),+ [appMode, sessionsByWorkspaceId, selectedWorkspaceId, workEnabled, workspaces],);const paletteSessionModelSelection = selectedSessionId@@ -3573,7 +3581,7 @@ export function SessionRoute() {const newTaskComposerWithProjects = useMemo<NewTaskComposerContext | null>(() => newTaskComposerContext && (workChatActive ? newTaskComposerContext : {...newTaskComposerContext,projectPicker: {- workspaces: workspaces.filter((workspace) => !workEnabled || workspace.preset !== WORK_PRESET).map((workspace) => ({ id: workspace.id, name: workspace.displayNameResolved, path: workspace.path || null })),+ workspaces: workspaces.filter((workspace) => shownInMode(workspace, workEnabled, "code")).map((workspace) => ({ id: workspace.id, name: workspace.displayNameResolved, path: workspace.path || null })),selectedId: selectedWorkspaceId || null,onSelect: (workspaceId: string) => {setLegacySelectedWorkspaceId(workspaceId);diff --git a/apps/app/tests/work-mode.test.tsx b/apps/app/tests/work-mode.test.tsxindex 9d4ca09a..84814f5f 100644--- a/apps/app/tests/work-mode.test.tsx+++ b/apps/app/tests/work-mode.test.tsx@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";import { renderToStaticMarkup } from "react-dom/server";import type { OmniRushWorkConnector } from "../src/app/lib/omnirush-server";-import { connectSettled, isWorkModeShortcut, visibleConnectors, WORK_TEMPLATES } from "../src/react-app/domains/work/work-mode";+import { connectSettled, countLabel, isWorkModeShortcut, shownInMode, visibleConnectors, WORK_TEMPLATES, workToolPermission } from "../src/react-app/domains/work/work-mode";import { ConnectorRow, WorkHome, WorkModeToggle } from "../src/react-app/domains/work/work-views";const row = (over: Partial<OmniRushWorkConnector>): OmniRushWorkConnector => ({@@ -11,6 +11,32 @@ const row = (over: Partial<OmniRushWorkConnector>): OmniRushWorkConnector => ({const noop = () => {};describe("Work mode", () => {+ test("approvals name Work tools and their account in words", () => {+ expect(workToolPermission("omnirush-work_gmail_send")).toEqual({ label: "Send e-mail (Gmail)", scope: "Your Gmail account" });+ expect(workToolPermission("omnirush-work_mock_send")?.label).toBe("Send e-mail (Test source)");+ expect(workToolPermission("omnirush-work_hubspot_update_deal")?.label).toBe("Update a deal (HubSpot)");+ expect(workToolPermission("omnirush-work_work_remember")?.label).toBe("Save to company knowledge");+ expect(workToolPermission("omnirush-work_acme_frobnicate")?.label).toBe("Frobnicate (acme)");+ expect(workToolPermission("bash")).toBeNull();+ });++ test("the Work workspace shows only in Work, and nowhere while Work is off", () => {+ const work = { preset: "work" };+ const code = { preset: "starter" };+ expect(shownInMode(work, true, "work")).toBe(true);+ expect(shownInMode(code, true, "work")).toBe(false);+ expect(shownInMode(work, true, "code")).toBe(false);+ expect(shownInMode(work, false, "code")).toBe(false);+ expect(shownInMode(work, false, "work")).toBe(false);+ expect(shownInMode(code, false, "code")).toBe(true);+ });++ test("counts read naturally", () => {+ expect(countLabel(1, "record")).toBe("1 record");+ expect(countLabel(0, "record")).toBe("0 records");+ expect(countLabel(1200, "record")).toBe("1,200 records");+ });+test("Cmd/Ctrl+Shift+K switches mode; Cmd/Ctrl+K stays the command palette", () => {const key = { key: "K", metaKey: true, ctrlKey: false, shiftKey: true, altKey: false };expect(isWorkModeShortcut(key, true)).toBe(true);