Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(agents): stamp Cursor agent sessions as cursor, not opencode (#6669)
Wolf Mermelsteinb88963e94f6f
diff --git a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsxindex aada726580..51305544f7 100644--- a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx+++ b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx@@ -36,6 +36,7 @@ import {import { AgentPullRequestChip } from './AgentPullRequestChip';import {harnessTitle,+ sessionHarnessTitle,sessionRepositoryUrl,} from './compose-agent-session-options';@@ -48,7 +49,7 @@ export function agentSessionTitle(): string {const name = session?.name;if (name && name !== 'Agent Session') return name;- return transcriptTitle ?? name ?? harnessTitle(session?.harness);+ return transcriptTitle ?? name ?? sessionHarnessTitle(session ?? {});}/**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.tsindex 247fc2ea2a..ac06dc077b 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,6 +1,10 @@+import { CLAUDE_BOT_ID } from '@core/constant/claudeAgent';+import { CODEX_BOT_ID } from '@core/constant/codexAgent';+import { CURSOR_BOT_ID } from '@core/constant/cursorAgent';import { describe, expect, it } from 'vitest';import {harnessDisplayName,+ sessionHarnessTitle,sessionRepositoryUrl,} from './compose-agent-session-options';@@ -43,3 +47,22 @@ describe('harnessDisplayName', () => {expect(harnessDisplayName('my-laptop')).toBe('my-laptop');});});++describe('sessionHarnessTitle', () => {+ it.each([+ [CURSOR_BOT_ID, 'Cursor'],+ [CODEX_BOT_ID, 'Codex Cloud'],+ [CLAUDE_BOT_ID, 'Claude Cloud'],+ ] as const)(+ 'names a %s session from the bot even when the row says opencode',+ (botId, title) => {+ expect(sessionHarnessTitle({ harness: 'opencode', botId })).toBe(title);+ }+ );++ it('title-cases other sessions from their stored slug', () => {+ expect(sessionHarnessTitle({ harness: 'claude-cloud' })).toBe(+ 'Claude Cloud'+ );+ });+});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.tsindex 3edd3c25fa..abf4db28e5 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,4 +1,7 @@import { isCoderHarness } from '@app/features/agents-view/core/agent-kind';+import { isClaudeBotId } from '@core/constant/claudeAgent';+import { isCodexBotId } from '@core/constant/codexAgent';+import { isCursorBotId } from '@core/constant/cursorAgent';/*** The repository a session works in, for the header menu and side panel.@@ -23,6 +26,30 @@ export function harnessTitle(harness: string | undefined): string {.join(' ');}+/**+ * The harness slug a session should be labeled with. First-party cloud bots+ * own a fixed slug (Cursor / Codex / Claude Cloud), even when an older row+ * was stamped with the sandboxed-coder default (`opencode`).+ */+export function sessionHarnessSlug(session: {+ harness?: string;+ botId?: string;+}): string | undefined {+ const botId = session.botId;+ if (botId && isCursorBotId(botId)) return 'cursor';+ if (botId && isCodexBotId(botId)) return 'codex-cloud';+ if (botId && isClaudeBotId(botId)) return 'claude-cloud';+ return session.harness;+}++/** Title-cased harness label for session chrome (side panel, fallback title). */+export function sessionHarnessTitle(session: {+ harness?: string;+ botId?: string;+}): string {+ return harnessTitle(sessionHarnessSlug(session));+}+/*** User-facing name for the runtime a persona runs on. Harness ids are* plumbing ("in-memory", "sandbox"); the product names are the coders.diff --git a/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsx b/apps/web/src/features/block-agent/component/sidepanel/AgentSidePanelSections.tsxindex 731cd84aef..1e9f738fc7 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,10 @@ import {TodoList,} from '../../ui';import { AgentPullRequestChip } from '../AgentPullRequestChip';-import { harnessTitle, sessionRepositoryUrl } from '../AgentSplitHeader';+import {+ sessionHarnessTitle,+ sessionRepositoryUrl,+} from '../compose-agent-session-options';export function AgentSidePanelSections() {const { session, bot, metadata, messages } = useAgentSession();@@ -60,7 +63,9 @@ export function AgentSidePanelSections() {</Show><SidePanel.Row label="Harness"><SidePanel.Pill>- <span class="truncate">{harnessTitle(session()?.harness)}</span>+ <span class="truncate">+ {sessionHarnessTitle(session() ?? {})}+ </span></SidePanel.Pill></SidePanel.Row><Show when={metadata()?.model ?? session()?.model}>diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/create-magic-chip-model.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/create-magic-chip-model.tsindex 0b8f64d014..754daee0ed 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/create-magic-chip-model.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/create-magic-chip-model.ts@@ -2,6 +2,7 @@ import {harnessDisplayName,harnessTitle,modelDisplayName,+ sessionHarnessSlug,} from '@app/features/block-agent/component/compose-agent-session-options';import {toolCallDetail,@@ -51,7 +52,11 @@ type SessionIdentity = {* by "Agent" (`Macro Agent`, `Cursor Agent`), a titled slug for a runtime* the composer does not name.*/-function agentName(harness: string | undefined): string | undefined {+function agentName(session: {+ harness?: string;+ botId?: string;+}): string | undefined {+ const harness = sessionHarnessSlug(session);if (!harness) return undefined;const known = harnessDisplayName(harness);return `${known === harness ? harnessTitle(harness) : known} Agent`;@@ -206,7 +211,8 @@ export function createMagicChipModel(props: MagicChipData): {});const header = createMemo((): MagicChipHeader | undefined => {- const agent = agentName(session()?.harness);+ const current = session();+ const agent = current ? agentName(current) : undefined;const model = modelName(metadata(), session());const pullRequestUrl = session()?.pullRequestUrl ?? undefined;return agent || model || pullRequestUrldiff --git a/crates/agent_harness/src/domain/model.rs b/crates/agent_harness/src/domain/model.rsindex 589c6ae363..b7b2ce70b5 100644--- a/crates/agent_harness/src/domain/model.rs+++ b/crates/agent_harness/src/domain/model.rs@@ -186,6 +186,24 @@ impl AgentKind {}}+ /// Fixed harness slug for kinds that map one-to-one onto one.+ ///+ /// Inverse of [`Self::from_harness`] for Cursor, Codex, and Claude — a+ /// session of those bots is always stored under that slug, even when the+ /// open path fell through to a deployment default (`opencode`). The+ /// sandboxed coder's slug is deployment configuration, in-memory accepts+ /// both `in-memory` and `macro-inmem`, and an external runtime is whoever+ /// dialed in; those keep the slug the open path already chose.+ #[must_use]+ pub const fn harness_slug(self) -> Option<&'static str> {+ match self {+ Self::Cursor => Some("cursor"),+ Self::CodexCloud => Some("codex-cloud"),+ Self::ClaudeCloud => Some("claude-cloud"),+ Self::SandboxedCoder | Self::InMemory | Self::External => None,+ }+ }+/// Whether a deployment provisions this kind's runtimes itself.////// Membership is about who provisions, not whether *this* deployment isdiff --git a/crates/agent_harness/src/domain/model/test.rs b/crates/agent_harness/src/domain/model/test.rsindex 60a1dab0e0..63be58e9c3 100644--- a/crates/agent_harness/src/domain/model/test.rs+++ b/crates/agent_harness/src/domain/model/test.rs@@ -1,4 +1,5 @@use super::*;+use bot_id::{CLAUDE_BOT_ID, CODEX_BOT_ID, CURSOR_BOT_ID};#[test]fn only_external_runtimes_prompt_by_default() {@@ -101,6 +102,30 @@ fn registered_harness_limit_wins_over_runtime_kind_and_persona_choice() {}}+#[test]+fn first_party_cloud_kinds_own_a_fixed_harness_slug() {+ assert_eq!(AgentKind::Cursor.harness_slug(), Some("cursor"));+ assert_eq!(AgentKind::CodexCloud.harness_slug(), Some("codex-cloud"));+ assert_eq!(AgentKind::ClaudeCloud.harness_slug(), Some("claude-cloud"));+ assert_eq!(AgentKind::SandboxedCoder.harness_slug(), None);+ assert_eq!(AgentKind::InMemory.harness_slug(), None);+ assert_eq!(AgentKind::External.harness_slug(), None);++ // A create-path fallback that stamped the sandboxed-coder default is+ // corrected from the bot, not from the wrong slug it was handed.+ for (bot, slug) in [+ (CURSOR_BOT_ID, "cursor"),+ (CODEX_BOT_ID, "codex-cloud"),+ (CLAUDE_BOT_ID, "claude-cloud"),+ ] {+ assert_eq!(+ AgentKind::for_session(bot, "opencode").harness_slug(),+ Some(slug),+ "{bot:?}"+ );+ }+}+/// The URL survives verbatim - it is what a session's row carries, and/// what the egress proxy re-reads - and one that names no repository is/// refused rather than repaired. The shapes themselves are the parser'sdiff --git a/crates/agent_harness/src/domain/service/open.rs b/crates/agent_harness/src/domain/service/open.rsindex e3ac7ef335..305e6352fd 100644--- a/crates/agent_harness/src/domain/service/open.rs+++ b/crates/agent_harness/src/domain/service/open.rs@@ -191,6 +191,7 @@ where),};let kind = AgentKind::for_session(bot_id, &harness);+ let harness = kind.harness_slug().map_or(harness, str::to_owned);if kind == AgentKind::CodexCloud {mcp_servers = AgentMcpServers::Selected {servers: Vec::new(),@@ -498,7 +499,11 @@ wherethread_id: Some(origin.thread_id),originating_message_id: Some(origin.message_id),model: runtime.model.clone(),- harness: runtime.harness.clone(),+ harness: runtime+ .kind+ .harness_slug()+ .unwrap_or(&runtime.harness)+ .to_owned(),repo_url: defaults.repo_url.as_ref()diff --git a/crates/agent_harness/src/domain/service/test.rs b/crates/agent_harness/src/domain/service/test.rsindex 8355b801e2..d7d780fabb 100644--- a/crates/agent_harness/src/domain/service/test.rs+++ b/crates/agent_harness/src/domain/service/test.rs@@ -3764,6 +3764,36 @@ impl crate::domain::ports::ReachableRepositories for SelectedRepositories {}}+/// The agents-view create path names the Cursor bot with no persisted+/// profile. The deployment default harness is the sandboxed coder's+/// `opencode`; Cursor sessions must not inherit it.+#[tokio::test]+async fn a_cursor_managed_session_is_always_stamped_cursor() {+ let (service, repo, containers, _, _) = harness();+ let open = service.open_managed_session(OpenManagedSession {+ repo_url: None,+ repo_branch: None,+ owner: model_owner::Owner::User(sender()),+ instructions: None,+ prompt: None,+ profile: Some(agent_session::domain::ports::SelectedManagedPersona {+ bot_id: bot_id::CURSOR_BOT_ID,+ profile: None,+ }),+ });+ let drive = async {+ while containers.spawned() == 0 {+ tokio::task::yield_now().await;+ }+ let container = containers.container(session_of(&containers)).unwrap();+ complete_session_handshake(&container).await;+ };+ let (opened, _) = tokio::join!(open, drive);+ let session = repo.get(opened.unwrap().id).await.unwrap();+ assert_eq!(session.bot_id, bot_id::CURSOR_BOT_ID);+ assert_eq!(session.harness, "cursor");+}+fn explicit_cursor_request() -> OpenManagedSession {OpenManagedSession {owner: model_owner::Owner::User(sender()),@@ -3814,6 +3844,7 @@ async fn selected_repository_and_branch_are_persisted_for_cursor() {};let (opened, _) = tokio::join!(open, drive);let session = repo.get(opened.unwrap().id).await.unwrap();+ assert_eq!(session.harness, "cursor");assert_eq!(session.repo_url.as_deref(),Some("https://github.com/macro-inc/macro")diff --git a/services/agent_harness_service/src/main.rs b/services/agent_harness_service/src/main.rsindex d3cef25d94..a87e0eda31 100644--- a/services/agent_harness_service/src/main.rs+++ b/services/agent_harness_service/src/main.rs@@ -777,6 +777,15 @@ async fn run() -> anyhow::Result<()> {harness: config.inmem_harness_slug.clone(),// Stamped but unused: the in-process agent has no// workspace to clone anything into.+ repo_url: Some(repo_url.clone()),+ },+ )+ .with_bot(+ bot_id::CURSOR_BOT_ID,+ SessionDefaults {+ bot_id: bot_id::CURSOR_BOT_ID,+ model: config.harness_model.clone(),+ harness: "cursor".into(),repo_url: Some(repo_url),},)