Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(agents): hide Changes and repository chrome for non-coding agent sessions (#6664)

Wolf Mermelstein1ee2334d90f9
diff --git a/apps/web/src/features/agent-changes/README.md b/apps/web/src/features/agent-changes/README.md
index b1c011e1ff..2c0e73cdf0 100644
--- a/apps/web/src/features/agent-changes/README.md
+++ b/apps/web/src/features/agent-changes/README.md
@@ -9,8 +9,10 @@ and mounts `AgentChangesControllerProvider` around `ChangesPane` or
`AgentChangesSplit`. Give each host a stable `scopeKey` (for example,
`pr:<foreign-entity-id>`) to isolate its locally persisted collapse state and notes.
The optional `agent` capability enables inline note creation and sending; omit it
-for a read-only PR viewer. Clipboard, external navigation, and notifications are
-host callbacks.
+for a read-only PR viewer. The optional `canHaveChanges` accessor hides every
+control and the pane while false; the session host reports it from the harness so
+a chat-only (in-memory) session shows no GitHub chrome. Clipboard, external
+navigation, and notifications are host callbacks.
The source owns fetching, cache identity, and conversion into the feature's core
changeset types. A PR entity adapter should resolve its GitHub owner/repository/PR
diff --git a/apps/web/src/features/agent-changes/agent-changes.tsx b/apps/web/src/features/agent-changes/agent-changes.tsx
index 22907db039..9c4ab82dad 100644
--- a/apps/web/src/features/agent-changes/agent-changes.tsx
+++ b/apps/web/src/features/agent-changes/agent-changes.tsx
@@ -8,6 +8,7 @@
* hand-off card, and the notes chip where they belong.
*/
+import { isCoderHarness } from '@app/features/agents-view/core/agent-kind';
import { toast } from '@core/component/Toast/Toast';
import { openExternalUrl } from '@core/util/url';
import { createSignal, type ParentProps } from 'solid-js';
@@ -36,7 +37,12 @@ async function copyText(text: string): Promise<boolean> {
export function AgentChangesProvider(props: ParentProps) {
const session = useAgentSession();
- const source = createSessionChangesSource(session.sessionId);
+ // Only a coding harness has a repository to diff; a chat-only session
+ // (in-memory) never fetches changes and shows none of the GitHub chrome.
+ const coding = () => isCoderHarness(session.session()?.harness);
+ const source = createSessionChangesSource(() =>
+ coding() ? session.sessionId() : undefined
+ );
const sendPrompt = async (markdown: string) => {
try {
const result = await session.issue({ type: 'prompt', prompt: markdown });
@@ -56,6 +62,7 @@ export function AgentChangesProvider(props: ParentProps) {
!session.loadFailed() &&
(session.session()?.canEdit ?? true),
},
+ canHaveChanges: coding,
pullRequestUrl: () => session.session()?.pullRequestUrl ?? undefined,
openExternal: openExternalUrl,
copyText,
diff --git a/apps/web/src/features/agent-changes/context/agent-changes-context.ts b/apps/web/src/features/agent-changes/context/agent-changes-context.ts
index deab771a4e..a74dfe14e0 100644
--- a/apps/web/src/features/agent-changes/context/agent-changes-context.ts
+++ b/apps/web/src/features/agent-changes/context/agent-changes-context.ts
@@ -49,6 +49,13 @@ export type ChangesHost = {
scopeKey: Accessor<string | undefined>;
/** Omit for a read-only viewer without agent note controls. */
agent?: ChangesAgent;
+ /**
+ * Whether the source can ever hold changes. Omit for hosts that always
+ * can (a PR entity); a session host reports false for a chat-only
+ * harness, which hides every Changes control instead of showing an
+ * empty pane.
+ */
+ canHaveChanges?: Accessor<boolean>;
/** The pull request represented by the source. */
pullRequestUrl: Accessor<string | undefined>;
openExternal: (url: string) => void;
diff --git a/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts b/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts
index 49bae300f8..389d60ced2 100644
--- a/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts
+++ b/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts
@@ -21,6 +21,8 @@ export type { DiffStyle } from '../core/layout';
export type AgentChangesController = {
context: AgentChangesContext;
+ /** False when the host can never have changes; every control renders nothing. */
+ available: Accessor<boolean>;
layout: PaneLayoutController;
model: ChangesModel;
review: ReviewController;
@@ -80,6 +82,7 @@ export function createAgentChanges(options: {
return {
context: options.context,
+ available: () => host.canHaveChanges?.() ?? true,
layout,
model,
review,
diff --git a/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx b/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
index d10c4d8b76..af78548da7 100644
--- a/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
+++ b/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
@@ -14,8 +14,12 @@ const SESSION_MIN_PX = 320;
const CHANGES_MIN_PX = 400;
export function AgentChangesSplit(props: ParentProps) {
- const { layout } = useAgentChanges();
+ const { available, layout } = useAgentChanges();
let zone: ResizeZoneCtx | undefined;
+ // A host that can never have changes keeps the session alone on screen,
+ // whatever a stale URL or persisted layout asks for.
+ const sessionVisible = () => !available() || layout.sessionVisible();
+ const changesVisible = () => available() && layout.changesVisible();
return (
<Resize.Zone
@@ -28,14 +32,14 @@ export function AgentChangesSplit(props: ParentProps) {
>
{/* Panels mount and unmount with the layout: an unregistered panel
would still paint its content at the zone's left edge. */}
- <Show when={layout.sessionVisible()}>
+ <Show when={sessionVisible()}>
<Resize.Panel id="agent-session" minSize={SESSION_MIN_PX} index={0}>
<div class="flex h-full min-w-0 flex-col overflow-hidden">
{props.children}
</div>
</Resize.Panel>
</Show>
- <Show when={layout.changesVisible()}>
+ <Show when={changesVisible()}>
<Resize.Panel
id="agent-changes"
minSize={CHANGES_MIN_PX}
diff --git a/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx b/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx
index 14f9ba5c69..c41a29d8f5 100644
--- a/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx
+++ b/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx
@@ -1,7 +1,9 @@
/**
* The pieces the session pane itself shows: the header toggle, the
* "changes ready" hand-off card, and the queued-notes chip by the composer.
- * Each renders nothing until a host has mounted the controller.
+ * Each renders nothing until a host has mounted the controller, and nothing
+ * at all while the host reports it can never have changes (a chat-only
+ * harness has no repository to diff).
*/
import { createSignal, Show } from 'solid-js';
@@ -13,15 +15,17 @@ import { useOptionalAgentChanges } from '../context/agent-changes-controller';
export function ChangesToggle() {
const controller = useOptionalAgentChanges();
if (!controller) return null;
- const { layout, model } = controller;
+ const { available, layout, model } = controller;
return (
- <ChangesToggleButton
- open={layout.changesVisible()}
- additions={model.changeset()?.additions ?? 0}
- deletions={model.changeset()?.deletions ?? 0}
- capturing={model.state().kind === 'capturing'}
- onToggle={layout.toggle}
- />
+ <Show when={available()}>
+ <ChangesToggleButton
+ open={layout.changesVisible()}
+ additions={model.changeset()?.additions ?? 0}
+ deletions={model.changeset()?.deletions ?? 0}
+ capturing={model.state().kind === 'capturing'}
+ onToggle={layout.toggle}
+ />
+ </Show>
);
}
@@ -29,8 +33,9 @@ export function ChangesToggle() {
export function ChangesHandoff() {
const controller = useOptionalAgentChanges();
if (!controller) return null;
- const { layout, model, review, context } = controller;
+ const { available, layout, model, review, context } = controller;
const visible = () =>
+ available() &&
!layout.changesVisible() &&
model.files().length > 0 &&
!controller.handoffDismissed();
@@ -60,9 +65,11 @@ export function ReviewNotesDock() {
const controller = useOptionalAgentChanges();
const [expanded, setExpanded] = createSignal(false);
if (!controller) return null;
- const { review, context, layout } = controller;
+ const { available, review, context, layout } = controller;
return (
- <Show when={context.host.agent && review.queued().length > 0}>
+ <Show
+ when={available() && context.host.agent && review.queued().length > 0}
+ >
<ReviewNotesChip
notes={review.queued()}
expanded={expanded()}
diff --git a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx b/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
index 6b614e0e0e..b2a3fef00f 100644
--- a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
+++ b/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
@@ -277,6 +277,38 @@ describe('session controls', () => {
expect(screen.queryByText(/review note/)).toBeNull();
});
+ it('renders nothing for a host that can never have changes', () => {
+ const context = readyContext();
+ const [coding, setCoding] = createSignal(false);
+ const { controller } = mount(
+ { ...context, host: { ...context.host, canHaveChanges: coding } },
+ () => (
+ <>
+ <ChangesToggle />
+ <ChangesHandoff />
+ <ReviewNotesDock />
+ </>
+ )
+ );
+ controller().review.addNote(
+ {
+ path: 'apps/web/src/a.ts',
+ side: 'additions',
+ lineNumber: 2,
+ endLineNumber: 2,
+ },
+ 'Use a constant'
+ );
+ expect(screen.queryByRole('button', { name: /Changes/ })).toBeNull();
+ expect(screen.queryByText('Changes ready to review')).toBeNull();
+ expect(screen.queryByText(/review note/)).toBeNull();
+
+ setCoding(true);
+ expect(screen.getByRole('button', { name: /Changes/ })).toBeTruthy();
+ expect(screen.getByText('Changes ready to review')).toBeTruthy();
+ expect(screen.getByText(/review note/)).toBeTruthy();
+ });
+
it("opens the note's file from the expanded dock", () => {
const context = readyContext();
const { controller } = mount(context, () => <ReviewNotesDock />);
diff --git a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
index 550986f554..263329bb84 100644
--- a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
+++ b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
@@ -8,7 +8,10 @@ import {
import { AgentSessionProvider } from '@app/features/block-agent/agent-session-provider';
import { AgentComposer } from '@app/features/block-agent/component/AgentComposer';
import { AgentPullRequestChip } from '@app/features/block-agent/component/AgentPullRequestChip';
-import { agentSessionTitle } from '@app/features/block-agent/component/AgentSplitHeader';
+import {
+ agentSessionTitle,
+ sessionRepositoryUrl,
+} from '@app/features/block-agent/component/AgentSplitHeader';
import { AgentSidePanelSections } from '@app/features/block-agent/component/sidepanel/AgentSidePanelSections';
import { Transcript } from '@app/features/block-agent/component/Transcript';
import { useAgentSession } from '@app/features/block-agent/context/AgentSessionContext';
@@ -143,14 +146,18 @@ function SessionContent(props: { onDeleted: () => void }) {
ops={[
{ op: 'rename' },
{ op: 'delete' },
- {
- label: 'Open repository',
- icon: GitBranch,
- action: () => {
- const url = session()?.repoUrl;
- if (url) openExternalUrl(url);
- },
- },
+ ...(sessionRepositoryUrl(session())
+ ? [
+ {
+ label: 'Open repository',
+ icon: GitBranch,
+ action: () => {
+ const url = sessionRepositoryUrl(session());
+ if (url) openExternalUrl(url);
+ },
+ },
+ ]
+ : []),
]}
tools={[
{
diff --git a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
index 06d0cf1f07..aada726580 100644
--- a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
+++ b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
@@ -34,9 +34,12 @@ import {
sessionOriginThread,
} from '../context/origin-thread';
import { AgentPullRequestChip } from './AgentPullRequestChip';
-import { harnessTitle } from './compose-agent-session-options';
+import {
+ harnessTitle,
+ sessionRepositoryUrl,
+} from './compose-agent-session-options';
-export { harnessTitle };
+export { harnessTitle, sessionRepositoryUrl };
/** Shared title precedence for standalone and workspace agent sessions. */
export function agentSessionTitle(
@@ -126,17 +129,18 @@ export function AgentSplitHeader(props: {
},
];
- const ops: FileOperation[] = [
+ const openRepository: FileOperation = {
+ label: 'Open repository',
+ icon: GitBranch,
+ action: () => {
+ const url = sessionRepositoryUrl(props.session);
+ if (url) openExternalUrl(url);
+ },
+ };
+ const ops = (): FileOperation[] => [
{ op: 'rename' },
{ op: 'delete' },
- {
- label: 'Open repository',
- icon: GitBranch,
- action: () => {
- const url = props.session?.repoUrl;
- if (url) openExternalUrl(url);
- },
- },
+ ...(sessionRepositoryUrl(props.session) ? [openRepository] : []),
];
return (
@@ -195,7 +199,7 @@ export function AgentSplitHeader(props: {
<ResponsiveBlockToolbar
tools={shareTools}
menuTools={tools}
- ops={entity() ? ops : []}
+ ops={entity() ? ops() : []}
id={sessionId() ?? ''}
itemType="agent_session"
entity={entity()}
diff --git a/apps/web/src/features/block-agent/component/compose-agent-session-options.test.ts b/apps/web/src/features/block-agent/component/compose-agent-session-options.test.ts
index efd6debda8..247fc2ea2a 100644
--- a/apps/web/src/features/block-agent/component/compose-agent-session-options.test.ts
+++ b/apps/web/src/features/block-agent/component/compose-agent-session-options.test.ts
@@ -1,5 +1,33 @@
import { describe, expect, it } from 'vitest';
-import { harnessDisplayName } from './compose-agent-session-options';
+import {
+ harnessDisplayName,
+ sessionRepositoryUrl,
+} from './compose-agent-session-options';
+
+describe('sessionRepositoryUrl', () => {
+ const repoUrl = 'https://github.com/macro-inc/macro';
+
+ it('shows the repository of a coding session', () => {
+ expect(sessionRepositoryUrl({ harness: 'cursor', repoUrl })).toBe(repoUrl);
+ expect(sessionRepositoryUrl({ harness: 'macrod', repoUrl })).toBe(repoUrl);
+ });
+
+ it('hides the default repository stamped on a chat session', () => {
+ expect(sessionRepositoryUrl({ harness: 'in-memory', repoUrl })).toBe(
+ undefined
+ );
+ expect(sessionRepositoryUrl({ harness: 'macro-inmem', repoUrl })).toBe(
+ undefined
+ );
+ });
+
+ it('is empty without a session or repository', () => {
+ expect(sessionRepositoryUrl(undefined)).toBe(undefined);
+ expect(sessionRepositoryUrl({ harness: 'cursor', repoUrl: null })).toBe(
+ undefined
+ );
+ });
+});
describe('harnessDisplayName', () => {
it('names Macro runtimes after the product', () => {
diff --git a/apps/web/src/features/block-agent/component/compose-agent-session-options.ts b/apps/web/src/features/block-agent/component/compose-agent-session-options.ts
index 9e08e7efe2..3edd3c25fa 100644
--- a/apps/web/src/features/block-agent/component/compose-agent-session-options.ts
+++ b/apps/web/src/features/block-agent/component/compose-agent-session-options.ts
@@ -1,3 +1,18 @@
+import { isCoderHarness } from '@app/features/agents-view/core/agent-kind';
+
+/**
+ * The repository a session works in, for the header menu and side panel.
+ * The service stamps the deployment's default repository on every session,
+ * including chat-only ones that never touch it, so only a coding harness
+ * gets to show one.
+ */
+export function sessionRepositoryUrl(
+ session: { harness: string; repoUrl?: string | null } | undefined
+): string | undefined {
+ if (!session || !isCoderHarness(session.harness)) return undefined;
+ return session.repoUrl ?? undefined;
+}
+
/** 'claude-code' → 'Claude Code'; the fallback when nothing names a harness. */
export function harnessTitle(harness: string | undefined): string {
if (!harness) return 'Agent session';
diff --git a/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsx b/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsx
index 9d121223b9..731cd84aef 100644
--- a/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsx
+++ b/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsx
@@ -29,7 +29,7 @@ import {
TodoList,
} from '../../ui';
import { AgentPullRequestChip } from '../AgentPullRequestChip';
-import { harnessTitle } from '../AgentSplitHeader';
+import { harnessTitle, sessionRepositoryUrl } from '../AgentSplitHeader';
export function AgentSidePanelSections() {
const { session, bot, metadata, messages } = useAgentSession();
@@ -72,7 +72,7 @@ export function AgentSidePanelSections() {
</SidePanel.Row>
)}
</Show>
- <Show when={session()?.repoUrl}>
+ <Show when={sessionRepositoryUrl(session())}>
{(url) => (
<SidePanel.Row label="Repository">
<button
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index b9e36298e0..0c3113d511 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -425,10 +425,13 @@ Existing announcement chips remain locked to the turn they announced.
### Reviewing a linked GitHub pull request
Sessions with a linked GitHub pull request capture that PR's diff when each
-turn ends, regardless of the agent runtime. Unpushed workspace changes and
+turn ends, regardless of the coding runtime. Unpushed workspace changes and
branches without a PR are not included. The session header gains a **Changes**
toggle (`aria-pressed`) with green additions and red deletions (`+N −M`); it opens a resizable
**Changes** pane beside the transcript (drag the 1px divider between them).
+Chat sessions on Macro's in-memory harness have no repository, so they show
+none of this: no **Changes** toggle, pane, hand-off card, or review-notes chip,
+and the title menu offers **Open repository** only when the session has one.
The URL's `diff` query parameter stores each session's pane state and diff
layout (`session-id:split:unified`, or `changes-only` / `agent-only` and
`split` for side-by-side diffs). Copying the URL preserves that view; reload