Skip to content
Open
5 changes: 5 additions & 0 deletions .changeset/shell-link-open-in-new-tab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@truefoundry/trueforge-ui": patch
---

Allow right-click / open-in-new-tab on sidebar links and table entries via real anchors.
27 changes: 25 additions & 2 deletions packages/trueforge-ui/src/atoms/AgentsLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { AgentOverflowMenu } from './AgentOverflowMenu.js';
import { CreatedByCell } from './CreatedByCell.js';
import { EmptyScreen, EmptyScreenQueryHighlight } from './EmptyScreen.js';
import { auiButtonClass } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { isMobileNavDrawerOpen } from './lib/isMobileNavDrawerOpen.js';
import { mountName } from './lib/mountName.js';
Expand All @@ -33,6 +34,7 @@ import { useSearchAgentsList } from './lib/useSearchAgentsList.js';
import { PageHeader } from './PageHeader.js';
import { Button } from './primitives/Button.js';
import SearchInput from './primitives/SearchInput.js';
import { ShellLink } from './primitives/ShellLink.js';
import { Skeleton } from './primitives/Skeleton.js';
import {
DEFAULT_TABLE_PAGE_SIZE,
Expand Down Expand Up @@ -75,6 +77,8 @@ export type AgentLibraryRowProps = {
onOpenSchedules?: () => void;
onCreateSchedule?: () => void;
onOpen?: () => void;
/** Agent id for the library detail deep link when `onOpen` is set. */
openAgentId?: string;
onTry: () => void;
onEdit: () => void;
onManageSchedules?: () => void;
Expand Down Expand Up @@ -143,15 +147,26 @@ function AgentNameContent({
description,
createdBySubject,
onOpen,
openAgentId,
}: {
name: string;
description: string | null;
createdBySubject?: Subject;
onOpen?: () => void;
openAgentId?: string;
}) {
const nameNode =
onOpen == null ? (
<span className="text-text-primary block truncate font-medium">{name}</span>
) : openAgentId != null ? (
<ShellLink
place={{ type: 'libraryAgent', agentId: openAgentId }}
className="block max-w-full cursor-pointer text-left"
aria-label={`Open ${name}`}
onNavigate={onOpen}
>
<span className="text-text-primary block truncate font-medium">{name}</span>
</ShellLink>
) : (
<button
type="button"
Expand Down Expand Up @@ -370,6 +385,7 @@ export function AgentLibraryRow({
onOpenSchedules,
onCreateSchedule,
onOpen,
openAgentId,
onTry,
onEdit,
onManageSchedules,
Expand Down Expand Up @@ -416,10 +432,15 @@ export function AgentLibraryRow({

const tryButton = (
<PermissionGuard allowed={canUseAgent}>
<Button.Secondary type="button" aria-label={`Try agent ${agent.name}`} size="large" onClick={onTry}>
<ShellLink
place={{ type: 'agent', agentName: agent.name }}
aria-label={`Try agent ${agent.name}`}
className={auiButtonClass({ variant: 'secondary', size: 'large' })}
onNavigate={onTry}
>
<Icon name="play" className="size-3.5" />
Try
</Button.Secondary>
</ShellLink>
</PermissionGuard>
);

Expand All @@ -439,6 +460,7 @@ export function AgentLibraryRow({
description={description}
{...(agent.createdBySubject != null ? { createdBySubject: agent.createdBySubject } : {})}
{...(onOpen != null ? { onOpen } : {})}
{...(openAgentId != null ? { openAgentId } : {})}
/>
);

Expand Down Expand Up @@ -724,6 +746,7 @@ export function AgentsLibrary({ onSelectAgent, headerStart }: AgentsLibraryProps
: {})}
{...(canOpenAgentDetails && agentId != null
? {
openAgentId: agentId,
onOpen: () => {
track(AnalyticsEvents.Library.AGENT_DETAILS_OPENED, {
agent_id: agentId,
Expand Down
9 changes: 5 additions & 4 deletions packages/trueforge-ui/src/atoms/AgentsLibraryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useOptionalShellMode } from '../server/ShellModeContext.js';
import { auiButtonClass, sidebarButtonRadiusClassName, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { SEARCH_AGENTS_PAGE_SIZE } from './lib/useSearchAgentsList.js';
import { ShellLink } from './primitives/ShellLink.js';

export type AgentsLibraryButtonProps = {
className?: string;
Expand Down Expand Up @@ -51,8 +52,8 @@ export function AgentsLibraryButton({ className, compact = false }: AgentsLibrar

return (
<div className={cn('relative min-w-0', compact ? 'flex justify-center' : 'w-full', className)}>
<button
type="button"
<ShellLink
place={{ type: 'library' }}
aria-label={compact ? 'Agents' : undefined}
title={compact ? 'Agents' : undefined}
aria-current={libraryOpen ? 'page' : undefined}
Expand All @@ -66,7 +67,7 @@ export function AgentsLibraryButton({ className, compact = false }: AgentsLibrar
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
onNavigate={() => {
if (!libraryOpen) track(AnalyticsEvents.Library.OPENED);
shell?.setLibraryOpen(true);
}}
Expand All @@ -85,7 +86,7 @@ export function AgentsLibraryButton({ className, compact = false }: AgentsLibrar
<Icon name="chevron-right" className="ml-auto size-3.5 shrink-0 opacity-60" />
</>
)}
</button>
</ShellLink>
</div>
);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/trueforge-ui/src/atoms/EnvironmentsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useOptionalShellMode } from '../server/ShellModeContext.js';
import { isEnvironmentsChromeEnabled } from '../server/serverChrome.js';
import { auiButtonClass, sidebarButtonRadiusClassName, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { ShellLink } from './primitives/ShellLink.js';

export type EnvironmentsButtonProps = {
className?: string;
Expand All @@ -28,8 +29,8 @@ export function EnvironmentsButton({ className, compact = false }: EnvironmentsB

return (
<div className={cn('relative min-w-0', compact ? 'flex justify-center' : 'w-full', className)}>
<button
type="button"
<ShellLink
place={{ type: 'environments' }}
aria-label={compact ? 'Environments' : undefined}
title={compact ? 'Environments' : undefined}
aria-current={open ? 'page' : undefined}
Expand All @@ -43,7 +44,7 @@ export function EnvironmentsButton({ className, compact = false }: EnvironmentsB
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
onNavigate={() => {
if (!open) track(AnalyticsEvents.Environment.PAGE_OPENED);
shell.setEnvironmentsOpen(!open);
}}
Expand All @@ -57,7 +58,7 @@ export function EnvironmentsButton({ className, compact = false }: EnvironmentsB
<Icon name="chevron-right" className="ml-auto size-3.5 shrink-0 opacity-60" />
</>
)}
</button>
</ShellLink>
</div>
);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/trueforge-ui/src/atoms/SchedulesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useOptionalShellMode } from '../server/ShellModeContext.js';
import { isSchedulesChromeEnabled } from '../server/serverChrome.js';
import { auiButtonClass, sidebarButtonRadiusClassName, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { ShellLink } from './primitives/ShellLink.js';

export type SchedulesButtonProps = {
className?: string;
Expand All @@ -26,8 +27,8 @@ export function SchedulesButton({ className, compact = false }: SchedulesButtonP

return (
<div className={cn('relative min-w-0', compact ? 'flex justify-center' : 'w-full', className)}>
<button
type="button"
<ShellLink
place={{ type: 'schedules' }}
aria-label={compact ? 'Schedules' : undefined}
title={compact ? 'Schedules' : undefined}
aria-current={open ? 'page' : undefined}
Expand All @@ -41,7 +42,7 @@ export function SchedulesButton({ className, compact = false }: SchedulesButtonP
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
onNavigate={() => {
if (!open) track(AnalyticsEvents.Schedule.PAGE_OPENED);
shell.setSchedulesOpen(!open);
}}
Expand All @@ -55,7 +56,7 @@ export function SchedulesButton({ className, compact = false }: SchedulesButtonP
<Icon name="chevron-right" className="ml-auto size-3.5 shrink-0 opacity-60" />
</>
)}
</button>
</ShellLink>
</div>
);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/trueforge-ui/src/atoms/SessionsBrowserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { isSessionsChromeEnabled } from '../server/serverChrome.js';
import { defaultSessionTimeRange, readSessionShareSearch } from '../utils/sessionShareUrl.js';
import { auiButtonClass, sidebarButtonRadiusClassName, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { ShellLink } from './primitives/ShellLink.js';

export type SessionsBrowserButtonProps = {
className?: string;
Expand All @@ -28,8 +29,8 @@ export function SessionsBrowserButton({ className, compact = false }: SessionsBr

return (
<div className={cn('relative min-w-0', compact ? 'flex justify-center' : 'w-full', className)}>
<button
type="button"
<ShellLink
place={{ type: 'sessionsBrowser' }}
aria-label={compact ? 'Sessions' : undefined}
title={compact ? 'Sessions' : undefined}
aria-current={sessionsOpen ? 'page' : undefined}
Expand All @@ -43,7 +44,7 @@ export function SessionsBrowserButton({ className, compact = false }: SessionsBr
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
onNavigate={() => {
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
if (!sessionsOpen) {
track(AnalyticsEvents.SessionsBrowser.OPENED);
const share = readSessionShareSearch(window.location.search);
Expand All @@ -66,7 +67,7 @@ export function SessionsBrowserButton({ className, compact = false }: SessionsBr
<Icon name="chevron-right" className="ml-auto size-3.5 shrink-0 opacity-60" />
</>
)}
</button>
</ShellLink>
</div>
);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/trueforge-ui/src/atoms/ShellActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useSlot } from '../theme/SlotsProvider.js';
import { useTheme } from '../theme/ThemeProvider.js';
import { auiButtonClass, sidebarRailButtonClassName } from './lib/buttonClasses.js';
import { cn } from './lib/cn.js';
import { ShellLink } from './primitives/ShellLink.js';

export function ShellActions({
className,
Expand Down Expand Up @@ -75,8 +76,8 @@ export function ShellActions({
{labeled ? <span className="text-center">{themeLabel}</span> : null}
</button>
{shell != null && settingsChromeEnabled ? (
<button
type="button"
<ShellLink
place={{ type: 'settings' }}
aria-label="Settings"
title="Settings"
aria-expanded={shell.settingsOpen}
Expand All @@ -91,15 +92,15 @@ export function ShellActions({
'bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text',
),
})}
onClick={() => {
onNavigate={() => {
if (!shell.settingsOpen) track(AnalyticsEvents.Settings.OPENED);
shell.setSettingsOpen(true);
onAction?.();
}}
>
<Icon name="settings" size={labeled ? 14 : undefined} />
{labeled ? <span className="text-center">Settings</span> : null}
</button>
</ShellLink>
) : null}
<ActionSlot />
</div>
Expand Down
77 changes: 48 additions & 29 deletions packages/trueforge-ui/src/atoms/ThreadListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import {
lastTurnStatusLabel,
} from './lib/threadListMeta.js';
import { useIsMobile } from './lib/useIsMobile.js';
import { ShellLink } from './primitives/ShellLink.js';
import { Tooltip } from './primitives/Tooltip.js';

export type ThreadListRowProps = {
title: string;
active: boolean;
onSelect: () => void;
/** Session deep-link href for right-click / open-in-new-tab. */
href?: string;
/** Named-agent label under the title (from session.agentName). */
agentName?: string;
/** Last-turn status for trailing status dot / running title shimmer. */
Expand Down Expand Up @@ -78,6 +81,7 @@ export function ThreadListRow({
title,
active,
onSelect,
href,
agentName,
lastTurnStatus,
lastMessageAt,
Expand All @@ -93,6 +97,31 @@ export function ThreadListRow({
// Paused/error → status dot; running → jumping dots; otherwise relative age.
const relative = !running && statusDotClass == null ? age : undefined;
const hasTrailing = running || relative != null || statusDotClass != null || actions != null;
const titleClassName = auiButtonClass({
variant: 'ghost',
className: cn(
'!justify-start h-auto min-h-8 min-w-0 flex-1 overflow-hidden rounded-[0.75rem] px-2.5 py-1.5 text-left font-normal shadow-none',
'bg-transparent hover:bg-transparent hover:text-inherit',
active ? 'text-dropdown-selected-item-text' : 'text-inherit',
),
});
const titleContent = (
<span className="min-w-0 flex-1">
<span className="flex min-w-0 items-center gap-1.5">
<span className={cn('truncate text-sm font-normal text-text-primary', running && 'aui-text-shimmer')}>
{title}
</span>
{/* Mobile: keep the paused/error dot next to the title when actions own the trailing slot. */}
{statusDotClass != null && actions != null ? (
<span data-slot="session-status-dot" className="shrink-0 md:hidden">
<StatusDot className="size-1.5" colorClassName={statusDotClass} pulse={paused} />
</span>
) : null}
{statusLabel != null ? <span className="sr-only">{statusLabel}</span> : null}
</span>
{agentName != null ? <ThreadListAgentName agentName={agentName} /> : null}
</span>
);

const row = (
<div
Expand All @@ -106,35 +135,25 @@ export function ThreadListRow({
className,
)}
>
<button
type="button"
onClick={onSelect}
style={{ borderRadius: 'var(--thread-list-item-radius, 0.75rem)' }}
className={auiButtonClass({
variant: 'ghost',
className: cn(
'!justify-start h-auto min-h-8 min-w-0 flex-1 overflow-hidden rounded-[0.75rem] px-2.5 py-1.5 text-left font-normal shadow-none',
'bg-transparent hover:bg-transparent hover:text-inherit',
active ? 'text-dropdown-selected-item-text' : 'text-inherit',
),
})}
>
<span className="min-w-0 flex-1">
<span className="flex min-w-0 items-center gap-1.5">
<span className={cn('truncate text-sm font-normal text-text-primary', running && 'aui-text-shimmer')}>
{title}
</span>
{/* Mobile: keep the paused/error dot next to the title when actions own the trailing slot. */}
{statusDotClass != null && actions != null ? (
<span data-slot="session-status-dot" className="shrink-0 md:hidden">
<StatusDot className="size-1.5" colorClassName={statusDotClass} pulse={paused} />
</span>
) : null}
{statusLabel != null ? <span className="sr-only">{statusLabel}</span> : null}
</span>
{agentName != null ? <ThreadListAgentName agentName={agentName} /> : null}
</span>
</button>
{href != null ? (
<ShellLink
href={href}
onNavigate={onSelect}
style={{ borderRadius: 'var(--thread-list-item-radius, 0.75rem)' }}
className={titleClassName}
>
{titleContent}
</ShellLink>
) : (
<button
type="button"
onClick={onSelect}
style={{ borderRadius: 'var(--thread-list-item-radius, 0.75rem)' }}
className={titleClassName}
>
{titleContent}
</button>
)}
{hasTrailing ? (
<div className="relative mr-1 size-7 shrink-0">
{statusDotClass != null ? (
Expand Down
Loading
Loading