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.

fix(ux): make shift click always open in new split if possible (#6462)

Seamuse6825ecc1d04
diff --git a/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx b/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
index c71522be82..c8f5fa97b3 100644
--- a/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
+++ b/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
@@ -128,8 +128,8 @@ function DetailsSectionContent() {
}
export function FolderLink(props: { projectId: string; projectName: string }) {
- const open = createCallback((e: MouseEvent) => {
- openDocument('project', props.projectId, undefined, !e.shiftKey);
+ const open = createCallback(() => {
+ openDocument('project', props.projectId, undefined, true);
});
const navHandlers = useSplitNavigationHandler<HTMLSpanElement>(open);
diff --git a/apps/web/src/features/agents-view/components/AgentResourceList.tsx b/apps/web/src/features/agents-view/components/AgentResourceList.tsx
index f9bc8690bd..fc7f9f6895 100644
--- a/apps/web/src/features/agents-view/components/AgentResourceList.tsx
+++ b/apps/web/src/features/agents-view/components/AgentResourceList.tsx
@@ -56,11 +56,14 @@ export function AgentResourceList(props: { page: 'routines' | 'skills' }) {
<Button
variant="ghost"
class="h-12 w-full justify-start gap-3 rounded-xl px-3 font-normal"
- onClick={() =>
- layout.openWithSplit({
- type: props.page === 'routines' ? 'automation' : 'skill',
- id: item.id,
- })
+ onClick={(event) =>
+ layout.openWithSplit(
+ {
+ type: props.page === 'routines' ? 'automation' : 'skill',
+ id: item.id,
+ },
+ { preferNewSplit: event.shiftKey }
+ )
}
>
<Dynamic
diff --git a/apps/web/src/features/block-automation/component/Automation.tsx b/apps/web/src/features/block-automation/component/Automation.tsx
index 09cc917f30..e43b5bdbf7 100644
--- a/apps/web/src/features/block-automation/component/Automation.tsx
+++ b/apps/web/src/features/block-automation/component/Automation.tsx
@@ -54,7 +54,7 @@ type HistoryRecord = {
};
function HistoryRow(props: { record: HistoryRecord }) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const chatId = () => props.record.resource_id ?? undefined;
const chatQuery = useChatQuery(chatId);
const name = () =>
@@ -73,9 +73,13 @@ function HistoryRow(props: { record: HistoryRecord }) {
'flex items-center gap-2 border-b border-edge-muted px-3 py-2 text-sm',
clickable() ? 'cursor-default hover:bg-hover' : 'cursor-default'
)}
- onClick={() => {
+ onClick={(event) => {
const id = chatId();
- if (id) replaceOrInsertSplit({ type: 'chat', id });
+ if (id)
+ openWithSplit(
+ { type: 'chat', id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
}}
>
<div class="size-4 shrink-0">
diff --git a/apps/web/src/features/block-call/component/CallRecording/CallRecordingParticipants.tsx b/apps/web/src/features/block-call/component/CallRecording/CallRecordingParticipants.tsx
index 435121b07d..01e753a07b 100644
--- a/apps/web/src/features/block-call/component/CallRecording/CallRecordingParticipants.tsx
+++ b/apps/web/src/features/block-call/component/CallRecording/CallRecordingParticipants.tsx
@@ -11,7 +11,7 @@ import { dedupeCallRecordingParticipants } from './call-recording-utils';
export function CallRecordingParticipantsSection(props: {
record: Accessor<CallRecord>;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation();
const participants = createMemo(() =>
dedupeCallRecordingParticipants(
@@ -20,12 +20,15 @@ export function CallRecordingParticipantsSection(props: {
)
);
- const openDirectMessage = (participantId: string) => {
+ const openDirectMessage = (participantId: string, event: MouseEvent) => {
getOrCreateDmMutation.mutate(
{ recipient_id: participantId },
{
onSuccess: ({ channel_id }) => {
- replaceOrInsertSplit({ type: 'channel', id: channel_id });
+ openWithSplit(
+ { type: 'channel', id: channel_id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
},
}
);
@@ -46,7 +49,7 @@ export function CallRecordingParticipantsSection(props: {
type="button"
role="listitem"
class="inline-flex items-center gap-1.5 rounded-full border border-edge-muted/50 py-1 pr-2.5 pl-1 text-sm text-ink transition-colors hover:bg-hover"
- onClick={() => openDirectMessage(participant.userId)}
+ onClick={(event) => openDirectMessage(participant.userId, event)}
>
<UserIcon id={participant.userId} size="sm" isDeleted={false} />
<span class="truncate max-w-48">
diff --git a/apps/web/src/features/block-canvas/component/nodes/EntityMention.tsx b/apps/web/src/features/block-canvas/component/nodes/EntityMention.tsx
index 5292bea3f5..047848489a 100644
--- a/apps/web/src/features/block-canvas/component/nodes/EntityMention.tsx
+++ b/apps/web/src/features/block-canvas/component/nodes/EntityMention.tsx
@@ -92,7 +92,7 @@ export function File(props: { node: EntityMentionNode; mode: RenderMode }) {
const blockId = useBlockId();
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const [selfMouseDownPosition, setSelfMouseDownPosition] =
createSignal<Vector2>();
@@ -184,10 +184,13 @@ export function File(props: { node: EntityMentionNode; mode: RenderMode }) {
if (
matches(item(), (i) => !i.loading && i.access === 'access')
) {
- replaceOrInsertSplit({
- type: blockName() as BlockName,
- id: props.node.file,
- });
+ openWithSplit(
+ {
+ type: blockName() as BlockName,
+ id: props.node.file,
+ },
+ { activate: true, preferNewSplit: e.shiftKey }
+ );
}
}}
>
diff --git a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
index 89bcb9bff9..736d90a312 100644
--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -404,8 +404,8 @@ function DetailsGrid(props: {
}
function FolderLink(props: { projectId: string; projectName: string }) {
- const open = createCallback((e: MouseEvent) => {
- openDocument('project', props.projectId, undefined, !e.shiftKey);
+ const open = createCallback(() => {
+ openDocument('project', props.projectId, undefined, true);
});
const navHandlers = useSplitNavigationHandler<HTMLSpanElement>(open);
return (
diff --git a/apps/web/src/features/calendar/components/EventDetails.tsx b/apps/web/src/features/calendar/components/EventDetails.tsx
index 4c8e5d59fb..e355765285 100644
--- a/apps/web/src/features/calendar/components/EventDetails.tsx
+++ b/apps/web/src/features/calendar/components/EventDetails.tsx
@@ -521,7 +521,12 @@ export function EventDetails(props: {
event.preventDefault();
const target = parseMacroAppLink(anchor.href);
if (target) {
- openDocument(target.blockName, target.documentId);
+ openDocument(
+ target.blockName,
+ target.documentId,
+ undefined,
+ event.shiftKey
+ );
return;
}
openExternalUrl(anchor.href);
diff --git a/apps/web/src/features/channel/Attachments/AttachmentEntityList.tsx b/apps/web/src/features/channel/Attachments/AttachmentEntityList.tsx
index fd003b83ec..f16ae12fa7 100644
--- a/apps/web/src/features/channel/Attachments/AttachmentEntityList.tsx
+++ b/apps/web/src/features/channel/Attachments/AttachmentEntityList.tsx
@@ -8,7 +8,7 @@ export type AttachmentEntityListRow = {
entity: EntityData;
timestamp?: DateValue | null;
senderId?: string;
- onClick?: () => void;
+ onClick?: (event: MouseEvent) => void;
};
export function AttachmentEntityList(props: {
diff --git a/apps/web/src/features/channel/Attachments/AttachmentEntityRow.tsx b/apps/web/src/features/channel/Attachments/AttachmentEntityRow.tsx
index f2987ac464..50ce6e957c 100644
--- a/apps/web/src/features/channel/Attachments/AttachmentEntityRow.tsx
+++ b/apps/web/src/features/channel/Attachments/AttachmentEntityRow.tsx
@@ -7,12 +7,12 @@ export function AttachmentEntityRow(props: {
entity: EntityData;
timestamp?: DateValue | null;
senderId?: string;
- onClick?: () => void;
+ onClick?: (event: MouseEvent) => void;
}) {
return (
<Entity.Root
entity={props.entity}
- onClick={() => props.onClick?.()}
+ onClick={(event) => props.onClick?.(event)}
class="flex items-center gap-2 min-h-10 px-6 text-sm hover:bg-hover w-full"
>
<div class="size-4 shrink-0">
diff --git a/apps/web/src/features/channel/Attachments/ChannelAttachmentEntitySection.tsx b/apps/web/src/features/channel/Attachments/ChannelAttachmentEntitySection.tsx
index 7171551662..f3bd917201 100644
--- a/apps/web/src/features/channel/Attachments/ChannelAttachmentEntitySection.tsx
+++ b/apps/web/src/features/channel/Attachments/ChannelAttachmentEntitySection.tsx
@@ -95,9 +95,12 @@ export function ChannelAttachmentEntitySection(props: { channelId: string }) {
return map;
});
- const { replaceOrInsertSplit } = useSplitLayout();
- const handleEntityClick = (entity: EntityData) =>
- replaceOrInsertSplit(getEntityClickContent(entity));
+ const { openWithSplit } = useSplitLayout();
+ const handleEntityClick = (entity: EntityData, event: MouseEvent) =>
+ openWithSplit(getEntityClickContent(entity), {
+ activate: true,
+ preferNewSplit: event.shiftKey,
+ });
const rows = createMemo<AttachmentEntityListRow[]>(() => {
const entities = soupQuery.data?.entities ?? [];
@@ -115,7 +118,7 @@ export function ChannelAttachmentEntitySection(props: { channelId: string }) {
entity,
timestamp: attachment?.created_at,
senderId: attachment?.sender_id,
- onClick: () => handleEntityClick(entity),
+ onClick: (event) => handleEntityClick(entity, event),
};
});
});
diff --git a/apps/web/src/features/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx b/apps/web/src/features/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx
index 348877ea82..c7d671fb60 100644
--- a/apps/web/src/features/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx
+++ b/apps/web/src/features/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx
@@ -49,7 +49,7 @@ export function InCallParticipantNameRow(props: {
/** When false, the row is display-only (no DM on click). Default true. */
allowOpenDm?: boolean;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation({
onError: () => toast.failure('Could not open direct message'),
});
@@ -69,7 +69,7 @@ export function InCallParticipantNameRow(props: {
const allowDm = () => props.allowOpenDm !== false;
const isInteractive = () => isRemote() && allowDm();
- const openDm = () => {
+ const openDm = (event: MouseEvent | KeyboardEvent) => {
if (props.member.kind !== 'remote') return;
const { identity } = props.member.participant;
if (!identity.startsWith('macro|') || !identity.slice(6).includes('@'))
@@ -79,7 +79,10 @@ export function InCallParticipantNameRow(props: {
{
onSuccess: ({ channel_id }) => {
props.onClose();
- replaceOrInsertSplit({ type: 'channel', id: channel_id });
+ openWithSplit(
+ { type: 'channel', id: channel_id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
},
}
);
@@ -91,7 +94,7 @@ export function InCallParticipantNameRow(props: {
tabIndex={isInteractive() ? 0 : undefined}
onClick={isInteractive() ? openDm : undefined}
onKeyDown={
- isInteractive() ? (e) => e.key === 'Enter' && void openDm() : undefined
+ isInteractive() ? (e) => e.key === 'Enter' && void openDm(e) : undefined
}
class={cn(
'flex min-w-0 items-center gap-2 rounded-xs p-1',
diff --git a/apps/web/src/features/channel/Participants/ChannelParticipantsTab.tsx b/apps/web/src/features/channel/Participants/ChannelParticipantsTab.tsx
index 0e5f99f587..9e187d428b 100644
--- a/apps/web/src/features/channel/Participants/ChannelParticipantsTab.tsx
+++ b/apps/web/src/features/channel/Participants/ChannelParticipantsTab.tsx
@@ -29,7 +29,7 @@ export function ChannelParticipantsTab(props: {
onCreateBot: () => void;
onOpenBot: (botId: string) => void;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const userId = useUserId();
const channel = useChannel(props.channelId);
const channelType = useChannelType(props.channelId);
@@ -127,12 +127,15 @@ export function ChannelParticipantsTab(props: {
});
};
- const openDirectMessage = (participantId: string) => {
+ const openDirectMessage = (participantId: string, event: MouseEvent) => {
getOrCreateDmMutation.mutate(
{ recipient_id: participantId },
{
onSuccess: ({ channel_id }) => {
- replaceOrInsertSplit({ type: 'channel', id: channel_id });
+ openWithSplit(
+ { type: 'channel', id: channel_id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
},
}
);
diff --git a/apps/web/src/features/channel/Participants/ParticipantsList.tsx b/apps/web/src/features/channel/Participants/ParticipantsList.tsx
index 4b11b3e902..f2e97cd686 100644
--- a/apps/web/src/features/channel/Participants/ParticipantsList.tsx
+++ b/apps/web/src/features/channel/Participants/ParticipantsList.tsx
@@ -10,7 +10,10 @@ export function ParticipantsList(props: {
searchQuery: Accessor<string>;
currentUserId?: string;
editable: boolean;
- onParticipantClick: (participantId: string) => void | Promise<void>;
+ onParticipantClick: (
+ participantId: string,
+ event: MouseEvent
+ ) => void | Promise<void>;
onRemoveParticipant: (participantId: string) => void;
}) {
const [listWrapperRef, setListWrapperRef] = createSignal<HTMLDivElement>();
@@ -47,7 +50,9 @@ export function ParticipantsList(props: {
currentUserId={props.currentUserId}
editable={props.editable}
isLast={index() === props.participants().length - 1}
- onClick={() => props.onParticipantClick(participant.user_id)}
+ onClick={(event) =>
+ props.onParticipantClick(participant.user_id, event)
+ }
onRemove={() => props.onRemoveParticipant(participant.user_id)}
/>
)}
diff --git a/apps/web/src/features/channel/Participants/ParticipantsListItem.tsx b/apps/web/src/features/channel/Participants/ParticipantsListItem.tsx
index 35822c27f5..2e14d9eaba 100644
--- a/apps/web/src/features/channel/Participants/ParticipantsListItem.tsx
+++ b/apps/web/src/features/channel/Participants/ParticipantsListItem.tsx
@@ -11,7 +11,7 @@ export function ParticipantsListItem(props: {
currentUserId?: string;
editable: boolean;
isLast?: boolean;
- onClick: () => void | Promise<void>;
+ onClick: (event: MouseEvent) => void | Promise<void>;
onRemove: () => void;
}) {
const canRemove =
@@ -23,7 +23,7 @@ export function ParticipantsListItem(props: {
async (event) => {
event.preventDefault();
event.stopPropagation();
- await props.onClick();
+ await props.onClick(event);
}
);
diff --git a/apps/web/src/features/companies/Company/CompanyContactsSection.tsx b/apps/web/src/features/companies/Company/CompanyContactsSection.tsx
index 1eae797368..9e66f651f1 100644
--- a/apps/web/src/features/companies/Company/CompanyContactsSection.tsx
+++ b/apps/web/src/features/companies/Company/CompanyContactsSection.tsx
@@ -8,7 +8,7 @@ export function CompanyContactsSection(props: {
contacts?: CompanyContact[];
}) {
const contacts = () => props.contacts ?? [];
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const [search, setSearch] = createSignal('');
const filtered = createMemo(() => {
@@ -56,11 +56,14 @@ export function CompanyContactsSection(props: {
{(contact) => (
<button
type="button"
- onClick={() =>
- replaceOrInsertSplit({
- type: 'contact',
- id: contact.id,
- })
+ onClick={(event) =>
+ openWithSplit(
+ {
+ type: 'contact',
+ id: contact.id,
+ },
+ { activate: true, preferNewSplit: event.shiftKey }
+ )
}
class="flex min-w-0 flex-col gap-0.5 rounded-md px-1 py-0.5 text-left hover:bg-ink-muted/[0.06]"
>
diff --git a/apps/web/src/features/contacts/Contact/ContactMetadataSection.tsx b/apps/web/src/features/contacts/Contact/ContactMetadataSection.tsx
index 7123493f8d..8fd26203a1 100644
--- a/apps/web/src/features/contacts/Contact/ContactMetadataSection.tsx
+++ b/apps/web/src/features/contacts/Contact/ContactMetadataSection.tsx
@@ -16,15 +16,18 @@ function Field(props: { label: string; children: JSX.Element }) {
export function ContactMetadataSection(props: {
contact?: CrmContactResponse;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
// NIL while the contact is loading — useCompanyQuery's `enabled` gate
// excludes it, so no doomed 404 fires before the real companyId arrives.
const { company } = useCompanyQuery(
() => props.contact?.companyId ?? NIL_UUID
);
- const openCompany = (companyId: string) => {
- replaceOrInsertSplit({ type: 'company', id: companyId });
+ const openCompany = (companyId: string, event: MouseEvent) => {
+ openWithSplit(
+ { type: 'company', id: companyId },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
return (
@@ -40,7 +43,7 @@ export function ContactMetadataSection(props: {
<Field label="Company">
<button
type="button"
- onClick={() => openCompany(contact().companyId)}
+ onClick={(event) => openCompany(contact().companyId, event)}
class="text-left text-sm text-link hover:text-link-hover hover:underline"
>
{company()?.name ?? 'Open company'}
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
index 0862008610..1a5b9514ef 100644
--- a/apps/web/src/features/drive-view/drive-view.tsx
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -56,14 +56,14 @@ export type DriveViewProps = {
function DriveFavorite(props: {
favorite: Favorite;
- onOpen: (favorite: Favorite) => void;
+ onOpen: (favorite: Favorite, event: MouseEvent) => void;
}) {
const name = useFavoriteDisplayName(props.favorite);
return (
<ViewSidebar.Item
class="font-normal"
title={name()}
- onClick={() => props.onOpen(props.favorite)}
+ onClick={(event) => props.onOpen(props.favorite, event)}
>
<FavoriteIcon favorite={props.favorite} class="size-4 shrink-0" />
<span class="truncate">{name()}</span>
@@ -246,11 +246,13 @@ export function DriveView(props: DriveViewProps) {
{(favorite) => (
<DriveFavorite
favorite={favorite}
- onOpen={(item) => {
- if (item.entityType === 'project') selectFolder(item.entityId);
+ onOpen={(item, event) => {
+ if (item.entityType === 'project' && !event.shiftKey)
+ selectFolder(item.entityId);
else
layout.openWithSplit(favoriteSplitContent(item), {
referredFrom: 'sidebar',
+ preferNewSplit: event.shiftKey,
});
}}
/>
diff --git a/apps/web/src/features/home/home-hub.tsx b/apps/web/src/features/home/home-hub.tsx
index c20081cf4b..e6caa5b592 100644
--- a/apps/web/src/features/home/home-hub.tsx
+++ b/apps/web/src/features/home/home-hub.tsx
@@ -89,7 +89,10 @@ export function RecommendedSection() {
);
};
- const openRecommendation = async (item: RecommendedItem) => {
+ const openRecommendation = async (
+ item: RecommendedItem,
+ event: MouseEvent
+ ) => {
const splitManager = globalSplitManager();
if (!splitManager) return;
@@ -101,7 +104,11 @@ export function RecommendedSection() {
}
if (notification) {
- const result = await openNotification(notification, splitManager);
+ const result = await openNotification(
+ notification,
+ splitManager,
+ event.shiftKey
+ );
if (result.isOk()) {
await notificationSource.markAsRead(notification);
return;
@@ -112,13 +119,13 @@ export function RecommendedSection() {
.with('email_thread', () =>
splitManager.openWithSplit(
{ type: 'email', id: item.entityId },
- { activate: true }
+ { activate: true, preferNewSplit: event.shiftKey }
)
)
.with('channel', 'chat', 'call', 'project', (entityType) =>
splitManager.openWithSplit(
{ type: entityType, id: item.entityId },
- { activate: true }
+ { activate: true, preferNewSplit: event.shiftKey }
)
)
.with('document', () => navigate(LIST_VIEW_PATHS.documents))
@@ -178,7 +185,7 @@ export function RecommendedSection() {
<RecommendedRow
item={item}
onSelect={() => selectRecommendation(item)}
- onOpen={() => void openRecommendation(item)}
+ onOpen={(event) => void openRecommendation(item, event)}
/>
)}
</For>
@@ -289,7 +296,7 @@ export function GettingStartedSection(props: { preferences: HomePreferences }) {
function RecommendedRow(props: {
item: RecommendedItem;
onSelect: () => void;
- onOpen: () => void;
+ onOpen: (event: MouseEvent) => void;
}) {
const status = () => STATUS[props.item.action];
const iconType = () => {
@@ -325,7 +332,7 @@ function RecommendedRow(props: {
class="rounded-lg px-2 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
onClick={(event) => {
event.stopPropagation();
- props.onOpen();
+ props.onOpen(event);
}}
aria-label={`Open ${props.item.title}`}
>
diff --git a/apps/web/src/features/home/home-recent-sessions.test.tsx b/apps/web/src/features/home/home-recent-sessions.test.tsx
index 1d6824a6f6..75bf444667 100644
--- a/apps/web/src/features/home/home-recent-sessions.test.tsx
+++ b/apps/web/src/features/home/home-recent-sessions.test.tsx
@@ -1,15 +1,20 @@
-import { cleanup, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { afterEach, expect, it, vi } from 'vitest';
import { RecentSessionsSection } from './home-recent-sessions';
+const navigation = vi.hoisted(() => ({
+ replace: vi.fn(),
+ openWithSplit: vi.fn(),
+}));
+
vi.mock('@app/features/next-soup/filters/query-filters', () => ({
QUERY_FILTERS_BASE: {},
}));
vi.mock('@app/signal/splitLayout', () => ({
- globalSplitManager: () => undefined,
+ globalSplitManager: () => ({ openWithSplit: navigation.openWithSplit }),
}));
vi.mock('@components/app/split-layout/layoutUtils', () => ({
- useSplitPanel: () => undefined,
+ useSplitPanel: () => ({ handle: { replace: navigation.replace } }),
}));
vi.mock('@core/component/AI/util/storage', () => ({
getChatStoredModel: () => undefined,
@@ -37,7 +42,10 @@ vi.mock('@queries/soup/items', () => ({
}),
}));
-afterEach(cleanup);
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
it('uses saved providers for recent chats without requiring a local draft', () => {
render(() => <RecentSessionsSection />);
@@ -57,3 +65,21 @@ it('uses saved providers for recent chats without requiring a local draft', () =
.querySelector('[data-entity-type="chat"]')
).not.toBeNull();
});
+
+it('keeps normal clicks in the source split and opens Shift-clicks in a new split', () => {
+ render(() => <RecentSessionsSection />);
+ const button = screen.getByRole('button', { name: 'GPT conversation' });
+ fireEvent.click(button);
+ expect(navigation.replace).toHaveBeenCalledWith({
+ next: { type: 'chat', id: 'gpt-chat' },
+ });
+ expect(navigation.openWithSplit).not.toHaveBeenCalled();
+ navigation.replace.mockClear();
+
+ fireEvent.click(button, { shiftKey: true });
+ expect(navigation.replace).not.toHaveBeenCalled();
+ expect(navigation.openWithSplit).toHaveBeenCalledWith(
+ { type: 'chat', id: 'gpt-chat' },
+ { activate: true, preferNewSplit: true }
+ );
+});
diff --git a/apps/web/src/features/home/home-recent-sessions.tsx b/apps/web/src/features/home/home-recent-sessions.tsx
index 00129042e5..fac2b4c3cb 100644
--- a/apps/web/src/features/home/home-recent-sessions.tsx
+++ b/apps/web/src/features/home/home-recent-sessions.tsx
@@ -47,13 +47,13 @@ function RecentSessionsContent(props: { limit?: number }) {
const sessions = useRecentChatSessions(props.limit);
const splitPanel = useSplitPanel();
- const openChat = (id: string) => {
- if (splitPanel) {
+ const openChat = (id: string, event: MouseEvent) => {
+ if (splitPanel && !event.shiftKey) {
splitPanel.handle.replace({ next: { type: 'chat', id } });
} else {
globalSplitManager()?.openWithSplit(
{ type: 'chat', id },
- { activate: true }
+ { activate: true, preferNewSplit: event.shiftKey }
);
}
};
@@ -70,7 +70,7 @@ function RecentSessionsContent(props: { limit?: number }) {
<button
type="button"
class="group flex w-full items-center gap-3.5 rounded-xl border border-edge-muted bg-active px-4 py-3 text-left transition-colors hover:bg-hover"
- onClick={() => openChat(session.id)}
+ onClick={(event) => openChat(session.id, event)}
>
<ChatProviderIcon
id={session.id}
diff --git a/apps/web/src/lib/core/component/AI/component/tool/ListEntities.tsx b/apps/web/src/lib/core/component/AI/component/tool/ListEntities.tsx
index 1c994c4bba..c6464ffe0f 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/ListEntities.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/ListEntities.tsx
@@ -71,32 +71,47 @@ const ListEntitiesToolResponse = (props: {
}
};
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const getClickHandler = (item: ListEntitiesItem) => {
switch (item.type) {
case 'document':
- return () => {
- replaceOrInsertSplit({
- type: fileTypeToBlockName(item.subType ?? item.fileType),
- id: item.id,
- });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ {
+ type: fileTypeToBlockName(item.subType ?? item.fileType),
+ id: item.id,
+ },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'aiChat':
- return () => {
- replaceOrInsertSplit({ type: 'chat', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'chat', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'project':
- return () => {
- replaceOrInsertSplit({ type: 'project', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'project', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'email':
- return () => {
- replaceOrInsertSplit({ type: 'email', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'email', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'channel':
- return () => {
- replaceOrInsertSplit({ type: 'channel', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'channel', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
default:
return undefined;
diff --git a/apps/web/src/lib/core/component/AI/component/tool/ReadProject.tsx b/apps/web/src/lib/core/component/AI/component/tool/ReadProject.tsx
index 92822ae01e..a3bf3aec4c 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/ReadProject.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/ReadProject.tsx
@@ -34,24 +34,33 @@ const ReadProjectToolResponse = (props: { items: ReadProjectItem[] }) => {
}
};
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const getClickHandler = (item: ReadProjectItem) => {
switch (item.itemType) {
case 'document':
- return () => {
- replaceOrInsertSplit({
- type: fileTypeToBlockName(item.fileType),
- id: item.id,
- });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ {
+ type: fileTypeToBlockName(item.fileType),
+ id: item.id,
+ },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'chat':
- return () => {
- replaceOrInsertSplit({ type: 'chat', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'chat', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
case 'project':
- return () => {
- replaceOrInsertSplit({ type: 'project', id: item.id });
+ return (event: MouseEvent) => {
+ openWithSplit(
+ { type: 'project', id: item.id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
};
default:
return undefined;
diff --git a/apps/web/src/lib/core/component/AI/component/tool/Search.tsx b/apps/web/src/lib/core/component/AI/component/tool/Search.tsx
index 0678e87210..7b6f47dfc7 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/Search.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/Search.tsx
@@ -31,7 +31,10 @@ const getToolSearchQuery = (
return 'query' in ctx.tool.data ? ctx.tool.data.query : ctx.tool.data.name;
};
-function SearchResultRow(props: { entity: SearchEntity; onClick: () => void }) {
+function SearchResultRow(props: {
+ entity: SearchEntity;
+ onClick: (event: MouseEvent) => void;
+}) {
const hit = () => props.entity.search.contentHitData?.[0];
return (
@@ -82,7 +85,7 @@ const UnifiedSearchToolResponse = (props: {
)
);
- const openEntity = async (entity: SearchEntity) => {
+ const openEntity = async (entity: SearchEntity, event: MouseEvent) => {
if (entity.type === 'channel_message') {
const orchestrator = globalSplitManager()?.getOrchestrator();
if (orchestrator) {
@@ -90,7 +93,8 @@ const UnifiedSearchToolResponse = (props: {
orchestrator,
entity.channelId,
entity.messageId,
- entity.threadId
+ entity.threadId,
+ { preferNewSplit: event.shiftKey }
);
return;
}
@@ -108,7 +112,7 @@ const UnifiedSearchToolResponse = (props: {
return (
<SearchResultRow
entity={entity}
- onClick={() => openEntity(entity)}
+ onClick={(event) => openEntity(entity, event)}
/>
);
}}
diff --git a/apps/web/src/lib/core/component/AI/component/tool/SendEmail.tsx b/apps/web/src/lib/core/component/AI/component/tool/SendEmail.tsx
index d0a2ce9ce9..39c25c2e1b 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/SendEmail.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/SendEmail.tsx
@@ -90,21 +90,24 @@ function DraftPreviewButton(props: {
subject: string;
threadId?: string;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
return (
<button
class="text-ink text-xs border border-edge-muted rounded-xs hover:bg-hover flex flex-row h-6 px-2 justify-center items-center"
- onClick={() =>
- replaceOrInsertSplit({
- ...(props.threadId
- ? { type: 'email' as const, id: props.threadId }
- : {
- type: 'component' as const,
- id: 'email-compose',
- params: { draftID: props.draftId },
- }),
- })
+ onClick={(event) =>
+ openWithSplit(
+ {
+ ...(props.threadId
+ ? { type: 'email' as const, id: props.threadId }
+ : {
+ type: 'component' as const,
+ id: 'email-compose',
+ params: { draftID: props.draftId },
+ }),
+ },
+ { activate: true, preferNewSplit: event.shiftKey }
+ )
}
>
<div class="flex justify-start items-center size-3.5 mr-2">
diff --git a/apps/web/src/lib/core/component/AI/component/tool/TextEditorCodeExecution.tsx b/apps/web/src/lib/core/component/AI/component/tool/TextEditorCodeExecution.tsx
index 68deab3d86..d145d66f24 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/TextEditorCodeExecution.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/TextEditorCodeExecution.tsx
@@ -54,7 +54,7 @@ function CreateResult(props: {
result: TextEditorCodeExecutionCreateResult;
toolId: string;
}) {
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const [createdFile, setCreatedFile] = createSignal<CreatedFileInfo | null>(
createdFilesMap[props.toolId] ?? null
);
@@ -78,11 +78,14 @@ function CreateResult(props: {
}
});
- const handleClick = () => {
+ const handleClick = (event: MouseEvent) => {
const file = createdFile();
if (file) {
const blockName = fileTypeToBlockName(file.extension);
- replaceOrInsertSplit({ type: blockName, id: file.documentId });
+ openWithSplit(
+ { type: blockName, id: file.documentId },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
}
};
diff --git a/apps/web/src/lib/core/component/DetailsDrawer.tsx b/apps/web/src/lib/core/component/DetailsDrawer.tsx
index 919ae7001e..b9c90b038e 100644
--- a/apps/web/src/lib/core/component/DetailsDrawer.tsx
+++ b/apps/web/src/lib/core/component/DetailsDrawer.tsx
@@ -149,9 +149,8 @@ function Row(props: { label: string; children: JSX.Element }) {
}
function FolderLink(props: { projectId: string; projectName: string }) {
- const open = createCallback((e: MouseEvent) => {
- // Default: open in new split. Shift-click: replace current split.
- openDocument('project', props.projectId, undefined, !e.shiftKey);
+ const open = createCallback(() => {
+ openDocument('project', props.projectId, undefined, true);
});
const navHandlers = useSplitNavigationHandler<HTMLSpanElement>(open);
return (
diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsx
index 5ee3de2b41..ce51075d99 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx
@@ -527,10 +527,13 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
return undefined;
};
- const openDocument = createCallback(async () => {
+ const openDocument = createCallback(async (event: MouseEvent) => {
const calendarTarget = calendarOpenTarget();
if (calendarTarget) {
- await openCalendarEventSplit(calendarTarget);
+ await openCalendarEventSplit({
+ ...calendarTarget,
+ openInNewSplit: event.shiftKey,
+ });
return;
}
const type = targetBlockType();
@@ -548,6 +551,14 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
return;
}
+ if (event.shiftKey) {
+ splitManager.openWithSplit(
+ { type, id: props.documentInfo.id, params: props.documentInfo.params },
+ { preferNewSplit: true }
+ );
+ return;
+ }
+
splitManager.replaceAllSplits({
type,
id: props.documentInfo.id,
@@ -682,7 +693,7 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
class="min-w-0 text-left wrap-anywhere rounded-sm hover:underline focus-visible:outline-2 focus-visible:outline-accent"
onClick={(event) => {
event.stopPropagation();
- void openDocument();
+ void openDocument(event);
}}
>
{local.name}
diff --git a/apps/web/src/lib/core/component/References.tsx b/apps/web/src/lib/core/component/References.tsx
index 515bd58736..57e7a53638 100644
--- a/apps/web/src/lib/core/component/References.tsx
+++ b/apps/web/src/lib/core/component/References.tsx
@@ -227,7 +227,6 @@ export function References(props: ReferenceProps) {
const blockOrchestrator = useGlobalBlockOrchestrator();
const navigateToItem = ({
- event,
blockId,
blockName,
}: {
@@ -235,17 +234,13 @@ export function References(props: ReferenceProps) {
blockName: BlockName | BlockAlias;
blockId: string;
}) => {
- openWithSplit(
- { type: blockName, id: blockId },
- { preferNewSplit: event?.shiftKey !== true }
- );
+ openWithSplit({ type: blockName, id: blockId }, { preferNewSplit: true });
};
const navigateToMessage = ({
channelId,
messageId,
threadId,
- event,
}: {
event?: KeyboardEvent | MouseEvent;
channelId: string;
@@ -258,7 +253,7 @@ export function References(props: ReferenceProps) {
messageId,
threadId,
{
- preferNewSplit: event?.shiftKey !== true,
+ preferNewSplit: true,
}
);
};
diff --git a/apps/web/src/lib/core/component/UserIcon.tsx b/apps/web/src/lib/core/component/UserIcon.tsx
index 28a903a6c9..09400e9134 100644
--- a/apps/web/src/lib/core/component/UserIcon.tsx
+++ b/apps/web/src/lib/core/component/UserIcon.tsx
@@ -150,17 +150,20 @@ export function UserIcon(props: UserIconProps) {
return props.email;
});
- const { replaceOrInsertSplit } = useSplitLayout();
+ const { openWithSplit } = useSplitLayout();
const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation();
const isConnectedSecondaryInbox = useIsConnectedSecondaryInbox();
- const getOrCreateDm = () => {
+ const getOrCreateDm = (event: MouseEvent) => {
if (!props.id || isConnectedSecondaryInbox(props.id)) return;
getOrCreateDmMutation.mutate(
{ recipient_id: props.id },
{
onSuccess: ({ channel_id }) => {
- replaceOrInsertSplit({ type: 'channel', id: channel_id });
+ openWithSplit(
+ { type: 'channel', id: channel_id },
+ { activate: true, preferNewSplit: event.shiftKey }
+ );
},
}
);
diff --git a/apps/web/src/lib/core/util/openInNewSplit.test.ts b/apps/web/src/lib/core/util/openInNewSplit.test.ts
index 6e82e0b561..84794afe20 100644
--- a/apps/web/src/lib/core/util/openInNewSplit.test.ts
+++ b/apps/web/src/lib/core/util/openInNewSplit.test.ts
@@ -15,8 +15,9 @@ describe('openInNewSplitForMention', () => {
expect(openInNewSplitForMention(false, true)).toBe(true);
});
- it('opens in the current split when Option (alt) is held', () => {
- expect(openInNewSplitForMention(true, true)).toBe(false);
+ it('opens in a new split when Shift is held regardless of the default', () => {
+ expect(openInNewSplitForMention(true, true)).toBe(true);
+ expect(openInNewSplitForMention(true, false)).toBe(true);
});
it('defaults to current split when there is no event (e.g. touch)', () => {
@@ -26,5 +27,6 @@ describe('openInNewSplitForMention', () => {
it('always opens in the current split on touch devices', () => {
vi.mocked(isTouchDevice).mockReturnValue(true);
expect(openInNewSplitForMention(false, true)).toBe(false);
+ expect(openInNewSplitForMention(true, true)).toBe(false);
});
});
diff --git a/apps/web/src/lib/core/util/openInNewSplit.ts b/apps/web/src/lib/core/util/openInNewSplit.ts
index eff777954b..010209f682 100644
--- a/apps/web/src/lib/core/util/openInNewSplit.ts
+++ b/apps/web/src/lib/core/util/openInNewSplit.ts
@@ -5,7 +5,7 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';
*
* For @mention pills we want:
* - default click/enter: open in a new split
- * - holding Option (alt): open in the current split
+ * - Shift-click: open in a new split, regardless of the default
*
* We also want touch opens to remain in the current split to avoid surprising
* split creation. The call-site `e != null` heuristic can't detect touch on
@@ -13,9 +13,9 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';
* mobile has no split concept and navigates in place / via forward navigation.
*/
export function openInNewSplitForMention(
- altKey: boolean | undefined,
+ shiftKey: boolean | undefined,
defaultOpenInNewSplit: boolean
): boolean {
if (isTouchDevice()) return false;
- return altKey ? false : defaultOpenInNewSplit;
+ return shiftKey === true || defaultOpenInNewSplit;
}
diff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.md
index 507f538635..b4745f914e 100644
--- a/docs/AGENT_GUIDE/navigation.md
+++ b/docs/AGENT_GUIDE/navigation.md
@@ -27,6 +27,12 @@
Splits: the app is a tiling window manager. A second pane appends its own segment to the URL
(`/app/<left>/<right>`). Each pane has its own Close / Go Back / Go Forward buttons.
+Shift-click on content links requests a new split wherever splits are supported,
+including mentions, references, folder links, and list rows with a linked preview.
+Unmodified clicks keep each surface’s default (same split, preview, or new split).
+Existing-content deduplication and split-capacity limits still apply; touch devices
+continue to navigate in place.
+
A block mounted in an inline preview cannot also open in a split. An attempt
shows `Content already open.` and keeps the preview in place. Select another
preview item or leave that view before opening the block in a split. Duplicate