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(splits): limit split creation based on size (#336)

Seamus17fe7b6118fe
diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsx
index e490d48268..b31f489f00 100644
--- a/js/app/packages/app/component/dock/Dock.tsx
+++ b/js/app/packages/app/component/dock/Dock.tsx
@@ -334,10 +334,13 @@ export function Dock() {
onClick={() => {
const manager = globalSplitManager();
if (manager) {
- manager.createNewSplit({
- id: 'unified-list',
- type: 'component',
- });
+ const canFit = manager.resizeContext()?.canFit({ minSize: 400 }) ?? true;
+ if (canFit) {
+ manager.createNewSplit({
+ id: 'unified-list',
+ type: 'component',
+ });
+ }
}
}}
icon={SplitIcon}
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index a6395a431d..dfc7eac17d 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -290,7 +290,9 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
scopeId: 'global',
description: 'Create new split',
keyDownHandler: () => {
- splitManager.createNewSplit();
+ const canFit =
+ splitManager.resizeContext()?.canFit({ minSize: 400 }) ?? true;
+ if (canFit) splitManager.createNewSplit();
return true;
},
runWithInputFocused: true,
@@ -308,7 +310,11 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
return (
<SplitLayoutContext.Provider value={{ manager: splitManager }}>
- <Resize.Zone direction="horizontal" gutter={gutterSize()}>
+ <Resize.Zone
+ direction="horizontal"
+ gutter={gutterSize()}
+ captureResizeCtx={splitManager.setResizeContext}
+ >
<For each={ids()}>
{(id, index) => (
<Resize.Panel id={id} minSize={400}>
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index dde315193a..382ec578fb 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -1,9 +1,15 @@
import type { BlockName } from '@core/block';
+import { ResizeZoneCtx } from '@core/component/Resize/types';
import type {
BlockInstanceHandle,
BlockOrchestrator,
} from '@core/orchestrator';
-import { type Accessor, createMemo, type JSXElement } from 'solid-js';
+import {
+ type Accessor,
+ createMemo,
+ createSignal,
+ type JSXElement,
+} from 'solid-js';
import { createStore, produce, reconcile } from 'solid-js/store';
import { resolveComponent } from './componentRegistry';
import { createHistory, type History } from './history';
@@ -102,6 +108,7 @@ export type SplitManager = {
readonly activeSplitId: Accessor<SplitId | undefined>;
readonly lastActiveSplitId: Accessor<SplitId | undefined>;
readonly events: Accessor<SplitEventWithType>;
+ readonly resizeContext: Accessor<ResizeZoneCtx | undefined>;
// methods
/** Get a split by its split id */
@@ -147,6 +154,9 @@ export type SplitManager = {
/** A function to return focus to the most recent split. */
returnFocus: () => void;
+
+ /** Set the layout resize context from the component tree. */
+ setResizeContext: (cts: ResizeZoneCtx) => void;
} & UrlCapabilities;
export type SplitHandle = {
@@ -241,6 +251,8 @@ export function createSplitLayout(
events: [],
});
+ const [resizeContext, setResizeContext] = createSignal<ResizeZoneCtx>();
+
const [splitNamesById, setSplitNamesById] = createStore<{
[id: SplitId]: string;
}>({});
@@ -667,5 +679,7 @@ export function createSplitLayout(
toggleSpotlightSplit,
tabTitle,
returnFocus: () => dispatchEvent(SplitEvent.ReturnFocus, undefined),
+ resizeContext,
+ setResizeContext,
};
}
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 9ec518f37f..455c2e03f2 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -265,7 +265,7 @@ export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {
canvas: WideDiagram,
html: WideFileCode,
channel: WideChannel,
- company: WideUnknown,
+ company: WideChannel,
email: WideEmail,
code: WideFileCode,
pdf: WideBook,
diff --git a/js/app/packages/core/component/Resize/Resize.tsx b/js/app/packages/core/component/Resize/Resize.tsx
index 2e0b9d02a1..0dfcf2364d 100644
--- a/js/app/packages/core/component/Resize/Resize.tsx
+++ b/js/app/packages/core/component/Resize/Resize.tsx
@@ -31,6 +31,7 @@ type ZoneProps = {
minSize?: number;
class?: string;
id?: string;
+ captureResizeCtx?: (ctx: ResizeZoneCtx) => void;
};
/**
@@ -120,6 +121,10 @@ function Zone(props: ParentProps<ZoneProps>) {
isHidden: solver.isHidden,
};
+ createEffect(() => {
+ props.captureResizeCtx?.(ctx);
+ });
+
return (
<div
class={props.class ?? ''}
@@ -128,7 +133,6 @@ function Zone(props: ParentProps<ZoneProps>) {
position: 'relative',
height: '100%',
width: '100%',
- // overflow: 'hidden',
}}
data-resize-zone
>
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 791dd3bde7..b4107c2ec4 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -1,3 +1,4 @@
+import { EntityIcon } from '@core/component/EntityIcon';
import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
import { TOKENS } from '@core/hotkey/tokens';
import { matches } from '@core/util/match';
@@ -744,12 +745,7 @@ function DirectMessageIcon(props: { entity: EntityData }) {
? (props.entity.particpantIds ?? []).filter((id) => id !== userId()).at(0)
: undefined;
- const Fallback = () => (
- <Dynamic
- component={getIconConfig('directMessage').icon}
- class={`flex size-full ${getIconConfig('directMessage').foreground}`}
- />
- );
+ const Fallback = () => <EntityIcon targetType="directMessage" />;
return (
<div class="bg-panel size-5 rounded-full p-[2px]">