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.

feat(soup): resize preview (#2912)

Seamus4f3db67175b7
diff --git a/js/app/packages/app/component/PreviewPanel.tsx b/js/app/packages/app/component/PreviewPanel.tsx
index 7286e56960..ef37876564 100644
--- a/js/app/packages/app/component/PreviewPanel.tsx
+++ b/js/app/packages/app/component/PreviewPanel.tsx
@@ -201,7 +201,7 @@ const PreviewPanelContent: Component<NonNullableFields<PreviewPanel>> = (
export const PreviewPanel: Component<PreviewPanel> = (props) => {
return (
- <div class="flex flex-row size-full sm:w-[70%] max-sm:h-[50%] max-sm:border-t border-edge-muted shrink-0">
+ <div class="flex flex-row size-full">
<Show when={props.selectedEntity}>
{(selectedEntity) => (
<PreviewPanelContent
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 73bce92787..aa6e74a788 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -35,6 +35,7 @@ import { SplitPanelContext } from '@app/component/split-layout/context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { CollapsibleHeaderItem } from '@app/component/split-layout/components/CollapsibleHeaderItem';
import { LoadingBlock } from '@core/component/LoadingBlock';
+import { Resize } from '@core/component/Resize';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import {
@@ -789,10 +790,15 @@ export const SoupViewList = (props: SoupViewListProps) => {
const featuredCount = createMemo(() => featuredIds().length);
+ const previewVisible = createMemo(
+ () =>
+ (!!soup.previewEntity() || panel.previewState[0]()) && !!soup.focus.item()
+ );
+
return (
<MaybeSoupEntityActionDrawerManager>
<div
- class="size-full flex bracket-never no-select-children"
+ class="size-full bracket-never no-select-children"
ref={(el) => {
setSoupViewRef(el);
attachHotkeys(el);
@@ -805,195 +811,224 @@ export const SoupViewList = (props: SoupViewListProps) => {
data-soup-view
data-soup-view-id={panel.handle.id + (previewPanel ? '-preview' : '')}
>
- <div
- class="@container/uList size-full unified-list-root flex flex-col"
- classList={{
- 'border-r border-edge-muted': soup.previewEntity() !== undefined,
- }}
- >
- <StaticMarkdownContext>
- <Switch>
- <Match when={source.isLoading() && !rows().length}>
- <LoadingBlock />
- </Match>
- <Match
- when={
- (isSearchServiceLoading() || isLocalSearchSettling()) &&
- !rows().length
- }
- >
- <div class="flex items-center gap-2 px-3 py-3 text-xs text-text-muted">
- <Spinner class="size-3 animate-spin" />
- Searching...
- </div>
- </Match>
- <Match when={!rows().length}>
- <EmptyState
- search={!!searchText()}
- hasRefinementsFromBase={hasActiveRefinements()}
- onClearFilters={resetToTabDefaults}
- />
- </Match>
- <Match when={rows().length}>
- <ListLayoutProvider ref={localEntityListRef}>
- <EntityRowProvider
- container={localEntityListRef}
- canSwipeLeft={(entityId) => {
- const entity = entityById().get(entityId);
- if (!entity) return false;
- return markDoneAction.canExecute(entity.original);
- }}
- onSwipeLeft={(entityId) => {
- const entity = entityById().get(entityId);
- if (!entity) return;
- markDoneAction.executeWithSoup([entity.original], soup);
- }}
- setCollapseEntity={soup.collapseEntity.set}
+ <Resize.Zone direction="horizontal" gutter={0}>
+ <Resize.Panel
+ id="soup-list"
+ minSize={200}
+ maxSize={previewVisible() ? 840 : undefined}
+ >
+ <div
+ class="@container/uList size-full unified-list-root flex flex-col"
+ classList={{
+ 'border-r border-edge-muted':
+ soup.previewEntity() !== undefined,
+ }}
+ >
+ <StaticMarkdownContext>
+ <Switch>
+ <Match when={source.isLoading() && !rows().length}>
+ <LoadingBlock />
+ </Match>
+ <Match
+ when={
+ (isSearchServiceLoading() || isLocalSearchSettling()) &&
+ !rows().length
+ }
>
- <SoupList
- cache={listStateCache.get(cacheKey)?.virtualCache}
- ref={setLocalEntityListRef}
- virtualizerClass="scrollbar-hidden"
- class="overflow-hidden flex min-w-0"
- virtualizerRef={registerVirtualizerHandler}
- onScrollBottom={debouncedFetchMore}
- scrollBottomOffset={300}
- rows={rows()}
- >
- {(row, i) => {
- const timestamp = () => {
- if (row.original.sortTs) return row.original.sortTs;
-
- const sort_ = soup.sort.active();
- if (!sort_.length) return;
-
- switch (sort_[0].id) {
- case 'viewed_at':
- return row.original.viewedAt;
- case 'created_at':
- return row.original.createdAt;
- case 'updated_at':
- return row.original.updatedAt;
- default:
- return row.original.createdAt;
- }
- };
-
- return (
- <>
- <Show when={i() === 0 && featuredCount() > 0}>
- <div class="px-3 py-1.5 text-xs text-text-muted font-medium">
- Featured Results
- </div>
- </Show>
- <Show
- when={
- i() === featuredCount() && featuredCount() > 0
- }
- >
- <div class="px-3 py-1.5 text-xs text-text-muted font-medium border-t border-edge-muted mt-1">
- More Results
- </div>
- </Show>
- <SoupEntityContextMenu entity={row.original}>
- <ListEntity
- entity={row.original}
- timestamp={timestamp()}
- highlighted={
- panel.isPanelActive() && row.isFocused()
- }
- onMouseMove={() => {
- if (isKeypressActive()) return;
- if (soup.previewEntity()) return;
- soup.focus.set(row.original.id);
- }}
- showUnrollNotifications={
- soup.filters.isActive('signal') &&
- !soup.filters.isActive('noise')
- }
- checked={row.isSelected()}
- onChecked={(next: boolean, shiftKey: boolean) =>
- handleMultiSelectChecked({
- entity: row.original,
- entityIndex: i(),
- next,
- shiftKey: shiftKey ?? false,
- })
- }
- onClick={(event: MouseEvent) => {
- onEntityClick({
- type: 'entity',
- entity: row.original,
- event,
- location: undefined,
- });
- }}
- onProjectClick={(projectEntity, event) => {
- onEntityClick({
- type: 'project',
- projectEntity,
- entity: row.original,
- event,
- location: undefined,
- });
- }}
- onContentHitClick={(
- e: PointerEvent | MouseEvent,
- location?: SearchLocation
- ) => {
- onEntityClick({
- type: 'entity',
- entity: row.original,
- event: e,
- location,
- });
- }}
- entityRowConfig={{
- swipeLeftColor: 'bg-success',
- swipeLeftRevealedComponent: (
- <CheckIcon class="size-8 text-panel" />
- ),
- }}
- />
- </SoupEntityContextMenu>
- <Show
- when={
- i() === rows().length - 1 &&
- isSearchServiceLoading()
+ <div class="flex items-center gap-2 px-3 py-3 text-xs text-text-muted">
+ <Spinner class="size-3 animate-spin" />
+ Searching...
+ </div>
+ </Match>
+ <Match when={!rows().length}>
+ <EmptyState
+ search={!!searchText()}
+ hasRefinementsFromBase={hasActiveRefinements()}
+ onClearFilters={resetToTabDefaults}
+ />
+ </Match>
+ <Match when={rows().length}>
+ <ListLayoutProvider ref={localEntityListRef}>
+ <EntityRowProvider
+ container={localEntityListRef}
+ canSwipeLeft={(entityId) => {
+ const entity = entityById().get(entityId);
+ if (!entity) return false;
+ return markDoneAction.canExecute(entity.original);
+ }}
+ onSwipeLeft={(entityId) => {
+ const entity = entityById().get(entityId);
+ if (!entity) return;
+ markDoneAction.executeWithSoup(
+ [entity.original],
+ soup
+ );
+ }}
+ setCollapseEntity={soup.collapseEntity.set}
+ >
+ <SoupList
+ cache={listStateCache.get(cacheKey)?.virtualCache}
+ ref={setLocalEntityListRef}
+ virtualizerClass="scrollbar-hidden"
+ class="overflow-hidden flex min-w-0"
+ virtualizerRef={registerVirtualizerHandler}
+ onScrollBottom={debouncedFetchMore}
+ scrollBottomOffset={300}
+ rows={rows()}
+ >
+ {(row, i) => {
+ const timestamp = () => {
+ if (row.original.sortTs)
+ return row.original.sortTs;
+
+ const sort_ = soup.sort.active();
+ if (!sort_.length) return;
+
+ switch (sort_[0].id) {
+ case 'viewed_at':
+ return row.original.viewedAt;
+ case 'created_at':
+ return row.original.createdAt;
+ case 'updated_at':
+ return row.original.updatedAt;
+ default:
+ return row.original.createdAt;
}
- >
- <div class="flex items-center gap-2 px-3 py-3 text-xs text-text-muted">
- <Spinner class="size-3 animate-spin" />
- Searching...
- </div>
- </Show>
- <Show when={i() === rows().length - 1}>
- <div class="h-15" />
- </Show>
- </>
- );
- }}
- </SoupList>
- </EntityRowProvider>
- </ListLayoutProvider>
-
- <Show when={!props.customScrollbarHidden}>
- <CustomScrollbar
- scrollContainer={() => {
- // Find the actual scroll container (VList creates its own scroll container)
- const listEl = localEntityListRef();
- if (!listEl) return undefined;
- const scrollContainer = listEl.querySelector(
- '[data-soup-list-container]'
- ) as HTMLElement;
- return scrollContainer || undefined;
- }}
- />
- </Show>
- </Match>
- </Switch>
- </StaticMarkdownContext>
- </div>
+ };
+
+ return (
+ <>
+ <Show when={i() === 0 && featuredCount() > 0}>
+ <div class="px-3 py-1.5 text-xs text-text-muted font-medium">
+ Featured Results
+ </div>
+ </Show>
+ <Show
+ when={
+ i() === featuredCount() &&
+ featuredCount() > 0
+ }
+ >
+ <div class="px-3 py-1.5 text-xs text-text-muted font-medium border-t border-edge-muted mt-1">
+ More Results
+ </div>
+ </Show>
+ <SoupEntityContextMenu entity={row.original}>
+ <ListEntity
+ entity={row.original}
+ timestamp={timestamp()}
+ highlighted={
+ panel.isPanelActive() && row.isFocused()
+ }
+ onMouseMove={() => {
+ if (isKeypressActive()) return;
+ if (soup.previewEntity()) return;
+ soup.focus.set(row.original.id);
+ }}
+ showUnrollNotifications={
+ soup.filters.isActive('signal') &&
+ !soup.filters.isActive('noise')
+ }
+ checked={row.isSelected()}
+ onChecked={(
+ next: boolean,
+ shiftKey: boolean
+ ) =>
+ handleMultiSelectChecked({
+ entity: row.original,
+ entityIndex: i(),
+ next,
+ shiftKey: shiftKey ?? false,
+ })
+ }
+ onClick={(event: MouseEvent) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event,
+ location: undefined,
+ });
+ }}
+ onProjectClick={(projectEntity, event) => {
+ onEntityClick({
+ type: 'project',
+ projectEntity,
+ entity: row.original,
+ event,
+ location: undefined,
+ });
+ }}
+ onContentHitClick={(
+ e: PointerEvent | MouseEvent,
+ location?: SearchLocation
+ ) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event: e,
+ location,
+ });
+ }}
+ entityRowConfig={{
+ swipeLeftColor: 'bg-success',
+ swipeLeftRevealedComponent: (
+ <CheckIcon class="size-8 text-panel" />
+ ),
+ }}
+ />
+ </SoupEntityContextMenu>
+ <Show
+ when={
+ i() === rows().length - 1 &&
+ isSearchServiceLoading()
+ }
+ >
+ <div class="flex items-center gap-2 px-3 py-3 text-xs text-text-muted">
+ <Spinner class="size-3 animate-spin" />
+ Searching...
+ </div>
+ </Show>
+ <Show when={i() === rows().length - 1}>
+ <div class="h-15" />
+ </Show>
+ </>
+ );
+ }}
+ </SoupList>
+ </EntityRowProvider>
+ </ListLayoutProvider>
+
+ <Show when={!props.customScrollbarHidden}>
+ <CustomScrollbar
+ scrollContainer={() => {
+ // Find the actual scroll container (VList creates its own scroll container)
+ const listEl = localEntityListRef();
+ if (!listEl) return undefined;
+ const scrollContainer = listEl.querySelector(
+ '[data-soup-list-container]'
+ ) as HTMLElement;
+ return scrollContainer || undefined;
+ }}
+ />
+ </Show>
+ </Match>
+ </Switch>
+ </StaticMarkdownContext>
+ </div>
+ </Resize.Panel>
+ <Show when={previewVisible()}>
+ <Resize.Panel id="soup-preview" minSize={300}>
+ <PreviewPanel
+ selectedEntity={soup.focus.item()}
+ orchestrator={orchestrator}
+ splitPanelContext={panel}
+ onFocusOut={() => {
+ soupViewRef()?.focus();
+ }}
+ />
+ </Resize.Panel>
+ </Show>
+ </Resize.Zone>
<Show when={soup.selection.count() > 0}>
<SoupEntitySelectionToolbar
selected={soup.selection.selected()}
@@ -1001,21 +1036,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
onClear={soup.selection.clear}
/>
</Show>
- <Show
- when={
- (soup.previewEntity() || panel.previewState[0]()) &&
- !!soup.focus.item()
- }
- >
- <PreviewPanel
- selectedEntity={soup.focus.item()}
- orchestrator={orchestrator}
- splitPanelContext={panel}
- onFocusOut={() => {
- soupViewRef()?.focus();
- }}
- />
- </Show>
</div>
</MaybeSoupEntityActionDrawerManager>
);
diff --git a/js/app/packages/core/component/Resize/Resize.tsx b/js/app/packages/core/component/Resize/Resize.tsx
index 1d498abaab..53c85da31b 100644
--- a/js/app/packages/core/component/Resize/Resize.tsx
+++ b/js/app/packages/core/component/Resize/Resize.tsx
@@ -94,6 +94,10 @@ function Zone(props: ParentProps<ZoneProps>) {
solver.dropPanel(id);
}
+ function update(id: PanelId, config: { minSize?: number; maxSize?: number }) {
+ solver.updatePanel(id, config);
+ }
+
const layouts = createMemo(() => {
const solve = solver.solve();
return solver.order().map((id) => ({
@@ -117,6 +121,7 @@ function Zone(props: ParentProps<ZoneProps>) {
direction,
register,
unregister,
+ update,
gutterSize: gutterPx,
size: zoneSize,
offsetOf,
@@ -233,6 +238,13 @@ function Panel(props: ParentProps<PanelProps>) {
);
});
+ createEffect(() => {
+ ctx.update(props.id, {
+ minSize: props.minSize,
+ maxSize: props.maxSize ?? Infinity,
+ });
+ });
+
createEffect(() => {
const collapsed = props.collapsed?.();
if (collapsed === undefined) return;
diff --git a/js/app/packages/core/component/Resize/solver.ts b/js/app/packages/core/component/Resize/solver.ts
index 7ad282c336..9d0da6bfe2 100644
--- a/js/app/packages/core/component/Resize/solver.ts
+++ b/js/app/packages/core/component/Resize/solver.ts
@@ -12,6 +12,10 @@ export type ResizeSolver = {
readonly direction: 'horizontal' | 'vertical';
addPanel: (panel: PanelConfig, index?: number) => void;
dropPanel: (id: PanelId) => void;
+ updatePanel: (
+ id: PanelId,
+ config: { minSize?: number; maxSize?: number }
+ ) => void;
solve: () => LayoutResult;
reset: () => void;
moveHandle: (index: number, delta: number) => void;
@@ -303,6 +307,30 @@ export function createResizeSolver(params: {
});
}
+ function updatePanel(
+ id: PanelId,
+ config: { minSize?: number; maxSize?: number }
+ ) {
+ const panel = panelData[id];
+ if (!panel) return;
+ let changed = false;
+ if ('minSize' in config) {
+ const next = config.minSize ?? 0;
+ if (panel.minSize !== next) {
+ panel.minSize = next;
+ changed = true;
+ }
+ }
+ if ('maxSize' in config) {
+ const next = config.maxSize ?? Infinity;
+ if (panel.maxSize !== next) {
+ panel.maxSize = next;
+ changed = true;
+ }
+ }
+ if (changed) setDirty();
+ }
+
function dropPanel(id: PanelId) {
batch(() => {
const ids = untrack(order);
@@ -452,6 +480,7 @@ export function createResizeSolver(params: {
direction: params.direction,
addPanel,
dropPanel,
+ updatePanel,
solve: layout,
reset: () => {
const panels = panelsInOrder();
diff --git a/js/app/packages/core/component/Resize/types.ts b/js/app/packages/core/component/Resize/types.ts
index 191741a80b..c332db6798 100644
--- a/js/app/packages/core/component/Resize/types.ts
+++ b/js/app/packages/core/component/Resize/types.ts
@@ -36,6 +36,7 @@ export type ResizeZoneCtx = {
direction: 'horizontal' | 'vertical';
register: (panel: PanelConfig, index?: number) => void;
unregister: (id: PanelId) => void;
+ update: (id: PanelId, config: { minSize?: number; maxSize?: number }) => void;
gutterSize: () => number;
size: () => number;
sizeOf: (id: PanelId) => () => number;