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
feat(preview): shift click for new split, alt click to replace preview (#5335)
Peter Chinmane2ff03963ac0
diff --git a/apps/web/src/components/app/split-layout/layoutManager.ts b/apps/web/src/components/app/split-layout/layoutManager.tsindex f4f135a2f9..a3ddc7ce5b 100644--- a/apps/web/src/components/app/split-layout/layoutManager.ts+++ b/apps/web/src/components/app/split-layout/layoutManager.ts@@ -23,6 +23,7 @@ import {type JSXElement,} from 'solid-js';import { createStore, produce, reconcile, type Store } from 'solid-js/store';+import { match } from 'ts-pattern';import {type ComponentMeta,type ComponentMetaMap,@@ -203,6 +204,13 @@ export type OpenWithSplitOptions = {replaceWhenFull?: boolean;/** If true, prefers opening in a new split. May still replace if layout is at capacity. */preferNewSplit?: boolean;+ /**+ * Open in place of the whole Preview Pair: the Viewer closes, preview mode+ * disengages, and the content replaces the Controller — the same shape as+ * external replacement navigation, but asked for deliberately. Ignored when+ * the navigation does not come from a live Preview Pair.+ */+ replacePreview?: boolean;insertIndex?: number;handle?: SplitHandle;/**@@ -1758,6 +1766,42 @@ export function createSplitLayout(}}+ /**+ * Where a navigation lands when its source belongs to a live Preview Pair.+ *+ * - `dissolve`: the Viewer closes and the content replaces the Controller.+ * - `into-viewer`: the content previews in the Viewer, which never takes the+ * keyboard from the Controller.+ * - `unchanged`: the navigation stands on its own — a new split, or the+ * Viewer replacing itself like any other split.+ */+ type PreviewRoute = 'dissolve' | 'into-viewer' | 'unchanged';++ function previewRouteFor(+ previewPair: PreviewPair,+ explicitSourceId: SplitId | undefined,+ options: OpenWithSplitOptions+ ): PreviewRoute {+ // Asking to replace the preview outranks everything else.+ if (options.replacePreview) return 'dissolve';++ // Explicit new-split intent stands on its own while there is room for it,+ // which leaves the Preview Pair intact. Without room it falls back to the+ // replacement routing below — into the Viewer, never the Controller.+ if (options.preferNewSplit && canAppendSplit()) return 'unchanged';++ // External (handle-less) replacement navigation, e.g. the sidebar or the+ // command menu, takes the pair's place. Handle-less create-new actions are+ // not replacements, and were already answered above.+ if (explicitSourceId === undefined) return 'dissolve';++ // A Controller selection previews; anything else (notably the Viewer+ // navigating itself) replaces its own split.+ return explicitSourceId === previewPair.controllerId+ ? 'into-viewer'+ : 'unchanged';+ }+function openWithSplit(content: SplitContent,options: OpenWithSplitOptions = {}@@ -1777,61 +1821,67 @@ export function createSplitLayout(if (result.handled) return undefined;}- // Preview Pair routing:- // - External (handle-less) replacement navigation while a Preview Pair- // member is active dissolves the Preview Pair: the Viewer closes and- // the content replaces the Controller. Explicit new-split intent is honored- // without dissolving the Preview Pair when the layout has room.- // - A replace originating from the Controller (`options.handle` names- // it) lands in the Viewer without stealing the keyboard. That- // includes new-split intent when the layout is full — the fallback- // replaces the Viewer, never the Controller.- // - The Viewer itself navigates like any split: it replaces- // itself, honors new-split intent, and a full layout falls back to- // replacing it (its own handle), never the Controller.- // Options are rewritten once, never recursively. Runs before the- // duplicate short-circuit so an existing-content hit can never activate- // (and focus) another split while the Controller holds the keyboard.- {- const explicitSourceId = options.handle?.id;- const sourceId = explicitSourceId ?? state.activeSplitId;- const previewPair = sourceId ? previewPairOf(sourceId) : undefined;- if (previewPair && findSplitById(previewPair.viewerId)) {- if (explicitSourceId === undefined) {- // Global create-new actions are handle-less too, but they are not- // replacement navigation. Honor their explicit new-split intent- // when there is room and leave the Preview Pair intact.- if (!options.preferNewSplit || !canAppendSplit()) {- disengagePreviewMode(previewPair.controllerId);- options = {- ...options,- handle: getSplit(previewPair.controllerId),- preferNewSplit: false,- insertIndex: undefined,- };- }- } else if (- explicitSourceId === previewPair.controllerId &&- (!options.preferNewSplit || !canAppendSplit())- ) {- options = {+ // Preview Pair routing (see previewRouteFor for the rules). Options are+ // rewritten once, never recursively. Runs before the duplicate+ // short-circuit so an existing-content hit can never activate (and focus)+ // another split while the Controller holds the keyboard.+ const explicitSourceId = options.handle?.id;+ const previewSourceId = explicitSourceId ?? state.activeSplitId;+ const sourcePreviewPair = previewSourceId+ ? previewPairOf(previewSourceId)+ : undefined;+ const previewPair =+ sourcePreviewPair && findSplitById(sourcePreviewPair.viewerId)+ ? sourcePreviewPair+ : undefined;+ const previewRoute: PreviewRoute = previewPair+ ? previewRouteFor(previewPair, explicitSourceId, options)+ : 'unchanged';++ if (previewPair) {+ options = match(previewRoute)+ .with('dissolve', () => {+ disengagePreviewMode(previewPair.controllerId);+ return {...options,- handle: getSplit(previewPair.viewerId),+ handle: getSplit(previewPair.controllerId),preferNewSplit: false,- activate: false,insertIndex: undefined,- // Controller-originated navigation is transient selection state,- // not preview history: it replaces the Viewer's current- // entry, so only the preview's own navigation stacks up.- mergeHistory: true,};- }- }+ })+ .with('into-viewer', () => ({+ ...options,+ handle: getSplit(previewPair.viewerId),+ preferNewSplit: false,+ activate: false,+ insertIndex: undefined,+ // Controller-originated navigation is transient selection state,+ // not preview history: it replaces the Viewer's current+ // entry, so only the preview's own navigation stacks up.+ mergeHistory: true,+ }))+ .with('unchanged', () => options)+ .exhaustive();}const existingSplit = getSplitByContent(content.type, content.id);- if (!options.allowDuplicate && existingSplit) {+ // Promoting the previewed row into a split of its own: the Viewer's copy is+ // the preview being superseded, not a competing split, so it must not+ // short-circuit into "activate what is already open". The Viewer drops back+ // to its placeholder once the content has a real split (see below), so the+ // content still lives in exactly one place. An `unchanged` route with+ // new-split intent is precisely the case where the split has room to exist.+ const promotedPreviewPair =+ previewPair !== undefined &&+ previewRoute === 'unchanged' &&+ options.preferNewSplit === true &&+ explicitSourceId === previewPair.controllerId &&+ existingSplit?.id === previewPair.viewerId+ ? previewPair+ : undefined;++ if (!options.allowDuplicate && existingSplit && !promotedPreviewPair) {// A controller selection can resolve to content already mounted in its// own viewer (notably two rows from one channel). Refresh the viewer's// merged history entry so per-entry source metadata follows the latest@@ -1886,6 +1936,13 @@ export function createSplitLayout(return splitHandle;} else {+ // The promoted content is about to own a real split, so clear the preview+ // it came from first: it must never sit in two splits at once, and a+ // Viewer still holding it would make createNewSplit dedupe into it.+ if (promotedPreviewPair) {+ resetPreviewMode(promotedPreviewPair.controllerId);+ }+return createNewSplit({content,activate: options.activate ?? true,diff --git a/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts b/apps/web/src/components/app/split-layout/tests/layoutManager.test.tsindex 5dee4687dd..8d1d83e950 100644--- a/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts+++ b/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts@@ -934,6 +934,184 @@ describe('layoutManager', () => {});});+ it('replacePreview dissolves the Preview Pair and opens in its place', () => {+ createRoot((dispose) => {+ const { manager, controllerId } = setup();+ manager.engagePreviewMode(controllerId);+ const viewerId = manager.viewerOf(controllerId)!;++ // Something is being previewed...+ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ { referredFrom: null, handle: manager.getSplit(controllerId) }+ );+ expect(manager.splits()).toHaveLength(2);++ // ...and opening another row for real takes the whole pair's place.+ manager.openWithSplit(+ { type: 'md', id: 'doc-2' },+ {+ referredFrom: null,+ replacePreview: true,+ handle: manager.getSplit(controllerId),+ }+ );++ expect(manager.splits()).toHaveLength(1);+ expect(manager.getSplit(viewerId)).toBeUndefined();+ expect(manager.viewerOf(controllerId)).toBeUndefined();+ expect(manager.getSplit(controllerId)!.isControllerSplit()).toBe(false);+ expect(manager.getSplit(controllerId)!.content()).toMatchObject({+ type: 'md',+ id: 'doc-2',+ });+ expect(manager.activeSplitId()).toBe(controllerId);++ // The list it replaced is one step back.+ manager.getSplit(controllerId)!.goBack();+ expect(manager.getSplit(controllerId)!.content()).toMatchObject({+ type: 'component',+ id: 'inbox',+ });++ dispose();+ });+ });++ it('replacePreview wins over new-split intent even with room to spare', () => {+ createRoot((dispose) => {+ const { manager, controllerId } = setup();+ manager.engagePreviewMode(controllerId);+ const viewerId = manager.viewerOf(controllerId)!;++ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ {+ referredFrom: null,+ replacePreview: true,+ preferNewSplit: true,+ handle: manager.getSplit(controllerId),+ }+ );++ expect(manager.splits()).toHaveLength(1);+ expect(manager.getSplit(viewerId)).toBeUndefined();+ expect(manager.getSplit(controllerId)!.content()).toMatchObject({+ type: 'md',+ id: 'doc-1',+ });++ dispose();+ });+ });++ it('replacePreview promotes the previewed row itself without duplicating it', () => {+ createRoot((dispose) => {+ const { manager, controllerId } = setup();+ manager.engagePreviewMode(controllerId);+ const viewerId = manager.viewerOf(controllerId)!;++ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ { referredFrom: null, handle: manager.getSplit(controllerId) }+ );++ // The Viewer holds this content; closing it with the pair leaves the+ // Controller free to take it, rather than short-circuiting into the+ // split that is about to disappear.+ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ {+ referredFrom: null,+ replacePreview: true,+ handle: manager.getSplit(controllerId),+ }+ );++ expect(manager.splits()).toHaveLength(1);+ expect(manager.getSplit(viewerId)).toBeUndefined();+ expect(manager.getSplit(controllerId)!.content()).toMatchObject({+ type: 'md',+ id: 'doc-1',+ });++ dispose();+ });+ });++ it('promotes the previewed content into its own split, resetting the Viewer', () => {+ createRoot((dispose) => {+ const { manager, controllerId } = setup();+ manager.engagePreviewMode(controllerId);+ const viewerId = manager.viewerOf(controllerId)!;++ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ { referredFrom: null, handle: manager.getSplit(controllerId) }+ );+ expect(manager.getSplit(viewerId)!.content()).toMatchObject({+ type: 'md',+ id: 'doc-1',+ });++ // New-split intent for the row currently being previewed: the Viewer's+ // copy is that preview, so it must not short-circuit into "already+ // open" — the content gets a real split and the preview resets.+ const created = manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ {+ referredFrom: null,+ preferNewSplit: true,+ handle: manager.getSplit(controllerId),+ }+ );++ expect(manager.splits()).toHaveLength(3);+ expect(created?.id).not.toBe(viewerId);+ expect(created?.content()).toMatchObject({ type: 'md', id: 'doc-1' });+ expect(manager.viewerOf(controllerId)).toBe(viewerId);+ expect(manager.getSplit(viewerId)!.content()).toMatchObject({+ type: 'component',+ id: 'preview-empty',+ });++ dispose();+ });+ });++ it('leaves the preview in place when a promotion cannot fit', () => {+ createRoot((dispose) => {+ const { manager, controllerId } = setup();+ manager.engagePreviewMode(controllerId);+ const viewerId = manager.viewerOf(controllerId)!;++ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ { referredFrom: null, handle: manager.getSplit(controllerId) }+ );+ manager.setResizeContext({+ canFit: () => false,+ } as unknown as ResizeZoneCtx);++ manager.openWithSplit(+ { type: 'md', id: 'doc-1' },+ {+ referredFrom: null,+ preferNewSplit: true,+ handle: manager.getSplit(controllerId),+ }+ );++ expect(manager.splits()).toHaveLength(2);+ expect(manager.getSplit(viewerId)!.content()).toMatchObject({+ type: 'md',+ id: 'doc-1',+ });++ dispose();+ });+ });+it('honors handle-less new-split intent without dissolving the Preview Pair', () => {createRoot((dispose) => {const { manager, controllerId } = setup();diff --git a/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx b/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsxindex 2eb418d667..dccf151358 100644--- a/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx+++ b/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx@@ -32,6 +32,7 @@ export function SoupEntityActionDrawer() {activeTab: activeTab(),activeListView: content.id,viewedProjectId: viewedProjectIdFromContent(content),+ splitHandle: panel.handle,});};@@ -74,9 +75,11 @@ export function SoupEntityActionDrawer() {{(action) => (<buttontype="button"+ disabled={action.disabled}class={cn('flex items-center gap-3 px-4 py-3 text-sm hover:bg-hover hover-transition-bg text-left not-last:mb-px bg-surface',- action.destructive ? 'text-failure-ink' : 'text-ink'+ action.destructive ? 'text-failure-ink' : 'text-ink',+ action.disabled && 'opacity-50')}onClick={async (e: MouseEvent) => {if (action.id === 'share') {diff --git a/apps/web/src/features/next-soup/soup-view/create-soup-entity-actions.ts b/apps/web/src/features/next-soup/soup-view/create-soup-entity-actions.tsindex c21ab5a631..734e564a13 100644--- a/apps/web/src/features/next-soup/soup-view/create-soup-entity-actions.ts+++ b/apps/web/src/features/next-soup/soup-view/create-soup-entity-actions.ts@@ -2,12 +2,9 @@ import { isListViewID } from '@app/constants/list-views';import { canExecuteMarkDoneOnView } from '@app/features/next-soup/actions/make-mark-done-action';import { useAnalytics } from '@app/lib/analytics/analytics-context';import { globalSplitManager } from '@app/signal/splitLayout';-import {- getChannelParams,- goToChannelMessage,-} from '@block-channel/utils/link';import { useGlobalNotificationSource } from '@components/app/GlobalAppState';-import { fileTypeToBlockName, itemToBlockName } from '@core/constant/allBlocks';+import type { SplitHandle } from '@components/app/split-layout/layoutManager';+import { itemToBlockName } from '@core/constant/allBlocks';import { useUserId } from '@core/context/user';import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';import { isMobile } from '@core/mobile/isMobile';@@ -36,7 +33,7 @@ import {makeShareAction,} from '../actions';import type { SoupState } from '../create-soup-state';-import { getChannelEntityTarget } from '../utils';+import { openEntityInSplitFromUnifiedList } from '../utils';const SIGNAL_TABS = new Set<string | undefined>([undefined,@@ -53,6 +50,7 @@ type SoupEntityActionItem = {shortcut?: string;onClick: () => void | Promise<void>;destructive?: boolean;+ disabled?: boolean;};type SoupEntityActionGroup = {@@ -70,6 +68,11 @@ type BuildActionGroups = (// Provided only where the menu host can anchor a tag picker for the// right-clicked row.openTagPicker?: () => void;+ /**+ * The split hosting the list. Open actions route through it so they match+ * their click/hotkey equivalents, including Preview Pair routing.+ */+ splitHandle?: SplitHandle;}) => SoupEntityActionGroup[];@@ -130,7 +133,7 @@ export function createSoupEntityActions(): {const buildActionGroups: BuildActionGroups = (soup,entities,- { activeTab, activeListView, viewedProjectId, openTagPicker }+ { activeTab, activeListView, viewedProjectId, openTagPicker, splitHandle }) => {const canExecuteAll = (canExecute: (e: EntityData) => boolean) =>entities.length > 0 && entities.every(canExecute);@@ -189,105 +192,74 @@ export function createSoupEntityActions(): {});}- const canOpenInSplit = () => {- if (isMobile()) return false;- if (entities.length !== 1) return false;+ /**+ * The single entity these open actions apply to, if any.+ *+ * Content already mounted in another split is skipped — reopening it would+ * duplicate it. The Preview Pair's own Viewer is the exception: its copy is+ * the preview of this very row, which opening supersedes rather than+ * duplicates, so the row keeps its open actions while it is being+ * previewed.+ */+ const openableEntity = (): EntityData | undefined => {+ if (isMobile()) return undefined;+ if (entities.length !== 1) return undefined;const entity = entities[0];- const splitManager = globalSplitManager();- if (!splitManager) return false;// TODO(dev-rb/github): Allow GitHub PRs once they map to /pr.- if (entity.type === 'foreign') return false;+ if (!entity || entity.type === 'foreign') return undefined;+ const splitManager = globalSplitManager();+ if (!splitManager) return undefined;const contentId =entity.type === 'channel_message' || entity.type === 'channel_thread'? entity.channelId: entity.id;const contentType = itemToBlockName(entity);- return !splitManager.getSplitByContent(contentType, contentId);+ const existing = splitManager.getSplitByContent(contentType, contentId);+ if (existing && existing.id !== splitHandle?.viewerId()) return undefined;+ return entity;};- if (canOpenInSplit()) {- const openInNewSplit = async () => {- const entity = entities[0];+ const openEntity =+ (options: { openInNewSplit?: boolean; replacePreview?: boolean }) =>+ async () => {+ const entity = openableEntity();if (!entity) return;- const splitManager = globalSplitManager();- if (!splitManager) return;-- analytics.track('split_created', {- from: 'soup_view_entity_actions_menu',- });-- if (entity.type === 'document') {- const { fileType, id, subType } = entity;- splitManager.createNewSplit({- content: {- type: fileTypeToBlockName(subType?.type ?? fileType),- id,- },- referredFrom: 'entity-actions-menu',- });- } else if (- entity.type === 'channel_message' ||- entity.type === 'channel_thread'- ) {- // Thread rows are keyed by their root; getChannelEntityTarget- // recovers the clicked reply from the driving notification so the- // new split lands on it rather than the root message. These rows- // always resolve to a message target (their own ids at worst), never- // `latest`, which only a whole-channel row produces.- const resolved = getChannelEntityTarget(entity);- const target =- resolved?.kind === 'message'- ? resolved- : { messageId: entity.messageId, threadId: entity.threadId };- splitManager.createNewSplit({- content: {- type: 'channel',- id: entity.channelId,- params: getChannelParams(target.messageId, target.threadId),- },- referredFrom: 'entity-actions-menu',- });-- await goToChannelMessage(- splitManager.getOrchestrator(),- entity.channelId,- target.messageId,- target.threadId- );- } else if (entity.type === 'crm_company') {- splitManager.createNewSplit({- content: {- type: 'company',- id: entity.id,- },- referredFrom: 'entity-actions-menu',- });- } else if (entity.type === 'crm_contact') {- splitManager.createNewSplit({- content: {- type: 'contact',- id: entity.id,- },- referredFrom: 'entity-actions-menu',- });- } else if (entity.type !== 'foreign') {- splitManager.createNewSplit({- content: {- type: itemToBlockName(entity),- id: entity.id,- },- referredFrom: 'entity-actions-menu',+ if (options.openInNewSplit) {+ analytics.track('split_created', {+ from: 'soup_view_entity_actions_menu',});}++ // Same path as shift/opt+click, so the menu inherits Preview Pair+ // routing (new split when it fits; replacing the pair outright) and+ // per-entity targeting such as a thread row's driving message.+ await openEntityInSplitFromUnifiedList(entity, {+ ...options,+ splitHandle,+ referredFrom: 'entity-actions-menu',+ });};+ if (openableEntity()) {topItems.push({id: 'open-in-split',label: 'Open in new split',shortcut: 'shift+enter',- onClick: openInNewSplit,+ // A layout with no room for another split cannot honor this: the open+ // would fall back to replacing a split instead of adding one.+ disabled: !globalSplitManager()?.canAppendSplit(),+ onClick: openEntity({ openInNewSplit: true }),});++ if (splitHandle?.isControllerSplit()) {+ topItems.push({+ id: 'open-to-replace-preview',+ label: 'Open to replace preview',+ shortcut: 'opt+enter',+ onClick: openEntity({ replacePreview: true }),+ });+ }}// Middle group: Rename, Move to folder, Duplicate, Copy Link, Copy Branch Name, Sharediff --git a/apps/web/src/features/next-soup/soup-view/soup-entity-actions-menu.tsx b/apps/web/src/features/next-soup/soup-view/soup-entity-actions-menu.tsxindex 3d56fa6b15..834f560739 100644--- a/apps/web/src/features/next-soup/soup-view/soup-entity-actions-menu.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-entity-actions-menu.tsx@@ -28,6 +28,7 @@ export const SoupEntityActionsMenu = (props: SoupEntityActionsMenuProps) => {activeListView: content.id,viewedProjectId: viewedProjectIdFromContent(content),openTagPicker: props.onEditTags,+ splitHandle: panel.handle,});};@@ -50,6 +51,7 @@ export const SoupEntityActionsMenu = (props: SoupEntityActionsMenuProps) => {icon={action.icon}hotkeyToken={action.hotkeyToken}shortcut={action.shortcut}+ disabled={action.disabled}onClick={() => handleAction(action.onClick)}class={action.destructive ? 'text-failure-ink' : undefined}/>diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsxindex ea789da98e..3d61cedff4 100644--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx@@ -933,15 +933,22 @@ const SoupViewListContent = (props: SoupViewListProps) => {}// Plain click while engaged as a Controller previews into the Viewer;- // shift+click falls through to open a fresh split instead. Non-member- // channels flow through to openEntityInSplitFromUnifiedList, which shows the- // Viewer's Join prompt when previewing and otherwise no-ops.+ // opt+click opens in place of the whole Preview Pair (the Viewer closes and+ // the content replaces this list); shift+click falls through to open a+ // fresh split instead. Non-member channels flow through to+ // openEntityInSplitFromUnifiedList, which shows the Viewer's Join prompt+ // when previewing and otherwise no-ops.if (panel.handle.isControllerSplit() &&type === 'entity' &&!event.shiftKey) {- if (preventDuplicatePreviewEntityOpen(entity, panel.handle)) return;+ if (+ !event.altKey &&+ preventDuplicatePreviewEntityOpen(entity, panel.handle)+ ) {+ return;+ }// Single click: focus the row AND open it in the Preview Pair's Viewer.// The openWithSplit redirect keeps the Viewer unfocused so keyboard@@ -952,6 +959,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {await openEntityInSplitFromUnifiedList(entity, {location,splitHandle: panel.handle,+ replacePreview: event.altKey,referredFrom: currentView(),});return;diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts b/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.tsindex af945c4975..bc0e28cc32 100644--- a/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts+++ b/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts@@ -203,6 +203,26 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {displayPriority: 4,}).withGroup(group);+ // opt+enter - Open in place of the whole Preview Pair+ registerHotkey({+ hotkey: ['opt+enter'],+ scopeId,+ description: 'Open to replace preview',+ condition: () =>+ splitHandle.isControllerSplit() && soup.focus.id() !== undefined,+ keyDownHandler: () => {+ const entity = soup.focus.item();+ if (!entity) return false;+ openEntityInSplitFromUnifiedList(entity, {+ splitHandle,+ replacePreview: true,+ referredFrom: currentView(),+ });+ return true;+ },+ hide: true,+ }).withGroup(group);+// x - Toggle select itemregisterHotkey({hotkey: ['x'],diff --git a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsxindex 2516efda76..ad8505e2af 100644--- a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx+++ b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx@@ -249,11 +249,13 @@ export function CompanyKanban() {};const openCompany = (entity: EntityData, event: MouseEvent) => {- // Shift+click always opens a fresh split; a plain click while engaged as a- // Controller previews into the Viewer and shouldn't re-open an entity- // already shown elsewhere. Matches the list view's onEntityClick.+ // Shift+click always opens a fresh split; opt+click replaces the whole+ // Preview Pair; a plain click while engaged as a Controller previews into+ // the Viewer and shouldn't re-open an entity already shown elsewhere.+ // Matches the list view's onEntityClick.if (!event.shiftKey &&+ !event.altKey &&panel.handle.isControllerSplit() &&preventDuplicatePreviewEntityOpen(entity, panel.handle)) {@@ -263,6 +265,7 @@ export function CompanyKanban() {void openEntityInSplitFromUnifiedList(entity, {openInNewSplit: event.shiftKey,+ replacePreview: !event.shiftKey && event.altKey,splitHandle: panel.handle,referredFrom: 'companies',});diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.tsindex 1c80cb4a88..708442c602 100644--- a/apps/web/src/features/next-soup/utils.test.ts+++ b/apps/web/src/features/next-soup/utils.test.ts@@ -167,6 +167,40 @@ describe('preview history source', () => {expect(previewSourceEntityId(openWithSplit.mock.calls[0][0])).toBe('doc-1');});++ it('forwards an explicit preview replacement to the split manager', async () => {+ const openWithSplit = vi.fn();+ const controller = {+ content: () => ({ type: 'component', id: 'inbox' }),+ isControllerSplit: () => true,+ viewerId: () => 'viewer-1',+ } as unknown as SplitHandle;+ setGlobalSplitManager({+ activeSplit: vi.fn(),+ getOrchestrator: vi.fn(() => ({})),+ getSplitByContent: vi.fn(() => ({ id: 'another-split' })),+ openWithSplit,+ } as unknown as SplitManager);++ await openEntityInSplitFromUnifiedList(+ {+ type: 'document',+ id: 'doc-1',+ fileType: 'md',+ } as EntityData,+ { splitHandle: controller, replacePreview: true }+ );++ expect(openWithSplit.mock.calls[0][1]).toMatchObject({+ replacePreview: true,+ });+ expect(toastAlert).not.toHaveBeenCalled();+ expect(openWithSplit.mock.calls[0][1].preferNewSplit).toBeUndefined();+ // The content takes the pair's place, so it is not preview history.+ expect(+ previewSourceEntityId(openWithSplit.mock.calls[0][0])+ ).toBeUndefined();+ });});describe('getChannelEntityTarget', () => {diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.tsindex 1dd84325f8..627c9b0c2d 100644--- a/apps/web/src/features/next-soup/utils.ts+++ b/apps/web/src/features/next-soup/utils.ts@@ -330,6 +330,11 @@ export const restoreSoupFocus = async (entityId?: string): Promise<void> => {interface OpenEntityOptions {openInNewSplit?: boolean;+ /**+ * Open in place of the whole Preview Pair: the Viewer closes and the content+ * replaces the Controller. No-op outside a Preview Pair.+ */+ replacePreview?: boolean;location?: SearchLocation;splitHandle?: SplitHandle;mergeHistory?: boolean;@@ -513,7 +518,13 @@ export const openEntityInSplitFromUnifiedList = async (entity: EntityData,options: OpenEntityOptions): Promise<void> => {- const { allowDuplicate, openInNewSplit, splitHandle, mergeHistory } = options;+ const {+ allowDuplicate,+ openInNewSplit,+ replacePreview,+ splitHandle,+ mergeHistory,+ } = options;let { location } = options;if (!location) {@@ -561,6 +572,7 @@ export const openEntityInSplitFromUnifiedList = async (referredFrom: options.referredFrom,activate: true,preferNewSplit: openInNewSplit,+ replacePreview,handle: splitHandle,mergeHistory,}@@ -579,6 +591,7 @@ export const openEntityInSplitFromUnifiedList = async (if (!allowDuplicate &&!openInNewSplit &&+ !replacePreview &&splitHandle &&preventDuplicatePreviewEntityOpen(entity, splitHandle)) {@@ -612,7 +625,9 @@ export const openEntityInSplitFromUnifiedList = async (const referredFrom = options.referredFrom ?? sourceListView;let splitContent: SplitContent = { ...content, params };- if (splitHandle?.isControllerSplit()) {+ // Preview source metadata belongs on Viewer entries; a replacement takes the+ // Preview Pair's place, so its entry is ordinary split history.+ if (splitHandle?.isControllerSplit() && !replacePreview) {splitContent = withPreviewSourceEntityId(splitContent, entity.id);}@@ -620,6 +635,7 @@ export const openEntityInSplitFromUnifiedList = async (referredFrom,activate: true,preferNewSplit: openInNewSplit,+ replacePreview,handle: splitHandle,mergeHistory,allowDuplicate,diff --git a/apps/web/src/features/settings/Shortcuts.tsx b/apps/web/src/features/settings/Shortcuts.tsxindex 84393b1667..a3f72ef6bd 100644--- a/apps/web/src/features/settings/Shortcuts.tsx+++ b/apps/web/src/features/settings/Shortcuts.tsx@@ -958,6 +958,11 @@ const shortcutSections: ShortcutSection[] = [codes: ['ShiftLeft', 'Enter'],description: 'Open item in a new split',},+ {+ keys: ['opt+enter'],+ codes: ['AltLeft', 'Enter'],+ description: 'Open item in place of the preview',+ },{ keys: ['arrowup'], codes: ['ArrowUp'], description: 'Move up' },{ keys: ['arrowdown'], codes: ['ArrowDown'], description: 'Move down' },{