Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/mobile-web/src/components/SessionTypeIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
Bot as LucideBot,
MessageSquare as LucideMessageSquare,
Users as LucideUsers,
} from 'lucide-react';
import React from 'react';
import type { RecentWorkspaceEntry } from '../services/RemoteSessionManager';
import { sessionIconKind, type SessionIconKind } from '../services/workspaceIdentity';

const SESSION_ICONS: Record<SessionIconKind, typeof LucideBot> = {
assistant: LucideBot,
cowork: LucideUsers,
code: LucideMessageSquare,
};

/**
* Shared session-type icon: assistant entries, Claw history rows, the resume
* card and the compact sidebar all resolve through `sessionIconKind`.
*/
export function SessionTypeIcon({
agentType,
workspaceKind,
size = 18,
}: {
agentType?: string;
workspaceKind?: RecentWorkspaceEntry['workspace_kind'];
size?: number;
}) {
const Icon = SESSION_ICONS[sessionIconKind(agentType, workspaceKind)];
return <Icon width={size} height={size} stroke="currentColor" aria-hidden="true" />;
}
37 changes: 9 additions & 28 deletions src/mobile-web/src/pages/SessionListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { WorkspaceIcon as ProjectWorkspaceIcon } from '../components/WorkspaceIcon';
import { SessionTypeIcon } from '../components/SessionTypeIcon';
import { subscribeHostCatalog } from '../services/HostCatalogSubscription';
import {
AppWindow as LucideAppWindow,
Bot as LucideBot,
Check as LucideCheck,
ChevronRight as LucideChevronRight,
ChevronsUpDown as LucideChevronsUpDown,
Expand All @@ -11,7 +10,6 @@ import {
FolderOpen as LucideFolderOpen,
LoaderCircle as LucideLoaderCircle,
LogOut as LucideLogOut,
MessageSquare as LucideMessageSquare,
MessageCircle as LucideMessageCircle,
Monitor as LucideMonitor,
Moon as LucideMoon,
Expand All @@ -22,7 +20,6 @@ import {
Sun as LucideSun,
Terminal as LucideTerminal,
User as LucideUser,
Users as LucideUsers,
Wrench as LucideWrench,
X as LucideX,
} from 'lucide-react';
Expand Down Expand Up @@ -64,7 +61,9 @@ import { describeRemoteError } from '../services/remoteErrorPresentation';
import { deviceFailurePresentation } from '../services/deviceFailureCopy';
import {
isClawAgent,
isCoworkAgent,
sameWorkspace,
sessionIconKind,
selectedSessionWorkspaceContext,
sessionMatchesWorkspace,
sessionWorkspaceContext,
Expand Down Expand Up @@ -227,10 +226,6 @@ function agentLabel(agentType: string, t: (key: string) => string): string {
}
}

function isCoworkAgent(agentType: string): boolean {
return agentType === 'cowork' || agentType === 'Cowork';
}

/** Pick first workspace suitable for Expert mode (exclude Claw assistant roots when kind is known). */
function pickFirstProWorkspace(list: RecentWorkspaceEntry[]): RecentWorkspaceEntry | undefined {
if (list.length === 0) return undefined;
Expand All @@ -249,24 +244,6 @@ function truncateMiddle(str: string, maxLen: number): string {
return str.slice(0, head) + '...' + str.slice(-tail);
}

function SessionTypeIcon({ agentType }: { agentType: string }) {
if (isCoworkAgent(agentType)) {
return (
<LucideUsers width="18" height="18" stroke="currentColor" aria-hidden="true" />
);
}

if (isClawAgent(agentType)) {
return (
<LucideAppWindow width="18" height="18" stroke="currentColor" aria-hidden="true" />
);
}

return (
<LucideMessageSquare width="18" height="18" stroke="currentColor" aria-hidden="true" />
);
}

/* Mode Selection Icons */
const ProModeIcon = () => (
<LucideTerminal width="32" height="32" stroke="currentColor" aria-hidden="true" />
Expand Down Expand Up @@ -1697,7 +1674,7 @@ const SessionListPage: React.FC<SessionListPageProps> = ({
<MobileButton appearance="plain" block className="harmony-sidebar__workspace-main" onClick={() => void handleToggleCompactWorkspace(workspace)}>
<span className="harmony-sidebar__folder-icon" aria-hidden="true">
{workspace.workspace_kind === 'assistant'
? <LucideBot width="21" height="21" stroke="currentColor" aria-hidden="true" />
? <SessionTypeIcon workspaceKind="assistant" size={21} />
: <ProjectWorkspaceIcon manager={sessionMgr} workspace={workspace} />}
</span>
<span className="harmony-sidebar__workspace-copy">
Expand All @@ -1724,7 +1701,11 @@ const SessionListPage: React.FC<SessionListPageProps> = ({
onContextMenu={(event) => { event.preventDefault(); setMenuSession(session); }}
>
<MobileButton appearance="plain" block className="harmony-sidebar__session-main" onClick={(event) => handleSessionClick(session, event, workspace)}>
<span className="harmony-sidebar__session-icon" aria-hidden="true"><LucideMessageCircle width="18" height="18" stroke="currentColor" /></span>
<span className="harmony-sidebar__session-icon" aria-hidden="true">
{sessionIconKind(session.agent_type, workspace.workspace_kind) === 'assistant'
? <SessionTypeIcon agentType={session.agent_type} workspaceKind={workspace.workspace_kind} />
: <LucideMessageCircle width="18" height="18" stroke="currentColor" />}
</span>
<span className="harmony-sidebar__row-label">{session.name || t('sessions.untitledSession')}</span>
</MobileButton>
<MobileIconButton
Expand Down
19 changes: 19 additions & 0 deletions src/mobile-web/src/services/workspaceIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,25 @@ export function isClawAgent(agentType: string): boolean {
return agentType === 'claw' || agentType === 'Claw';
}

export function isCoworkAgent(agentType: string): boolean {
return agentType === 'cowork' || agentType === 'Cowork';
}

export type SessionIconKind = 'assistant' | 'cowork' | 'code';

/**
* The one icon mapping for sessions and assistant entries. Claw sessions and
* assistant workspaces share the assistant icon wherever they are listed.
*/
export function sessionIconKind(
agentType: string | undefined,
workspaceKind?: RecentWorkspaceEntry['workspace_kind'],
): SessionIconKind {
if (isClawAgent(agentType ?? '') || workspaceKind === 'assistant') return 'assistant';
if (isCoworkAgent(agentType ?? '')) return 'cowork';
return 'code';
}

/**
* The workspace a session belongs to, captured when the session is opened. Every
* field is optional because pre-ID hosts and old navigation records omit them.
Expand Down
20 changes: 19 additions & 1 deletion src/mobile-web/tests/workspace-identity.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const code = ts.transpileModule(source, {
const {
mergeWorkspaceSessions, sessionMatchesWorkspace, workspaceIdentityKey,
resolveLegacyWorkspaceReference, sameWorkspace,
isClawAgent, isRemoteSessionWorkspace, resolveChatHeaderContext, selectedSessionWorkspaceContext,
isClawAgent, isCoworkAgent, sessionIconKind, isRemoteSessionWorkspace, resolveChatHeaderContext, selectedSessionWorkspaceContext,
sessionWorkspaceContext, workspaceContext,
} = await import(
`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`
Expand Down Expand Up @@ -633,3 +633,21 @@ test('a path-only session context cannot open the rollback gate over a possibly
assert.equal(isRemoteSessionWorkspace('Claw', pathOnly, selectedSsh, [sshRow]), false);
assert.equal(isRemoteSessionWorkspace('Standard', { ...pathOnly, workspace_kind: 'assistant' }, selectedSsh, [sshRow]), false);
});

test('Claw sessions and assistant entries share one icon kind (#2363)', async () => {
assert.equal(sessionIconKind('Claw'), 'assistant');
assert.equal(sessionIconKind('claw'), 'assistant');
assert.equal(sessionIconKind(undefined, 'assistant'), 'assistant');
assert.equal(sessionIconKind('agentic', 'assistant'), 'assistant');
assert.equal(sessionIconKind('Cowork'), 'cowork');
assert.equal(isCoworkAgent('cowork'), true);
assert.equal(sessionIconKind('agentic'), 'code');
assert.equal(sessionIconKind('agentic', 'remote'), 'code');

const page = await readFile(new URL('../src/pages/SessionListPage.tsx', import.meta.url), 'utf8');
const icon = await readFile(new URL('../src/components/SessionTypeIcon.tsx', import.meta.url), 'utf8');
assert.match(icon, /assistant: LucideBot/);
assert.doesNotMatch(page, /AppWindow|function SessionTypeIcon|Bot as LucideBot/);
assert.match(page, /<SessionTypeIcon workspaceKind="assistant"/);
assert.match(page, /renderSessionIcon=\{\(agentType\) => <SessionTypeIcon agentType=\{agentType\} \/>\}/);
});
Loading