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: shift clicking items on new views doesn't work as expected (#6430)

dev-rb3b00272b15a9
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
index 437e18d9d3..3062966a8f 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
@@ -74,7 +74,7 @@ const AGENT_FAVORITES_FILTER = {
function FavoriteRow(props: {
favorite: Favorite;
- onOpen: (favorite: Favorite) => void;
+ onOpen: (favorite: Favorite, event: MouseEvent) => void;
}) {
const name = useFavoriteDisplayName(props.favorite);
@@ -83,7 +83,7 @@ function FavoriteRow(props: {
<ViewSidebar.Item
class="font-normal"
title={name()}
- onClick={() => props.onOpen(props.favorite)}
+ onClick={(event) => props.onOpen(props.favorite, event)}
>
<span class="flex size-4 shrink-0 items-center justify-center">
<FavoriteIcon favorite={props.favorite} class="size-4" />
@@ -95,7 +95,10 @@ function FavoriteRow(props: {
}
function AgentFavorites(props: {
- onOpenConversation: (conversation: AgentConversationTarget) => void;
+ onOpenConversation: (
+ conversation: AgentConversationTarget,
+ event?: MouseEvent
+ ) => void;
}) {
const favoritesData = useFavoritesData(AGENT_FAVORITES_FILTER);
const [open, setOpen] = createSignal(true);
@@ -105,7 +108,7 @@ function AgentFavorites(props: {
)
);
- const openFavorite = (favorite: Favorite) => {
+ const openFavorite = (favorite: Favorite, event: MouseEvent) => {
if (
favorite.entityType !== 'agent_session' &&
favorite.entityType !== 'chat'
@@ -113,10 +116,13 @@ function AgentFavorites(props: {
return;
}
- props.onOpenConversation({
- id: favorite.entityId,
- type: favorite.entityType,
- });
+ props.onOpenConversation(
+ {
+ id: favorite.entityId,
+ type: favorite.entityType,
+ },
+ event
+ );
};
return (
@@ -143,7 +149,7 @@ function AgentFavorites(props: {
function ConversationRow(props: {
conversation: AgentConversationEntity;
active: boolean;
- onOpen: () => void;
+ onOpen: (event: MouseEvent) => void;
}) {
const timestamp = () =>
props.conversation.updatedAt ?? props.conversation.createdAt;
@@ -224,29 +230,39 @@ export type AgentsSidebarProps = {
loadMoreError: boolean;
onNavigate: (page: AgentsPage) => void;
onSearchChange: (search: string) => void;
- onOpenConversation: (conversation: AgentConversationTarget) => void;
+ onOpenConversation: (
+ conversation: AgentConversationTarget,
+ event?: MouseEvent
+ ) => void;
onRetry: () => void;
onLoadMore: () => void;
};
export function AgentsSidebar(props: AgentsSidebarProps) {
const panel = useSplitPanelOrThrow();
+
const forceEmptyState = useDebugSetting(
DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES
);
+
const [searchOpen, setSearchOpen] = createSignal(false);
const [recentChatsOpen, setRecentChatsOpen] = createSignal(true);
+
const [scrollRoot, setScrollRoot] = createSignal<HTMLElement>();
const [loadMoreSentinel, setLoadMoreSentinel] =
createSignal<HTMLDivElement>();
+
let searchInput: HTMLInputElement | undefined;
+
const visibleConversations = () =>
forceEmptyState() ? [] : props.conversations;
+
const actionController = createListController({
items: visibleConversations,
getKey: (conversation) => conversation.id,
isSelectable: () => false,
});
+
const actionList = toEntityActionListState({
controller: actionController,
getEntity: (conversation) => conversation,
@@ -414,8 +430,8 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
active={
props.activeConversationId === conversation().id
}
- onOpen={() =>
- props.onOpenConversation(conversation())
+ onOpen={(event) =>
+ props.onOpenConversation(conversation(), event)
}
/>
</SoupEntityContextMenu>
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index ce32957789..85a8bbe525 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -8,6 +8,7 @@ import { ConnectedAccounts } from '@app/features/settings/ConnectedAccounts';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
import { PreviewPanel } from '@components/app/PreviewPanel';
+import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { SplitPanel } from '@components/app/split-panel';
import { ChatInputProvider } from '@core/component/AI/context';
@@ -53,12 +54,17 @@ function LoadingComposer() {
function AgentsWorkspace() {
const panel = useSplitPanelOrThrow();
+ const layout = useSplitLayout();
+
const orchestrator = useGlobalBlockOrchestrator();
const userId = useUserId();
+
const agentsFlag = useFeatureFlag(enableChatV3Agents);
+
const [page, setPage] = createSignal<AgentsPage>('new');
const [selected, setSelected] = createSignal<SelectedConversation>();
const [search, setSearch] = createSignal('');
+
const query = useSoupItemsQuery(
() => {
const ownerId = userId();
@@ -76,6 +82,7 @@ function AgentsWorkspace() {
},
() => ({ enabled: Boolean(userId()) })
);
+
const conversations = () =>
selectRecentAgentConversations(
query.isSuccess ? query.data : [],
@@ -90,7 +97,21 @@ function AgentsWorkspace() {
setPage(next);
};
- const openConversation = (conversation: AgentConversationTarget) => {
+ const openConversation = (
+ conversation: AgentConversationTarget,
+ event?: MouseEvent
+ ) => {
+ if (event?.shiftKey) {
+ layout.openWithSplit(
+ {
+ type: conversation.type === 'agent_session' ? 'agent' : 'chat',
+ id: conversation.id,
+ },
+ { preferNewSplit: true, referredFrom: 'agents' }
+ );
+ return;
+ }
+
setPage('new');
setSelected({
conversation: { id: conversation.id, type: conversation.type },
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
index 6ddc40c943..4f9103fd74 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
@@ -38,7 +38,7 @@ export type ChannelRailItemProps = {
incomingCallId?: string;
selected: boolean;
focused: boolean;
- onActivate: () => void;
+ onActivate: (event: MouseEvent) => void;
};
export const CHANNEL_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
@@ -303,7 +303,7 @@ export function ConversationCard(props: ConversationCardProps) {
)}
aria-current={props.selected ? 'page' : undefined}
onMouseDown={(event) => {
- if (isPrimaryMouseDown(event)) props.onActivate();
+ if (isPrimaryMouseDown(event)) props.onActivate(event);
}}
>
<div
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
index b3ad230463..d600086ad1 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
@@ -45,6 +45,7 @@ import type {
ChannelsTab,
} from '../../types';
import {
+ type ChannelRailActivationMetadata,
type ChannelRailRow,
type ChannelsRailContext,
ChannelsRailProvider,
@@ -200,22 +201,33 @@ export function ChannelsRail(props: ChannelsRailProps) {
setSortBy,
setTab,
} = useChannelsView();
+
const panel = useSplitPanelOrThrow();
const layout = useSplitLayout();
+
const favoritesData = useFavoritesData({ entityType: ['channel'] });
+
const listDomId = createUniqueId();
+
const [sectionScrollRoots, setSectionScrollRoots] = createSignal<
Partial<Record<ChannelsRailSection, HTMLDivElement>>
>({});
+
const [listRoot, setListRoot] = createSignal<HTMLDivElement>();
const [virtualizers, setVirtualizers] = createSignal<
Partial<Record<ChannelsSourceScope, VirtualizerHandle>>
>({});
+
const [searchQuery, setSearchQuery] = createSignal('');
+
const [restoreListScroll, setRestoreListScroll] = createSignal(false);
+
const normalizedSearchQuery = () => searchQuery().trim();
+
const serviceSearchQuery = debouncedDependent(normalizedSearchQuery, 300);
+
let searchInput: HTMLInputElement | undefined;
+
const previewAfterNavigation = debounce(setSelectedChannelId, 150);
onCleanup(() => previewAfterNavigation.clear());
@@ -224,11 +236,13 @@ export function ChannelsRail(props: ChannelsRailProps) {
setSearchQuery('');
props.onSearchOpenChange(false);
};
+
const openSearch = () => {
if (props.mode === 'slim') props.onModeChange('full');
props.onSearchOpenChange(true);
queueMicrotask(() => searchInput?.focus());
};
+
const selectTab = (tab: ChannelsTab) => {
previewAfterNavigation.clear();
setRestoreListScroll(true);
@@ -236,6 +250,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
};
const channelCalls = useChannelCalls();
+
const channels = createMemo(() =>
deduplicateChannels([
props.sources.channels.items(),
@@ -244,6 +259,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
props.sources.search.items(),
])
);
+
const channelSearchQuery = useSearchSoupQuery(
() => ({
params: { page_size: 100 },
@@ -259,6 +275,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
props.searchOpen && normalizedSearchQuery() === serviceSearchQuery(),
})
);
+
const localSearchResults = createMemo(() => {
const query = normalizedSearchQuery().toLocaleLowerCase();
const items = props.sources.search.items();
@@ -268,6 +285,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
channel.name.toLocaleLowerCase().includes(query)
);
});
+
const serviceSearchResults = createMemo(() => {
if (
normalizedSearchQuery() !== serviceSearchQuery() ||
@@ -281,14 +299,17 @@ export function ChannelsRail(props: ChannelsRailProps) {
(entity): entity is WithSearch<ChannelEntity> => isChannelEntity(entity)
);
});
+
const searchResults = createMemo(() =>
deduplicateChannels([localSearchResults(), serviceSearchResults()])
);
+
const searchLoading = () =>
props.sources.search.isLoading() ||
(normalizedSearchQuery().length >= 3 &&
(normalizedSearchQuery() !== serviceSearchQuery() ||
channelSearchQuery.isFetching));
+
const searchError = () => {
if (
normalizedSearchQuery() === serviceSearchQuery() &&
@@ -299,13 +320,16 @@ export function ChannelsRail(props: ChannelsRailProps) {
return props.sources.search.error() ?? undefined;
};
+
const retrySearch = async () => {
await props.sources.search.refresh();
if (normalizedSearchQuery().length >= 3) {
await channelSearchQuery.refetch();
}
};
+
const channelActivity = useChannelRailActivity(channels, channelCalls);
+
const favorites = createMemo(() => favoritesData()?.favorites ?? []);
const visibleRows = createMemo(() => {
@@ -338,7 +362,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
});
const list = withSplitPanelOwner(listOwnedSlotName('controller'), () =>
- createListController<ChannelRailRow>({
+ createListController<ChannelRailRow, ChannelRailActivationMetadata>({
items: visibleRows,
getKey: (row) => row.id,
isSelectable: () => false,
@@ -346,27 +370,39 @@ export function ChannelsRail(props: ChannelsRailProps) {
state.selectedChannelId === undefined
? undefined
: rowKeyForChannel(state.selectedChannelId),
- onActivate: ({ item }) => {
+ onActivate: ({ item, metadata }) => {
previewAfterNavigation.clear();
+ const openInNewSplit =
+ metadata?.newSplit === true || metadata?.event?.shiftKey === true;
if (item.kind === 'section') {
setGroupOpen(item.group, !state.expandedGroups[item.group]);
return;
}
- if (item.kind === 'favorite') {
- if (item.favorite.entityType === 'channel') {
- setSelectedChannelId(item.favorite.entityId);
- return;
- }
-
+ if (
+ item.kind === 'favorite' &&
+ item.favorite.entityType !== 'channel'
+ ) {
layout.openWithSplit(favoriteSplitContent(item.favorite), {
+ preferNewSplit: openInNewSplit,
referredFrom: 'channels',
});
return;
}
- setSelectedChannelId(item.channel.id);
+ const channelId =
+ item.kind === 'favorite' ? item.favorite.entityId : item.channel.id;
+
+ if (openInNewSplit) {
+ layout.openWithSplit(
+ { type: 'channel', id: channelId },
+ { preferNewSplit: true, referredFrom: 'channels' }
+ );
+ return;
+ }
+
+ setSelectedChannelId(channelId);
},
})
);
@@ -411,9 +447,11 @@ export function ChannelsRail(props: ChannelsRailProps) {
const scrollScopeToSelectedOrStart = (scope: ChannelsQueryScope) => {
const items = props.sources[scope].items();
+
const selectedIndex = items.findIndex(
(channel) => channel.id === state.selectedChannelId
);
+
const targetIndex = selectedIndex >= 0 ? selectedIndex : 0;
const virtualizer = virtualizers()[scope];
@@ -431,9 +469,11 @@ export function ChannelsRail(props: ChannelsRailProps) {
const scrollSearchToSelectedOrStart = () => {
const items = searchResults();
+
const selectedIndex = items.findIndex(
(channel) => channel.id === state.selectedChannelId
);
+
const virtualizer = virtualizers().search;
if (!virtualizer || items.length === 0) return;
@@ -447,6 +487,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
if (!scrollRoot?.isConnected) return;
scrollRoot.scrollTop = 0;
+
const favorite = favorites().find(
(item) =>
item.entityType === 'channel' &&
@@ -461,6 +502,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
const elementBounds = element.getBoundingClientRect();
const scrollBounds = scrollRoot.getBoundingClientRect();
+
if (elementBounds.bottom > scrollBounds.bottom) {
scrollRoot.scrollTop += elementBounds.bottom - scrollBounds.bottom;
}
@@ -579,6 +621,10 @@ export function ChannelsRail(props: ChannelsRailProps) {
}
},
},
+ activation: {
+ createMetadata: (intent) => ({ newSplit: intent === 'alternate' }),
+ alternateDescription: 'Open in new split',
+ },
disclosure: {
getKey: (row) =>
props.mode === 'slim' && row.kind === 'conversation'
@@ -595,10 +641,12 @@ export function ChannelsRail(props: ChannelsRailProps) {
const jumpToSection = (offset: 1 | -1) => {
const currentGroup = list.focus.item()?.group;
+
const sections =
favorites().length > 0
? CHANNEL_RAIL_SECTIONS
: CHANNEL_RAIL_SECTIONS.filter((section) => section !== 'favorites');
+
const currentIndex = currentGroup ? sections.indexOf(currentGroup) : -1;
const origin = currentIndex === -1 ? (offset === 1 ? -1 : 0) : currentIndex;
const nextIndex = (origin + offset + sections.length) % sections.length;
@@ -659,8 +707,11 @@ export function ChannelsRail(props: ChannelsRailProps) {
)
);
- const activateRow = (rowId: ChannelRailRow['id']) => {
- list.activate.key(rowId, { reason: 'pointer' });
+ const activateRow = (rowId: ChannelRailRow['id'], event?: MouseEvent) => {
+ list.activate.key(rowId, {
+ reason: 'pointer',
+ metadata: event ? { event } : undefined,
+ });
};
const registerVirtualizer = (
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts b/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts
index 6c5f8f2d73..482c6cf7c5 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts
+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts
@@ -50,9 +50,14 @@ export const rowKeyForSection = (group: ChannelsRailSection) =>
export const domIdForRow = (railId: string, rowId: string) =>
`${railId}-${rowId}`;
+export type ChannelRailActivationMetadata = {
+ event?: MouseEvent;
+ newSplit?: boolean;
+};
+
export type ChannelsRailContext = {
railId: string;
- list: ListController<ChannelRailRow>;
+ list: ListController<ChannelRailRow, ChannelRailActivationMetadata>;
tab: Accessor<ChannelsTab>;
selectTab: (tab: ChannelsTab) => void;
setMode: (mode: 'full' | 'slim') => void;
@@ -66,7 +71,7 @@ export type ChannelsRailContext = {
slimGroupEnabled: (group: ChannelsGroup) => boolean;
setSlimGroupEnabled: (group: ChannelsGroup, enabled: boolean) => void;
registerRootRef: (element: HTMLDivElement) => void;
- activateRow: (rowId: ChannelRailRow['id']) => void;
+ activateRow: (rowId: ChannelRailRow['id'], event?: MouseEvent) => void;
registerScrollRef: (
group: ChannelsRailSection,
element: HTMLDivElement
diff --git a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
index 43abf4b4a1..28658061cd 100644
--- a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
@@ -186,7 +186,9 @@ function FavoriteOption(props: { favorite: Favorite }) {
'hover:bg-hover hover:text-ink'
)}
aria-current={item().selected ? 'page' : undefined}
- onClick={() => rail.activateRow(rowKeyForFavorite(props.favorite))}
+ onClick={(event) =>
+ rail.activateRow(rowKeyForFavorite(props.favorite), event)
+ }
>
<span class="flex size-6 shrink-0 items-center justify-center">
<FavoriteIcon favorite={props.favorite} avatarSize="md" />
@@ -226,7 +228,7 @@ function ChannelOption(props: { channel: ChannelEntity }) {
aria-current={item().selected ? 'page' : undefined}
onMouseDown={(event) => {
if (!isPrimaryMouseDown(event)) return;
- rail.activateRow(rowKeyForChannel(props.channel.id));
+ rail.activateRow(rowKeyForChannel(props.channel.id), event);
}}
>
<ChannelAvatar channel={props.channel} />
@@ -656,7 +658,9 @@ function RecentConversationCard(props: { channel: ChannelEntity }) {
incomingCallId={item().incomingCallId}
selected={item().selected}
focused={item().focused}
- onActivate={() => rail.activateRow(rowKeyForChannel(props.channel.id))}
+ onActivate={(event) =>
+ rail.activateRow(rowKeyForChannel(props.channel.id), event)
+ }
/>
</ChannelRailItemContextMenu>
);
diff --git a/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx
index 2f523eca05..d449d42d2d 100644
--- a/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx
@@ -161,7 +161,9 @@ function SlimFavoriteItem(props: { favorite: Favorite }) {
'hover:bg-hover hover:text-ink'
)}
aria-current={item().selected ? 'page' : undefined}
- onClick={() => rail.activateRow(rowKeyForFavorite(props.favorite))}
+ onClick={(event) =>
+ rail.activateRow(rowKeyForFavorite(props.favorite), event)
+ }
>
<span
aria-hidden="true"
@@ -300,7 +302,7 @@ function SlimChannelItem(props: { channel: ChannelEntity }) {
aria-current={item().selected ? 'page' : undefined}
onMouseDown={(event) => {
if (!isPrimaryMouseDown(event)) return;
- rail.activateRow(rowKeyForChannel(props.channel.id));
+ rail.activateRow(rowKeyForChannel(props.channel.id), event);
}}
>
<span
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 0e5faf0239..aa88ab6b11 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -5,7 +5,8 @@
- List: `Go to Agents` → `/app/component/agents`. With new app views enabled
on desktop, an Agents sidebar opens New Chat, Routines, configured Agents,
Connections, and Skills, followed by favorite and recent conversations.
- Selecting a recent chat or agent session opens it inside the workspace.
+ Selecting a recent chat or agent session opens it inside the workspace;
+ Shift-clicking one opens it in a new split instead.
Touch devices and users outside the flag retain the Owned / Running / Shared /
Automations / Skills list.
- A chat is `/app/chat/<uuid>`. A doc-scoped chat is `/app/md/<doc>/chat/<chat>` (split view).
diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.md
index 5519d6e491..6e701bb3f9 100644
--- a/docs/AGENT_GUIDE/channels.md
+++ b/docs/AGENT_GUIDE/channels.md
@@ -191,7 +191,8 @@ a channel cached away from its latest page, and a delta longer than one page use
On desktop, the Chat rail has `All` and `Recent` tabs. All contains an
optional `Favorites` section above the independently paginated `Channels` and
`DMs` sections. It appears when the user has channel favorites and only lists
-channels. Channel favorites open in the channel preview.
+channels. Channel favorites open in the channel preview. Shift-clicking a
+favorite, channel, or DM opens that conversation in a new split instead.
The search action beside the tabs opens a search field below them and replaces
the active tab contents with matching channels and direct messages from one
activity-ordered source. Search results use compact rows on `All` and
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index d163681fa5..ea50060430 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -60,7 +60,8 @@ Filter menu. On desktop, selecting a row renders its block in the inline preview
the notification sidebar. With the `enable-inbox-notified-sort` flag on, both tabs order
rows and date headers by when you were last notified about the item, so a fresh comment
on an old task sits under "Today"; with it off they order by content recency. Keyboard:
-`j`/`k` move between rows and update the preview; alternate activation opens a new split.
+`j`/`k` move between rows and update the preview; alternate activation and Shift-click
+open a new split.
On mobile, the filters float above the full-height scrolling list. On iOS, rows
fade underneath the filters and status bar using the shared top edge gradient.