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(ui): fix vertical thrash in current sidebar (#4384)

Seamus4874328e479e
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index f31e8bcf63..c268fb7434 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -78,6 +78,9 @@ export function Layout(props: RouteSectionProps) {
isAuthenticated() === true &&
!AUTH_URLS.includes(location.pathname)
);
+ createEffect(() => {
+ console.log('VIZ', sidebarVisible());
+ });
return (
<SidebarVisibilityContext.Provider value={sidebarVisible}>
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index a96c152c9b..c2b7c5ea1d 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -9,7 +9,6 @@ import {
SidebarPromoCard,
SidebarPromoHint,
} from '@app/component/app-sidebar/sidebar-promo';
-import { CommandState } from '@app/component/command';
import { InteractiveOnboardingModal } from '@app/component/interactive-onboarding/InteractiveOnboardingModal';
import { createMenuOpen, setCreateMenuOpen } from '@app/component/Launcher';
import { buildDocumentTypeQuery } from '@app/component/next-soup/filters/configs/document-type-query';
@@ -27,11 +26,7 @@ import type {
SplitHandle,
} from '@app/component/split-layout/layoutManager';
import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';
-import {
- LIST_VIEW_ID,
- LIST_VIEW_PATHS,
- type ListView,
-} from '@app/constants/list-views';
+import { LIST_VIEW_PATHS, type ListView } from '@app/constants/list-views';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';
import { globalSplitManager } from '@app/signal/splitLayout';
@@ -64,7 +59,6 @@ import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';
import type { ValidHotkey } from '@core/hotkey/types';
import { activateClosestDOMScope } from '@core/hotkey/utils';
import LogoIcon from '@icon/macro-logo.svg';
-import { AnimatedSquareCommandKIcon } from '@icon/square-command-k';
import { AnimatedSquareSidebarIcon } from '@icon/square-sidebar';
import { AnimatedCallIcon } from '@icon/wide-call';
import { AnimatedChannelIcon } from '@icon/wide-channel';
@@ -72,18 +66,15 @@ import { AnimatedCompanyIcon } from '@icon/wide-company';
import { AnimatedEmailIcon } from '@icon/wide-email';
import { AnimatedFileMdIcon } from '@icon/wide-fileMd';
import { AnimatedInboxIcon } from '@icon/wide-inbox';
-import { AnimatedNewSplitIcon } from '@icon/wide-newSplit';
-import { AnimatedPlusIcon } from '@icon/wide-plus';
import { AnimatedSearchIcon } from '@icon/wide-search';
import { AnimatedStarIcon } from '@icon/wide-star';
import { AnimatedTaskIcon } from '@icon/wide-task';
import { ContextMenu } from '@kobalte/core/context-menu';
-import { useNotificationSettings } from '@notifications';
-import BellIcon from '@phosphor/bell.svg';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CaretUpIcon from '@phosphor/caret-up.svg';
import HomeIcon from '@phosphor/house.svg';
import PlayIcon from '@phosphor/play.svg';
+import PlusIcon from '@phosphor/plus.svg';
import SignOutIcon from '@phosphor/sign-out.svg';
import { useEmailLinksQuery } from '@queries/email/link';
import { debounce } from '@solid-primitives/scheduled';
@@ -522,6 +513,8 @@ const SidebarShortcutLink = (props: SidebarShortcutLinkProps) => {
return (
<NavRow
draggable={false}
+ class="h-8"
+ fullWidth
tooltipPlacement="right"
label={props.isSlim() ? props.label : undefined}
onMouseEnter={() => setIsHovering(true)}
@@ -560,10 +553,11 @@ const SidebarActionButton = (props: SidebarActionButtonProps) => {
return (
<NavRow
- class="group-data-[slim=true]/sidebar:justify-center"
+ class="center h-8"
+ fullWidth
tooltipPlacement="right"
- label={props.isSlim() ? props.label : undefined}
- hotkey={props.isSlim() ? props.hotkeyToken : undefined}
+ label={props.label}
+ hotkey={props.hotkeyToken}
onMouseDown={(e) => {
if (e.button !== 0) return;
e.preventDefault();
@@ -605,7 +599,7 @@ const SidebarHeaderIconButton = (props: {
const [hovering, setHovering] = createSignal(false);
return (
<Button
- class="rounded-md p-1 text-ink-extra-muted [&_svg]:size-4"
+ class="rounded-md p-1 text-ink-extra-muted size-8 [&_svg]:size-4"
size="icon-sm"
label={props.label}
hotkey={props.hotkey}
@@ -636,11 +630,12 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
<Dropdown.Trigger
variant="ghost"
class={cn(
- 'flex items-center w-full rounded-md cursor-default text-ink-extra-muted not-disabled:hover:bg-ink/3 h-9',
- 'justify-start gap-2 px-1.5 py-1',
- 'group-data-[slim=true]/sidebar:justify-center group-data-[slim=true]/sidebar:gap-0'
+ 'flex items-center rounded-md cursor-default text-ink-extra-muted not-disabled:hover:bg-ink/3 h-9',
+ 'justify-start gap-2 px-1.5 py-1'
)}
- label={props.isSlim() ? 'Settings' : undefined}
+ label="Settings"
+ fullWidth
+ tooltipDisabled={!props.isSlim()}
tooltipPlacement="right"
onMouseDown={(e: MouseEvent) => {
if (e.button !== 0) return;
@@ -652,13 +647,12 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
fallback={<div class="size-5 shrink-0 rounded-full bg-ink/10" />}
>
{(id) => (
- <div class="size-5">
+ <div class="size-5 shrink-0">
<UserIcon
id={id()}
size="fill"
suppressClick
showTooltip={false}
- // class="-m-1"
/>
</div>
)}
@@ -752,7 +746,6 @@ export const AppSidebar = (props: AppSidebarProps) => {
const layout = useSplitLayout();
const { openSettings, setActiveTabId, settingsOpen } = useSettingsState();
const isTabAvailable = useSettingsTabAvailable();
- const notificationSettings = useNotificationSettings();
const callCtx = useCallContextOptional();
const homeViewEnabled = useFeatureFlag('enable-home-view', {
@@ -771,18 +764,6 @@ export const AppSidebar = (props: AppSidebarProps) => {
enabledOverride: ENABLE_NEW_PRICING_OVERRIDE,
});
- const showEnableNotifications = () =>
- notificationSettings.isSupported && notificationSettings.canPrompt();
-
- const handleEnableNotifications = async () => {
- if (!notificationSettings.isSupported) return;
- try {
- await notificationSettings.toggle(true);
- } catch (error) {
- console.error('Failed to enable notifications:', error);
- }
- };
-
const [hotkeyVisible, setHotkeyVisible] = createSignal(false);
const visibleLinks = createMemo((): SidebarItem[] => {
@@ -824,13 +805,6 @@ export const AppSidebar = (props: AppSidebarProps) => {
activateClosestDOMScope();
};
- const handleCommandPaletteClick = () => {
- if (!CommandState.isOpen()) {
- analytics.track('command_menu_open', { from: 'sidebar' });
- }
- CommandState.toggle();
- };
-
const handleCreateClick = () => {
const willOpen = !createMenuOpen();
if (willOpen) {
@@ -839,25 +813,6 @@ export const AppSidebar = (props: AppSidebarProps) => {
setCreateMenuOpen((p) => !p);
};
- const canCreateNewSplit = () =>
- globalSplitManager()?.canAppendSplit() ?? true;
-
- const handleNewSplitClick = () => {
- const manager = globalSplitManager();
- if (!manager || !manager.canAppendSplit()) return;
-
- analytics.track('split_created', { from: 'sidebar' });
- manager.createNewSplit({
- content: {
- type: 'component',
- id: LIST_VIEW_ID.inbox,
- },
- activate: true,
- allowDuplicate: true,
- referredFrom: 'sidebar',
- });
- };
-
const openSettingsTab = (tab: SettingsTab) => {
if (!isTabAvailable(tab)) return;
if (settingsOpen()) {
@@ -893,51 +848,24 @@ export const AppSidebar = (props: AppSidebarProps) => {
sidebarShell = el ?? undefined;
}}
class={cn(
- 'group/sidebar h-full py-2 flex flex-col gap-0 mobile:absolute mobile:z-modal-content overflow-hidden',
+ 'group/sidebar h-full p-3 flex flex-col gap-0 mobile:absolute mobile:z-modal-content overflow-hidden',
isExpanded() &&
- 'max-w-49.75 w-full mobile:max-w-2/3 translate-x-0 opacity-100',
+ 'max-w-48 w-full mobile:max-w-2/3 translate-x-0 opacity-100',
props.sidebarState === 'hidden' &&
'-translate-x-full overflow-hidden opacity-0',
- isSlim() && 'max-w-12 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
+ isSlim() && 'max-w-14 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
)}
data-expanded={isExpanded()}
data-slim={isSlim()}
style={{ transition: SIDEBAR_MAX_WIDTH_TRANSITION_STYLE }}
>
- <div class="flex items-center justify-between p-2 relative group-data-[slim=true]/sidebar:pr-2.25">
+ <div class="flex items-center justify-between relative">
<div class="flex items-center group/logo-area w-full group-data-[slim=true]/sidebar:justify-end">
- <div class="text-accent group-data-[slim=true]/sidebar:opacity-0 group-data-[slim=true]/sidebar:max-w-0 min-w-0 pl-1 group-data-[slim=true]/sidebar:pl-0">
+ <div class="text-accent group-data-[slim=true]/sidebar:opacity-0 group-data-[slim=true]/sidebar:max-w-0 min-w-0 pl-1 group-data-[slim=true]/sidebar:pl-0 transition-opacity">
<LogoIcon class="size-6" />
</div>
<div class="grow shrink-10 min-w-0 group-data-[slim=true]/sidebar:hidden" />
- <Show when={isExpanded()}>
- <div class="flex items-center gap-1 mr-1">
- <Show when={showEnableNotifications()}>
- <Button
- class="rounded-md p-1 text-ink-extra-muted"
- size="icon-sm"
- label="Enable Notifications"
- onClick={handleEnableNotifications}
- >
- <BellIcon />
- </Button>
- </Show>
- <SidebarHeaderIconButton
- label="Command"
- hotkey={TOKENS.global.commandMenu}
- onClick={handleCommandPaletteClick}
- icon={AnimatedSquareCommandKIcon}
- />
- <SidebarHeaderIconButton
- label="New Split"
- hotkey={TOKENS.global.createNewSplit}
- disabled={!canCreateNewSplit()}
- onClick={handleNewSplitClick}
- icon={AnimatedNewSplitIcon}
- />
- </div>
- </Show>
<SidebarHeaderIconButton
label={isExpanded() ? 'Shrink Sidebar' : 'Expand Sidebar'}
hotkey={TOKENS.global.toggleSidebar}
@@ -954,26 +882,18 @@ export const AppSidebar = (props: AppSidebarProps) => {
</div>
</div>
- <div class="px-2">
- <hr class="border-transparent" />
- </div>
-
- <div class="w-full px-2 my-[4.5px]">
+ <div class="w-full mb-2">
<SidebarActionButton
label="Create"
hotkeyToken={TOKENS.global.createCommand}
isSlim={isSlim}
onClick={handleCreateClick}
- icon={() => <AnimatedPlusIcon class="size-4" />}
+ icon={() => <PlusIcon class="size-4" />}
/>
</div>
- <div class="px-2">
- <hr class="border-transparent mb-2" />
- </div>
-
<nav>
- <ul class="size-full px-2 flex flex-col gap-1">
+ <ul class="size-full flex flex-col gap-0.5">
<For each={visibleLinks()}>
{(link) => (
<li class="flex flex-col items-center justify-center">
@@ -1069,7 +989,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
</div>
</Show>
- <div class="w-full px-2 flex flex-col gap-1 mb-1">
+ <div class="w-full flex flex-col gap-0.5 mb-1">
<For each={PROMOTED_SETTINGS_TABS}>
{(tab) => (
<Show
@@ -1088,7 +1008,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
</For>
</div>
- <div class="w-full px-2">
+ <div class="w-full">
<SidebarSettingsWidget isSlim={isSlim} onSelect={openSettingsTab} />
</div>
<InviteModal />
@@ -1143,7 +1063,6 @@ const SidebarLink = (props: SidebarLinkProps) => {
id: props.id,
params: props.params,
}) as const;
-
const canOpenInNewSplit = () =>
globalSplitManager()?.canAppendSplit() ?? true;
@@ -1175,25 +1094,23 @@ const SidebarLink = (props: SidebarLinkProps) => {
return (
<ContextMenu>
- <ContextMenu.Trigger class="w-full">
+ <ContextMenu.Trigger class="w-full h-8">
<NavRow
draggable={false}
data-sidebar-link={props.id}
data-active={isActive() ? '' : undefined}
active={isActive() && !props.suppressActiveStyle}
- class="group-data-[slim=true]/sidebar:justify-center"
+ class="h-8"
+ fullWidth
tooltipPlacement="right"
onMouseEnter={() => setIsHovering(true)}
- label={
- props.sidebarState === 'slim' ? `Go to ${props.label}` : undefined
- }
+ label={`Go to ${props.label}`}
hotkey={
- props.sidebarState === 'slim'
- ? props.standaloneHotkey
- ? props.hotkeyToken
- : [TOKENS.sidebar.goToLeader, props.hotkeyToken]
- : undefined
+ props.standaloneHotkey
+ ? props.hotkeyToken
+ : [TOKENS.sidebar.goToLeader, props.hotkeyToken]
}
+ tooltipDisabled={props.sidebarState !== 'slim'}
onMouseLeave={() => setIsHovering(false)}
onMouseDown={(e) => {
if (e.button !== 0) return;
@@ -1230,7 +1147,7 @@ const SidebarLink = (props: SidebarLinkProps) => {
}}
>
<Show when={props.icon}>
- <div class="shrink-0 [&_svg]:size-4">
+ <div class="shrink-0 [&_svg]:size-3.5">
<Dynamic component={props.icon} triggerAnimation={isHovering()} />
</div>
</Show>
diff --git a/js/app/packages/ui/components/Button.tsx b/js/app/packages/ui/components/Button.tsx
index 5ba5af1a8e..15da379901 100644
--- a/js/app/packages/ui/components/Button.tsx
+++ b/js/app/packages/ui/components/Button.tsx
@@ -15,6 +15,12 @@ export type ButtonProps = ButtonRootProps<'button'> &
ComponentProps<'button'> & {
depth?: 0 | 1 | 2 | 3 | 4 | 5;
tooltipPlacement?: Placement;
+ /**
+ * Stretch the button (and, when a tooltip wraps it, the tooltip's trigger
+ * wrapper) to fill the available width. Without this the tooltip wrapper is
+ * `inline-flex` and collapses a `w-full` button to its content width.
+ */
+ fullWidth?: boolean;
noTouchResize?: boolean;
variant?: ButtonVariant;
children?: JSX.Element;
@@ -27,6 +33,7 @@ export type ButtonProps = ButtonRootProps<'button'> &
shortcut?: string | string[];
size?: ButtonSize;
class?: string;
+ tooltipDisabled?: boolean;
};
export type ButtonSize = 'sm' | 'icon-sm' | 'md' | 'icon-md' | 'lg' | 'icon-lg';
@@ -74,6 +81,8 @@ export const Button = (props: ButtonProps) => {
'depth',
'label',
'size',
+ 'fullWidth',
+ 'tooltipDisabled',
]);
const group = useButtonGroupContext();
@@ -81,6 +90,7 @@ export const Button = (props: ButtonProps) => {
const cls = () =>
cn(
'relative inline-flex items-center justify-center font-medium leading-none border border-transparent rounded-sm whitespace-nowrap',
+ local.fullWidth && 'w-full',
{
'touch:min-h-9 touch:min-w-9 touch:[&_svg]:size-6':
!props.noTouchResize,
@@ -127,10 +137,12 @@ export const Button = (props: ButtonProps) => {
>
{(label) => (
<Tooltip
+ class={local.fullWidth ? 'w-full' : undefined}
hotkey={local.hotkey}
shortcut={local.shortcut}
placement={placement()}
label={label()}
+ disabled={local.tooltipDisabled}
>
{button()}
</Tooltip>
diff --git a/js/app/packages/ui/components/NavRow.tsx b/js/app/packages/ui/components/NavRow.tsx
index ca4ab89a43..22b2ae528c 100644
--- a/js/app/packages/ui/components/NavRow.tsx
+++ b/js/app/packages/ui/components/NavRow.tsx
@@ -12,7 +12,7 @@ import { Button, type ButtonProps } from './Button';
* which is merged last so callers can extend without leaking layout concerns in.
*/
const NAV_ROW_BASE =
- 'flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-md py-1 text-ink-extra-muted not-disabled:hover:bg-ink/3';
+ 'flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-md py-1 px-2 text-ink-extra-muted not-disabled:hover:bg-ink/3';
const NAV_ROW_ACTIVE = 'bg-ink/6 not-disabled:hover:bg-ink/6 text-ink';
export type NavRowProps = ButtonProps & { active?: boolean };
diff --git a/js/app/packages/ui/components/Tooltip.tsx b/js/app/packages/ui/components/Tooltip.tsx
index 1988d5aa80..430fa28606 100644
--- a/js/app/packages/ui/components/Tooltip.tsx
+++ b/js/app/packages/ui/components/Tooltip.tsx
@@ -18,6 +18,7 @@ type TooltipProps = ParentProps<{
as?: 'div' | 'span';
class?: string;
label: string;
+ disabled?: boolean;
}>;
/**
@@ -101,6 +102,7 @@ export function Tooltip(props: TooltipProps) {
closeDelay={0}
flip={true}
gutter={4}
+ disabled={props.disabled}
>
<KobalteTooltip.Trigger
ref={(ref) => {