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(core): side panel component first pass, flagged off (#3262)

Seamus8f3f989e6338
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index c059ce1e5f..fc271b69b9 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -386,13 +386,13 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
const AnimatedIcon = props.creatableBlock.animatedIcon;
return (
- <Layer depth={2}>
+ <Layer depth={4}>
<button
class={cn(
- ' size-28 relative flex flex-col sm:gap-4 gap-2 items-center isolate justify-center bg-surface ring ring-edge-muted transition-transform ease-out duration-200 rounded-sm',
+ 'size-28 shadow-md shadow-drop-shadow relative flex flex-col sm:gap-4 gap-2 items-center isolate justify-center bg-surface ring ring-edge transition-transform ease-click duration-200 rounded-sm',
`create-menu-${props.creatableBlock.label.toLowerCase()}`,
{
- '-translate-y-2 text-ink': props.focused,
+ '-translate-y-2 text-ink ring-2': props.focused,
'text-ink-extra-muted': !props.focused,
}
)}
@@ -405,17 +405,6 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
buttonRef?.focus();
}}
>
- <div
- class={cn(
- 'absolute size-full inset-0 transition-transform origin-top ease duration-200',
- getIconConfig(props.creatableBlock.blockName).background,
- {
- 'opacity-0': !props.focused,
- 'opacity-20': props.focused,
- }
- )}
- ></div>
-
<div class="absolute top-1.5 left-2 z-user-highlight p-1 px-1.5 text-ink border border-edge-muted rounded-xs text-xs">
<Hotkey token={props.creatableBlock.hotkeyToken} />
</div>
@@ -440,7 +429,7 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
'w-1/3 -translate-y-1 transition-all ease-out duration-200',
textFg(),
{
- 'text-edge': !props.focused,
+ 'text-ink-extra-muted': !props.focused,
'scale-110': props.focused,
}
)}
@@ -685,14 +674,14 @@ export const LauncherInner = (props: LauncherInnerProps) => {
}
`}</style>
Hold{' '}
- <span class="relative inline-grid place-items-center my-1">
+ <span class="relative inline-flex place-items-center my-1">
<span
ref={shiftRippleRef}
class="shift-ripple absolute inset-0 rounded-sm border border-accent pointer-events-none opacity-0"
/>
<span
class={cn(
- 'px-1 py-0.5 rounded-sm h-fit ring text-xs grid place-items-center transition-colors duration-150',
+ 'ring text-xs transition-colors duration-150',
shiftHeld()
? 'ring-accent text-accent bg-accent/10'
: 'ring-edge-muted'
@@ -737,7 +726,7 @@ export const Launcher = (props: LauncherProps) => {
<Dialog.Portal>
<Dialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay pattern-diagonal-4 pattern-edge-muted"></Dialog.Overlay>
<Dialog.Content>
- <Layer depth={1}>
+ <Layer depth={3}>
<div
class="fixed inset-0 z-modal w-screen h-screen flex items-center justify-center"
onClick={(e) => {
diff --git a/js/app/packages/app/component/side-panel/SidePanel.tsx b/js/app/packages/app/component/side-panel/SidePanel.tsx
new file mode 100644
index 0000000000..43a0acc68b
--- /dev/null
+++ b/js/app/packages/app/component/side-panel/SidePanel.tsx
@@ -0,0 +1,248 @@
+import { Resize, ResizeZoneContext } from '@core/component/Resize/Resize';
+import { isMobile } from '@core/mobile/isMobile';
+import CaretRight from '@icon/fill/caret-right-fill.svg';
+import { Accordion } from '@kobalte/core/accordion';
+import { Panel, Scroll } from '@ui';
+import {
+ type Accessor,
+ children,
+ createMemo,
+ createSignal,
+ For,
+ type JSX,
+ onCleanup,
+ onMount,
+ type ParentProps,
+ Show,
+ Suspense,
+ useContext,
+} from 'solid-js';
+import {
+ SidePanelContext,
+ type SidePanelContextType,
+ type SidePanelSectionEntry,
+} from './context';
+
+const NARROW_THRESHOLD_PX = 720;
+const SIDE_MIN_PX = 320;
+const SIDE_MAX_PX = 480;
+const MAIN_MIN_PX = 320;
+
+/**
+ * Layout root for a block that opts in to a right-side panel.
+ *
+ * Wraps `props.children` in a horizontal Resize.Zone with two panels:
+ * a main panel (the children) and a right side panel that hosts any
+ * `<SidePanel.Section>` descendants registered via context.
+ *
+ * The side panel is hidden when:
+ * - on mobile (`isMobile()`),
+ * - the layout root is narrower than NARROW_THRESHOLD_PX,
+ * - no sections are currently registered, OR
+ * - the user has toggled it closed via `ctx.setIsOpen(false)`.
+ *
+ * Sections are rendered as a Kobalte Accordion in JSX-declared order.
+ */
+function Layout(props: ParentProps) {
+ const [sections, setSections] = createSignal<SidePanelSectionEntry[]>([]);
+ const [openIds, setOpenIds] = createSignal<string[]>([]);
+ const [isOpen, setIsOpen] = createSignal(true);
+
+ const toggle = () => setIsOpen((prev) => !prev);
+
+ const register = (entry: SidePanelSectionEntry) => {
+ setSections((prev) => {
+ const next = prev.filter((s) => s.id !== entry.id);
+ next.push(entry);
+ return next;
+ });
+ if (entry.defaultOpen) {
+ setOpenIds((prev) =>
+ prev.includes(entry.id) ? prev : [...prev, entry.id]
+ );
+ }
+ };
+
+ const unregister = (id: string) => {
+ setSections((prev) => prev.filter((s) => s.id !== id));
+ setOpenIds((prev) => prev.filter((v) => v !== id));
+ };
+
+ const ctx: SidePanelContextType = {
+ register,
+ unregister,
+ sections,
+ isOpen,
+ setIsOpen,
+ toggle,
+ };
+
+ return (
+ <SidePanelContext.Provider value={ctx}>
+ <Resize.Zone direction="horizontal" gutter={0}>
+ <SidePanelLayoutInner
+ sections={sections}
+ openIds={openIds}
+ setOpenIds={setOpenIds}
+ isOpen={isOpen}
+ >
+ {props.children}
+ </SidePanelLayoutInner>
+ </Resize.Zone>
+ </SidePanelContext.Provider>
+ );
+}
+
+function SidePanelLayoutInner(
+ props: ParentProps<{
+ sections: Accessor<SidePanelSectionEntry[]>;
+ openIds: Accessor<string[]>;
+ setOpenIds: (ids: string[]) => void;
+ isOpen: Accessor<boolean>;
+ }>
+) {
+ const resolved = children(() => props.children);
+ const zoneCtx = useContext(ResizeZoneContext);
+ if (!zoneCtx) {
+ throw new Error('SidePanelLayoutInner must be rendered inside Resize.Zone');
+ }
+
+ const isNarrow = createMemo(() => zoneCtx.size() < NARROW_THRESHOLD_PX);
+ const hasSections = createMemo(() => props.sections().length > 0);
+
+ // Panel should be hidden if: mobile, narrow, no sections, OR user toggled it closed
+ const shouldHide = createMemo(
+ () => isMobile() || isNarrow() || !hasSections() || !props.isOpen()
+ );
+
+ return (
+ <>
+ <Resize.Panel id="side-panel-main" minSize={MAIN_MIN_PX} index={0}>
+ {resolved()}
+ </Resize.Panel>
+ <Show when={!shouldHide()}>
+ <Resize.Panel
+ id="side-panel-side"
+ minSize={SIDE_MIN_PX}
+ maxSize={SIDE_MAX_PX}
+ index={1}
+ >
+ <SidePanelOutlet
+ sections={props.sections}
+ openIds={props.openIds}
+ setOpenIds={props.setOpenIds}
+ />
+ </Resize.Panel>
+ </Show>
+ </>
+ );
+}
+
+function SidePanelOutlet(props: {
+ sections: Accessor<SidePanelSectionEntry[]>;
+ openIds: Accessor<string[]>;
+ setOpenIds: (ids: string[]) => void;
+}) {
+ return (
+ <Scroll class="flex flex-col min-h-0">
+ <Accordion
+ multiple
+ collapsible
+ value={props.openIds()}
+ onChange={(value) => props.setOpenIds(value as string[])}
+ class="p-2 flex flex-col gap-2 min-h-0"
+ >
+ <For each={props.sections()}>{(section) => section.component()}</For>
+ </Accordion>
+ </Scroll>
+ );
+}
+
+/**
+ * A collapsible section that registers itself with the nearest SidePanel.Layout.
+ *
+ * The section component returns null in place; its children are rendered
+ * inside the side panel's Accordion. Children evaluate lazily when the
+ * panel renders the section, so they only mount when the panel is visible.
+ *
+ * Must be a descendant of `<SidePanel.Layout>`.
+ */
+function Section(
+ props: ParentProps<{
+ id: string;
+ title: string;
+ defaultOpen?: boolean;
+ }>
+) {
+ const ctx = useContext(SidePanelContext);
+ if (!ctx) {
+ throw new Error('<SidePanel.Section> must be inside <SidePanel.Layout>');
+ }
+
+ onMount(() => {
+ ctx.register({
+ id: props.id,
+ title: props.title,
+ defaultOpen: props.defaultOpen ?? false,
+ component: () => (
+ <Accordion.Item value={props.id}>
+ <Panel
+ depth={2}
+ style={{ height: 'auto' }}
+ class="rounded-lg shadow-md shadow-drop-shadow"
+ >
+ <Accordion.Header class="group">
+ <Accordion.Trigger class="px-2 py-3 flex w-full items-center gap-2 text-sm hover:underline">
+ <span>{props.title}</span>
+ <CaretRight class="size-2.5 text-ink-extra-muted transition-transform duration-90 group-data-expanded:rotate-90" />
+ </Accordion.Trigger>
+ </Accordion.Header>
+ <Accordion.Content class="group/content overflow-hidden data-expanded:animate-accordion-down data-closed:animate-accordion-up">
+ <Suspense fallback={<div class="h-4" />}>
+ <div class="px-2 pb-3 text-sm opacity-0 group-data-expanded/content:opacity-100 transition-opacity duration-150 ease-out">
+ {props.children}
+ </div>
+ </Suspense>
+ </Accordion.Content>
+ </Panel>
+ </Accordion.Item>
+ ),
+ });
+ onCleanup(() => ctx.unregister(props.id));
+ });
+ return null;
+}
+
+/** Hook to access the SidePanel context for toggling visibility */
+function useSidePanel() {
+ const ctx = useContext(SidePanelContext);
+ if (!ctx) {
+ return null;
+ }
+ return {
+ isOpen: ctx.isOpen,
+ setIsOpen: ctx.setIsOpen,
+ toggle: ctx.toggle,
+ };
+}
+
+/** Indicates whether the current subtree has a SidePanel.Layout ancestor. */
+function useHasSidePanel(): boolean {
+ return useContext(SidePanelContext) !== undefined;
+}
+
+/**
+ * A simple flex row for side panel content.
+ * Children are rendered on the left, label on the right.
+ */
+function Row(props: ParentProps<{ label: JSX.Element }>) {
+ return (
+ <div class="flex flex-row items-center gap-2 text-xs">
+ {props.children}
+ <span class="text-ink-muted">{props.label}</span>
+ </div>
+ );
+}
+
+export const SidePanel = { Layout, Section, Row };
+export { useHasSidePanel, useSidePanel };
diff --git a/js/app/packages/app/component/side-panel/context.ts b/js/app/packages/app/component/side-panel/context.ts
new file mode 100644
index 0000000000..c2f6afe45a
--- /dev/null
+++ b/js/app/packages/app/component/side-panel/context.ts
@@ -0,0 +1,22 @@
+import { type Accessor, createContext, type JSX, type Setter } from 'solid-js';
+
+export type SidePanelSectionEntry = {
+ id: string;
+ title: string;
+ defaultOpen: boolean;
+ component: () => JSX.Element;
+};
+
+export type SidePanelContextType = {
+ register: (entry: SidePanelSectionEntry) => void;
+ unregister: (id: string) => void;
+ sections: Accessor<SidePanelSectionEntry[]>;
+ /** Whether the side panel is open (user-toggled state) */
+ isOpen: Accessor<boolean>;
+ /** Set the open state of the side panel */
+ setIsOpen: Setter<boolean>;
+ /** Toggle the side panel open/closed */
+ toggle: () => void;
+};
+
+export const SidePanelContext = createContext<SidePanelContextType>();
diff --git a/js/app/packages/app/component/side-panel/index.ts b/js/app/packages/app/component/side-panel/index.ts
new file mode 100644
index 0000000000..8308bb09f4
--- /dev/null
+++ b/js/app/packages/app/component/side-panel/index.ts
@@ -0,0 +1,5 @@
+export type {
+ SidePanelContextType,
+ SidePanelSectionEntry,
+} from './context';
+export { SidePanel, useHasSidePanel, useSidePanel } from './SidePanel';
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.css
index 4f4ab4ffb2..7e92e0a20f 100644
--- a/js/app/packages/app/index.css
+++ b/js/app/packages/app/index.css
@@ -116,7 +116,6 @@
--color-ink: var(--c0);
--color-ink-muted: var(--c1);
- --color-default: var(--c1); /* wtf? */
--color-ink-extra-muted: var(--c2);
--color-ink-disabled: var(--c3);
--color-ink-placeholder: var(--c4);
@@ -152,7 +151,8 @@
--color-task: oklch(from var(--a0) l c 150deg);
--color-pdf: oklch(from var(--a0) l c 25deg);
--color-rss: oklch(from var(--a0) l c 260deg);
- --color-email: var(--theme-email); /* wtf? */
+ --color-default: var(--c1);
+ --color-email: var(--color-default);
/* SCUFFED We probably want to let the theme determine 3 or 4 "extra" hue offsets. Rights now these are only being */
/* used as debug colors and to improve the consistency of markdown block lightness/chroma with themed css */
diff --git a/js/app/packages/block-md/component/Block.tsx b/js/app/packages/block-md/component/Block.tsx
index 002b7d8d30..6d7e162f7f 100644
--- a/js/app/packages/block-md/component/Block.tsx
+++ b/js/app/packages/block-md/component/Block.tsx
@@ -1,15 +1,26 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { useBlockEntityCommands } from '@app/component/next-soup/actions';
+import { SidePanel } from '@app/component/side-panel';
import { useBlockId } from '@core/block';
-import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { ENABLE_MARKDOWN_SIDE_PANEL } from '@core/constant/featureFlags';
+import { useCanEdit } from '@core/signal/permissions';
+import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { DocumentDebouncedNotificationReadMarker } from '@notifications';
import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';
-import { createEffect, createSignal, Show, Suspense } from 'solid-js';
+import { Scroll } from '@ui';
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ Show,
+ Suspense,
+} from 'solid-js';
import { mdStore } from '../signal/markdownBlockData';
import { FindAndReplace } from './FindAndReplace';
import { ModalsProvider } from './ModalsProvider';
import { InstructionsNotebook, Notebook } from './Notebook';
+import { MarkdownSidePanelSections } from './sidepanel/MarkdownSidePanelSections';
import { InstructionsTopBar, TopBar } from './TopBar';
export default function BlockMarkdown() {
@@ -18,9 +29,9 @@ export default function BlockMarkdown() {
const blockId = useBlockId();
const instructionsMdId = useInstructionsMdIdQuery();
const notificationSource = useGlobalNotificationSource();
- const isInstructionsMd = () => {
- return blockId === instructionsMdId.data;
- };
+ const canEdit = useCanEdit();
+ const documentName = useBlockDocumentName();
+ const isInstructionsMd = createMemo(() => blockId === instructionsMdId.data);
createEffect(() => {
const el = scrollRef();
@@ -36,44 +47,53 @@ export default function BlockMarkdown() {
tabIndex={-1}
>
<ModalsProvider>
- <div class="relative">
- <Suspense>
- <Show
- when={!isInstructionsMd()}
- fallback={<InstructionsTopBar />}
+ <SidePanel.Layout>
+ <Show when={ENABLE_MARKDOWN_SIDE_PANEL && !isInstructionsMd()}>
+ <MarkdownSidePanelSections
+ canEdit={canEdit()}
+ documentName={documentName()}
+ />
+ </Show>
+ <div class="flex flex-col size-full">
+ <div class="relative shrink-0">
+ <Suspense>
+ <Show
+ when={!isInstructionsMd()}
+ fallback={<InstructionsTopBar />}
+ >
+ <TopBar />
+ </Show>
+ </Suspense>
+ {/* off until - https://linear.app/macro-eng/issue/M-5203/markdown-unloads-completely-after-find */}
+ <Suspense>
+ <Show when={!isInstructionsMd() && false}>
+ <div class="absolute right-4 bottom-[-12] translate-y-full z-action-menu flex justify-end">
+ <FindAndReplace />
+ </div>
+ </Show>
+ </Suspense>
+ </div>
+ <DocumentDebouncedNotificationReadMarker
+ notificationSource={notificationSource}
+ documentId={blockId}
+ />
+ <div
+ class="w-full grow overflow-hidden relative"
+ data-block-content
>
- <TopBar />
- </Show>
- </Suspense>
- {/* off until - https://linear.app/macro-eng/issue/M-5203/markdown-unloads-completely-after-find */}
- <Suspense>
- <Show when={!isInstructionsMd() && false}>
- <div class="absolute right-4 bottom-[-12] translate-y-full z-action-menu flex justify-end">
- <FindAndReplace />
- </div>
- </Show>
- </Suspense>
- </div>
- <DocumentDebouncedNotificationReadMarker
- notificationSource={notificationSource}
- documentId={blockId}
- />
- <div class="w-full grow overflow-hidden relative" data-block-content>
- <div
- class="size-full relative overflow-auto portal-scope scrollbar-hidden"
- ref={setScrollRef}
- >
- <Suspense>
- <Show
- when={!isInstructionsMd()}
- fallback={<InstructionsNotebook />}
- >
- <Notebook />
- </Show>
- </Suspense>
+ <Scroll class="relative portal-scope" ref={setScrollRef}>
+ <Suspense>
+ <Show
+ when={!isInstructionsMd()}
+ fallback={<InstructionsNotebook />}
+ >
+ <Notebook />
+ </Show>
+ </Suspense>
+ </Scroll>
+ </div>
</div>
- <CustomScrollbar scrollContainer={scrollRef} />
- </div>
+ </SidePanel.Layout>
</ModalsProvider>
</div>
</DocumentBlockContainer>
diff --git a/js/app/packages/block-md/component/MarkdownEditor.tsx b/js/app/packages/block-md/component/MarkdownEditor.tsx
index 1b121b294c..a0f46fcdc1 100644
--- a/js/app/packages/block-md/component/MarkdownEditor.tsx
+++ b/js/app/packages/block-md/component/MarkdownEditor.tsx
@@ -32,7 +32,6 @@ import TableActionMenu, {
import { DraggableBlockMenu } from '@core/component/LexicalMarkdown/component/misc/DraggableBlockMenu';
import { DragInsertIndicator } from '@core/component/LexicalMarkdown/component/misc/DragInsertIndicator';
import { TableCellResizer } from '@core/component/LexicalMarkdown/component/misc/TableCellResizer';
-import { Wordcount } from '@core/component/LexicalMarkdown/component/status/Wordcount';
import {
getErrorDescription,
MarkdownEditorErrors,
@@ -112,7 +111,6 @@ import {
getDragDropPosition,
} from '@core/component/LexicalMarkdown/utils/fileUploadUtils';
import { useUrlParams } from '@core/component/ParamsProvider';
-import { ScopedPortal } from '@core/component/ScopedPortal';
import { toast } from '@core/component/Toast/Toast';
import { itemToBlockName } from '@core/constant/allBlocks';
import {
@@ -906,6 +904,7 @@ export function MarkdownEditor(props: { autoFocusOnMount?: boolean } = {}) {
plugins.use(
wordcountPlugin({ setStore: setWordcountStats, debounceTime: 200 })
);
+ setMdStore('wordcountStats', wordcountStats);
return (
<LexicalWrapperContext.Provider value={lexicalWrapper}>
@@ -1043,35 +1042,6 @@ export function MarkdownEditor(props: { autoFocusOnMount?: boolean } = {}) {
<CommentsProvider activeComment={activeCommentIdParam} />
</Show>
- <ScopedPortal scope="block">
- <Show when={!isBlankMarkdown() && !isMobile()}>
- <div class="absolute bottom-2 left-2 size-fit">
- <Wordcount stats={wordcountStats} />
- </div>
- </Show>
- {/* <Show
- when={
- isBlankMarkdown() &&
- titleIsEmpty() &&
- !isMobileWidth() &&
- isContentEditable()
- }
- >
- <div
- class="absolute bottom-0 left-0 right-0 flex justify-center items-end
- p-4 w-full overflow-auto"
- >
- <div class="w-full max-w-sm sm:max-w-md lg:max-w-3xl">
- <TemplateSelector
- titleEditor={md.titleEditor}
- editor={editor}
- editorContainerRef={editorContainerRef}
- />
- </div>
- </div>
- </Show> */}
- </ScopedPortal>
-
<Show when={canEdit()}>
<TableCellResizer />
<TableActionMenu anchorElem={editorContainerRef} cellMerge={true} />
diff --git a/js/app/packages/block-md/component/Notebook.tsx b/js/app/packages/block-md/component/Notebook.tsx
index e4d83d101e..3d838cf194 100644
--- a/js/app/packages/block-md/component/Notebook.tsx
+++ b/js/app/packages/block-md/component/Notebook.tsx
@@ -21,7 +21,6 @@ import {
blockHotkeyScopeSignal,
} from '@core/signal/blockElement';
import { tempRedirectLocation } from '@core/signal/location';
-import { useCanEdit } from '@core/signal/permissions';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { makeResizeObserver } from '@solid-primitives/resize-observer';
import {
@@ -33,7 +32,6 @@ import {
Show,
untrack,
} from 'solid-js';
-import { FrontMatterProperties } from './FrontMatterProperties';
import { InstructionsEditor } from './InstructionsEditor';
import { MarkdownEditor } from './MarkdownEditor';
import { TaskDiscussion } from './TaskDiscussion';
@@ -73,7 +71,6 @@ export function Notebook() {
const blockElement = blockElementSignal.get;
const setStore = mdStore.set;
const setWideEnoughForComments = commentWidthSignal.set;
- const canEdit = useCanEdit();
const documentName = useBlockDocumentName();
const scopeId = blockHotkeyScopeSignal.get;
const isTask = useBlockAliasedName() === 'task';
@@ -284,11 +281,7 @@ export function Notebook() {
<div class={containerClasses()} ref={notebookRef}>
<div class={contentDivClasses()} ref={contentRef}>
<TitleEditor autoFocusOnMount={!navigatedFromJK()} />
- <FrontMatterProperties
- canEdit={canEdit()}
- documentName={documentName()}
- fallback={<div class="h-6 w-full" />}
- />
+ <div class="spacer h-6" />
<ParamsProvider>
<MarkdownEditor autoFocusOnMount={!navigatedFromJK()} />
<Show when={ENABLE_RAIL_CHAT_TASK_COMMENTS && isTask}>
diff --git a/js/app/packages/block-md/component/TopBar.tsx b/js/app/packages/block-md/component/TopBar.tsx
index 4a218f8de6..19314a4114 100644
--- a/js/app/packages/block-md/component/TopBar.tsx
+++ b/js/app/packages/block-md/component/TopBar.tsx
@@ -11,6 +11,7 @@ import {
ResponsivePermissionsBadge,
ToolButton,
} from '@app/component/ResponsiveBlockToolbar';
+import { useSidePanel } from '@app/component/side-panel';
import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import {
@@ -47,6 +48,7 @@ import {
import {
ENABLE_HISTORY_COMPONENT,
ENABLE_MARKDOWN_LIVE_COLLABORATION,
+ ENABLE_MARKDOWN_SIDE_PANEL,
ENABLE_REFERENCES_MODAL,
} from '@core/constant/featureFlags';
import { registerHotkey } from '@core/hotkey/hotkeys';
@@ -58,6 +60,7 @@ import type { EntityType } from '@core/types';
import { copyBranchNameToClipboard } from '@core/util/branchName';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { buildSimpleEntityUrl } from '@core/util/url';
+import SidePanelIcon from '@icon/fill/square-half-fill.svg';
import Bell from '@icon/regular/bell.svg';
import ShowComments from '@icon/regular/chat-circle-dots.svg';
import HideComments from '@icon/regular/chat-circle-slash.svg';
@@ -71,6 +74,7 @@ import TagIcon from '@icon/regular/tag.svg';
import TerminalWindowIcon from '@icon/regular/terminal-window.svg';
import IconShared from '@macro-icons/wide/share.svg';
import { blockNameToItemType } from '@service-storage/client';
+import { Button, cn } from '@ui';
import { createEffect, For, type JSX, on, Show } from 'solid-js';
import { DispatchAgentButton } from './DispatchAgentMenu';
import { HISTORY_DRAWER_ID } from './History';
@@ -161,6 +165,8 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
+ const sidePanel = useSidePanel();
+
const tools: BlockTool[] = [
{
label: 'History',
@@ -273,6 +279,36 @@ export function TopBar() {
action: copyLink,
condition: isMobile,
},
+ {
+ label: () =>
+ sidePanel?.isOpen() ? 'Hide Side Panel' : 'Show Side Panel',
+ icon: SidePanelIcon,
+ action: () => sidePanel?.toggle(),
+ isActive: () => sidePanel?.isOpen() ?? false,
+ condition: () => ENABLE_MARKDOWN_SIDE_PANEL && !isMobile(),
+ buttonComponent: () => (
+ <Show when={sidePanel}>
+ {(panel) => (
+ <Button
+ depth={2}
+ variant="base"
+ size="icon-sm"
+ class={cn('bg-surface order-20', {
+ 'bg-active': sidePanel?.isOpen(),
+ })}
+ tooltip={
+ sidePanel?.isOpen() ? 'Hide Side Panel' : 'Show Side Panel'
+ }
+ onClick={() => {
+ panel().toggle();
+ }}
+ >
+ <SidePanelIcon />
+ </Button>
+ )}
+ </Show>
+ ),
+ },
];
return (
@@ -286,6 +322,7 @@ export function TopBar() {
<BlockLiveIndicators />
</div>
</SplitHeaderRight>
+
<ResponsivePermissionsBadge />
<ResponsiveBlockToolbar
diff --git a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
new file mode 100644
index 0000000000..133a2ac394
--- /dev/null
+++ b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -0,0 +1,556 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import { SidePanel } from '@app/component/side-panel';
+import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
+import { Wordcount } from '@core/component/LexicalMarkdown/component/status/Wordcount';
+import {
+ $getPinnedProperties,
+ ADD_PINNED_PROPERTY_COMMAND,
+ REMOVE_PINNED_PROPERTY_COMMAND,
+} from '@core/component/LexicalMarkdown/plugins';
+import { Notifications } from '@core/component/Notifications';
+import { Modals } from '@core/component/Properties/component/modal';
+import { PanelContainer } from '@core/component/Properties/component/panel';
+import { getDefaultPinnedProperties } from '@core/component/Properties/constants';
+import {
+ PropertiesProvider,
+ type PropertySaveHandler,
+ usePropertiesContext,
+} from '@core/component/Properties/context/PropertiesContext';
+import { useEntityProperties } from '@core/component/Properties/hooks';
+import type {
+ Property,
+ PropertyApiValues,
+} from '@core/component/Properties/types';
+import { References } from '@core/component/References';
+import { UserIcon } from '@core/component/UserIcon';
+import type { Entity, EntityType } from '@core/types';
+import { tryMacroId, useDisplayName } from '@core/user';
+import { type DateValue, formatDate } from '@core/util/date';
+import { isErr } from '@core/util/maybeResult';
+import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
+import Plus from '@icon/regular/plus.svg';
+import LoadingSpinner from '@icon/regular/spinner.svg';
+import { useNotificationsForEntity } from '@notifications';
+import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
+import { useDocumentMetadataQuery } from '@queries/storage/document-metadata';
+import { commsServiceClient } from '@service-comms/client';
+import type { EntityType as PropertiesEntityType } from '@service-properties/generated/schemas/entityType';
+import { blockNameToItemType } from '@service-storage/client';
+import { createCallback } from '@solid-primitives/rootless';
+import {
+ createEffect,
+ createMemo,
+ createResource,
+ createSignal,
+ For,
+ onCleanup,
+ Show,
+ Suspense,
+} from 'solid-js';
+import { mdStore } from '../../signal/markdownBlockData';
+
+interface MarkdownSidePanelSectionsProps {
+ canEdit: boolean;
+ documentName: string;
+}
+
+/**
+ * Renders all three SidePanel sections for the markdown block:
+ * - Properties (always shown)
+ * - Details (always shown)
+ * - Stats (hidden for tasks)
+ */
+export function MarkdownSidePanelSections(
+ props: MarkdownSidePanelSectionsProps
+) {
+ const blockName = useBlockAliasedName();
+ const rawBlockName = useBlockName();
+ const blockId = useBlockId();
+ const isTask = () => blockName === 'task';
+
+ const itemType = blockNameToItemType(rawBlockName);
+ const entity = (): Entity => ({ id: blockId, type: itemType as EntityType });
+
+ return (
+ <>
+ <SidePanel.Section id="details" title="Details" defaultOpen>
+ <DetailsSectionContent />
+ </SidePanel.Section>
+ <SidePanel.Section id="properties" title="Properties" defaultOpen>
+ <PropertiesSectionContent
+ canEdit={props.canEdit}
+ documentName={props.documentName}
+ />
+ </SidePanel.Section>
+ <Show when={!isTask()}>
+ <SidePanel.Section id="stats" title="Stats">
+ <StatsSectionContent />
+ </SidePanel.Section>
+ </Show>
+ <NotificationsSectionConditional entity={entity()} />
+ <ReferencesSectionConditional documentId={blockId} />
+ <SidePanel.Section id="debug" title="Debug (Scroll Test)">
+ <DebugSectionContent />
+ </SidePanel.Section>
+ </>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Details Section
+// ─────────────────────────────────────────────────────────────────────────────
+
+function DetailsSectionContent() {
+ const blockId = useBlockId();
+ const query = useDocumentMetadataQuery(() => blockId);
+ const metadata = createMemo(() => query.data);
+
+ return (
+ <Suspense fallback={<DetailsLoading />}>
+ <DetailsGrid
+ owner={() => metadata()?.owner}
+ folder={() => {
+ const id = metadata()?.projectId;
+ const name = metadata()?.projectName;
+ return id && name ? { id, name } : undefined;
+ }}
+ createdAt={() => metadata()?.createdAt}
+ updatedAt={() => metadata()?.updatedAt}
+ />
+ </Suspense>
+ );
+}
+
+function DetailsLoading() {
+ return (
+ <div class="flex justify-center items-center py-8">
+ <div class="animate-spin rounded-full h-6 w-6 border-b-2 border-ink-muted" />
+ </div>
+ );
+}
+
+function DetailsGrid(props: {
+ owner: () => string | undefined;
+ folder: () => { id: string; name: string } | undefined;
+ createdAt: () => DateValue | null | undefined;
+ updatedAt: () => DateValue | null | undefined;
+}) {
+ return (
+ <div class="grid grid-cols-[auto_1fr] gap-x-2 gap-y-2 items-center text-sm">
+ <Show when={props.owner()}>
+ {(ownerId) => (
+ <DetailsRow label="Owner">
+ <OwnerValue ownerId={ownerId()} />
+ </DetailsRow>
+ )}
+ </Show>
+ <Show when={props.folder()}>
+ {(folder) => (
+ <DetailsRow label="Folder">
+ <FolderLink projectId={folder().id} projectName={folder().name} />
+ </DetailsRow>
+ )}
+ </Show>
+ <Show when={props.createdAt()}>
+ {(created) => (
+ <DetailsRow label="Created">
+ <span>{formatDate(created(), { showTime: true })}</span>
+ </DetailsRow>
+ )}
+ </Show>
+ <Show when={props.updatedAt()}>
+ {(updated) => (
+ <DetailsRow label="Last updated">
+ <span>{formatDate(updated(), { showTime: true })}</span>
+ </DetailsRow>
+ )}
+ </Show>
+ </div>
+ );
+}
+
+function DetailsRow(props: {
+ label: string;
+ children: import('solid-js').JSX.Element;
+}) {
+ return (
+ <>
+ <span class="text-ink-muted">{props.label}</span>
+ <div class="flex items-center gap-2 min-w-0">{props.children}</div>
+ </>
+ );
+}
+
+function FolderLink(props: { projectId: string; projectName: string }) {
+ const open = createCallback((e: MouseEvent) => {
+ openDocument('project', props.projectId, undefined, !e.shiftKey);
+ });
+ const navHandlers = useSplitNavigationHandler<HTMLSpanElement>(open);
+ return (
+ <span
+ {...navHandlers}
+ class="pointer-events-auto min-w-0 truncate py-0.5 rounded-xs hover:bg-hover focus:bg-active"
+ >
+ <span class="relative top-[0.125em] size-[1em] inline-flex mx-1">
+ <EntityIcon targetType="project" size="fill" />
+ </span>
+ <span class="underline decoration-current/20 decoration-[max(1px,0.1em)] underline-offset-2">
+ {props.projectName}
+ </span>
+ </span>
+ );
+}
+
+function OwnerValue(props: { ownerId: string }) {
+ const [displayName] = useDisplayName(tryMacroId(props.ownerId));
+ return (
+ <div class="rounded-full flex gap-1 items-center px-1 ring ring-edge-muted">
+ <div class="flex">
+ <UserIcon id={props.ownerId} size="sm" showTooltip suppressClick />
+ </div>
+ <span class="truncate">{displayName()}</span>
+ </div>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Properties Section
+// ─────────────────────────────────────────────────────────────────────────────
+
+function PropertiesSectionContent(props: {
+ canEdit: boolean;
+ documentName: string;
+}) {
+ const blockId = useBlockId();
+ const mdData = mdStore.get;
+
+ const blockName = useBlockAliasedName();
+ const entityType: PropertiesEntityType =
+ blockName === 'task' ? 'TASK' : 'DOCUMENT';
+
+ const { properties, isLoading, error, refetch } = useEntityProperties(
+ blockId,
+ entityType,
+ false
+ );
+
+ const [pinnedPropertyIds, setPinnedPropertyIds] = createSignal<string[]>([]);
+
+ createEffect(() => {
+ const currentEditor = mdData.editor;
+ if (!currentEditor) return;
+ currentEditor.getEditorState().read(() => {
+ const ids = $getPinnedProperties();
+ setPinnedPropertyIds(ids);
+ });
+
+ const unregister = currentEditor.registerUpdateListener(
+ ({ editorState }) => {
+ editorState.read(() => {
+ const ids = $getPinnedProperties();
+ setPinnedPropertyIds(ids);
+ });
+ }
+ );
+ onCleanup(unregister);
+ });
+
+ const docMetadataQuery = useDocumentMetadataQuery(() => blockId);
+ const createdByProperty = createMemo<Property | null>(() => {
+ if (entityType !== 'TASK') return null;
+ const ownerId = docMetadataQuery.data?.owner;
+ if (!ownerId) return null;
+ const now = new Date();
+ return {
+ propertyId: `${blockId}-created-by`,
+ propertyDefinitionId: 'ffffffff-ffff-ffff-ffff-ffffffffffff',
+ displayName: 'Created By',
+ isMultiSelect: false,
+ isMetadata: true,
+ owner: { scope: 'system' },
+ specificEntityType: 'USER',
+ createdAt: now,
+ updatedAt: now,
+ valueType: 'ENTITY',
+ value: [{ entity_id: ownerId, entity_type: 'USER' }],
+ };
+ });
+
+ const filteredPinnedProperties = createMemo(() => {
+ const allProps = properties();
+ const pinnedIds = pinnedPropertyIds();
+ const defaultPinnedIds = getDefaultPinnedProperties(blockName);
+
+ const pinned = allProps.filter(
+ (prop) =>
+ !prop.isMetadata &&
+ (defaultPinnedIds.includes(prop.propertyDefinitionId) ||
+ pinnedIds.includes(prop.propertyId))
+ );
+
+ const createdBy = createdByProperty();
+ return createdBy ? [createdBy, ...pinned] : pinned;
+ });
+
+ const [pendingPinDefIds, setPendingPinDefIds] = createSignal<Set<string>>(
+ new Set()
+ );
+
+ const handlePropertyAdded = async (addedDefinitionIds?: string[]) => {
+ if (addedDefinitionIds && addedDefinitionIds.length > 0) {
+ setPendingPinDefIds((prev) => {
+ const next = new Set(prev);
+ for (const id of addedDefinitionIds) next.add(id);
+ return next;
+ });
+ }
+ refetch();
+ };
+
+ const handlePropertyDeleted = async () => {
+ refetch();
+ };
+
+ const handlePropertyPinned = (propertyId: string) => {
+ const editor = mdData.editor;
+ if (editor) {
+ editor.dispatchCommand(ADD_PINNED_PROPERTY_COMMAND, propertyId);
+ }
+ };
+
+ const handlePropertyUnpinned = (propertyId: string) => {
+ const editor = mdData.editor;
+ if (editor) {
+ editor.dispatchCommand(REMOVE_PINNED_PROPERTY_COMMAND, propertyId);
+ }
+ };
+
+ createEffect(() => {
+ const pending = pendingPinDefIds();
+ if (pending.size === 0) return;
+ const current = properties();
+ const remaining = new Set(pending);
+ for (const defId of pending) {
+ const instance = current.find((p) => p.propertyDefinitionId === defId);
+ if (instance) {
+ handlePropertyPinned(instance.propertyId);
+ remaining.delete(defId);
+ }
+ }
+ if (remaining.size !== pending.size) {
+ setPendingPinDefIds(remaining);
+ }
+ });
+
+ const saveMutation = useBulkSaveEntityPropertiesMutation();
+
+ const saveOne = (property: Property, apiValues: PropertyApiValues) =>
+ saveMutation.mutateAsync({
+ properties: [
+ { entityId: blockId, entityType: entityType, property, apiValues },
+ ],
+ });
+
+ const saveHandler: PropertySaveHandler = {
+ saveProperty: (property, value) => saveOne(property, value),
+ saveDate: (property, date) =>
+ saveOne(property, { valueType: 'DATE', value: date }),
+ };
+
+ return (
+ <Show
+ when={!error()}
+ fallback={
+ <div class="text-failure-ink text-center py-4 text-xs">{error()}</div>
+ }
+ >
+ <Suspense>
+ <PropertiesProvider
+ entityType={entityType}
+ canEdit={props.canEdit}
+ documentName={props.documentName}
+ properties={filteredPinnedProperties}
+ onRefresh={refetch}
+ onPropertyAdded={handlePropertyAdded}
+ onPropertyDeleted={handlePropertyDeleted}
+ onPropertyPinned={handlePropertyPinned}
+ onPropertyUnpinned={handlePropertyUnpinned}
+ pinnedPropertyIds={pinnedPropertyIds}
+ saveHandler={saveHandler}
+ >
+ <Show when={isLoading()}>
+ <div class="flex items-center justify-center py-8">
+ <div class="w-5 h-5 animate-spin">
+ <LoadingSpinner />
+ </div>
+ </div>
+ </Show>
+
+ <Show when={filteredPinnedProperties().length > 0}>
+ <PanelContainer
+ properties={filteredPinnedProperties}
+ isLoading={isLoading}
+ error={error}
+ />
+ </Show>
+
+ <Show when={props.canEdit}>
+ <div class="py-2">
+ <AddPinnedPropertyButton />
+ </div>
+ </Show>
+ <Modals />
+ </PropertiesProvider>
+ </Suspense>
+ </Show>
+ );
+}
+
+function AddPinnedPropertyButton() {
+ const { openPropertySelector } = usePropertiesContext();
+ return (
+ <button
+ class="flex items-center gap-1 opacity-75 hover:opacity-50 transition-opacity"
+ onClick={openPropertySelector}
+ >
+ <Plus class="w-3 h-3 mr-2" />
+ <span class="text-ink-muted">Add property</span>
+ </button>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Stats Section
+// ─────────────────────────────────────────────────────────────────────────────
+
+function StatsSectionContent() {
+ const md = mdStore.get;
+
+ return (
+ <Show
+ when={md.wordcountStats}
+ fallback={
+ <div class="text-ink-muted text-xs py-2">No stats available</div>
+ }
+ >
+ {(stats) => (
+ <Wordcount.Root stats={stats()}>
+ <div class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-3 items-center text-sm">
+ <span class="text-xs text-ink-muted">Words</span>
+ <div class="flex items-center gap-2 min-w-0">
+ <Wordcount.Words />
+ </div>
+
+ <span class="text-xs text-ink-muted">Characters</span>
+ <div class="flex items-center gap-2 min-w-0">
+ <Wordcount.Characters />
+ </div>
+ </div>
+ </Wordcount.Root>
+ )}
+ </Show>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Notifications Section (conditional)
+// ─────────────────────────────────────────────────────────────────────────────
+
+function NotificationsSectionConditional(props: { entity: Entity }) {
+ const notificationSource = useGlobalNotificationSource();
+ const notifications = useNotificationsForEntity(
+ notificationSource,
+ props.entity
+ );
+ const count = createMemo(() => notifications().length);
+ const unreadCount = createMemo(
+ () => notifications().filter((n) => !n.viewed_at).length
+ );
+
+ const title = createMemo(() => {
+ const unread = unreadCount();
+ return unread > 0 ? `Notifications (${unread})` : 'Notifications';
+ });
+
+ return (
+ <Show when={count() > 0}>
+ <SidePanel.Section id="notifications" title={title()}>
+ <Suspense
+ fallback={
+ <div class="flex justify-center py-8">
+ <div class="animate-spin rounded-full size-6 border-b-2 border-ink-muted" />
+ </div>
+ }
+ >
+ <Notifications
+ entity={props.entity}
+ notificationSource={notificationSource}
+ />
+ </Suspense>
+ </SidePanel.Section>
+ </Show>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// References Section (conditional)
+// ─────────────────────────────────────────────────────────────────────────────
+
+function ReferencesSectionConditional(props: { documentId: string }) {
+ const [references] = createResource(
+ () => props.documentId,
+ async (id) => {
+ const response = await commsServiceClient.attachmentReferences({
+ entity_type: 'document',
+ entity_id: id,
+ });
+
+ if (isErr(response)) {
+ console.error(response);
+ return [];
+ }
+
+ return response[1].references;
+ }
+ );
+
+ const count = createMemo(() => references()?.length ?? 0);
+
+ const title = createMemo(() => {
+ const c = count();
+ return c > 0 ? `References (${c})` : 'References';
+ });
+
+ return (
+ <Show when={count() > 0}>
+ <SidePanel.Section id="references" title={title()}>
+ <Suspense
+ fallback={
+ <div class="flex justify-center py-8">
+ <div class="animate-spin rounded-full size-6 border-b-2 border-ink-muted" />
+ </div>
+ }
+ >
+ <References documentId={props.documentId} />
+ </Suspense>
+ </SidePanel.Section>
+ </Show>
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Debug Section (for scroll testing)
+// ─────────────────────────────────────────────────────────────────────────────
+
+function DebugSectionContent() {
+ const items = Array.from({ length: 50 }, (_, i) => i + 1);
+ return (
+ <div class="flex flex-col gap-2 text-xs text-ink-muted">
+ <For each={items}>
+ {(i) => <div class="p-2 bg-surface-muted rounded">Debug item {i}</div>}
+ </For>
+ </div>
+ );
+}
diff --git a/js/app/packages/block-md/signal/markdownBlockData.ts b/js/app/packages/block-md/signal/markdownBlockData.ts
index 61edd3697e..bff2a71d04 100644
--- a/js/app/packages/block-md/signal/markdownBlockData.ts
+++ b/js/app/packages/block-md/signal/markdownBlockData.ts
@@ -2,6 +2,7 @@ import { blockDataSignalAs, createBlockStore } from '@core/block';
import type {
PluginManager,
SelectionData,
+ WordcountStats,
} from '@core/component/LexicalMarkdown/plugins';
import { createCallback } from '@solid-primitives/rootless';
import type { LexicalEditor } from 'lexical';
@@ -26,6 +27,7 @@ export type MdData = {
titleEditor?: LexicalEditor;
plugins?: PluginManager;
selection?: Store<SelectionData>;
+ wordcountStats?: Store<WordcountStats>;
notebook?: HTMLElement;
scrollContainer?: HTMLElement;
commentMargin?: HTMLElement;
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/status/Wordcount.tsx b/js/app/packages/core/component/LexicalMarkdown/component/status/Wordcount.tsx
index 76bbbbfe35..75cb2e4f1a 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/status/Wordcount.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/status/Wordcount.tsx
@@ -1,91 +1,132 @@
-import CaretUp from '@icon/regular/caret-up.svg';
-import Stats from '@icon/regular/chart-bar.svg';
-import { Button, HoverCard } from '@ui';
-import { createSignal, Show } from 'solid-js';
+import {
+ createContext,
+ type JSX,
+ type ParentProps,
+ Show,
+ useContext,
+} from 'solid-js';
import type { Store } from 'solid-js/store';
import type { WordcountStats } from '../../plugins';
-export function Wordcount(props: { stats: Store<WordcountStats> }) {
- const [isExpanded, setIsExpanded] = createSignal(false);
+type WordcountContextValue = {
+ stats: Store<WordcountStats>;
+};
- const simpleWordCount = () => {
- if (props.stats.selectedWords === null) return props.stats.totalWords;
- return props.stats.selectedWords;
- };
+const WordcountContext = createContext<WordcountContextValue>();
- const Words = () => {
- if (props.stats.selectedWords === null)
- return <span>{props.stats.totalWords.toLocaleString()}</span>;
- return (
- <>
- <span>{props.stats.selectedWords.toLocaleString()}</span>
- <span class="opacity-50">
- {' '}
- / {props.stats.totalWords.toLocaleString()}
- </span>
- </>
+function useWordcountContext(): WordcountContextValue {
+ const ctx = useContext(WordcountContext);
+ if (!ctx) {
+ throw new Error(
+ 'Wordcount compound components must be used within <Wordcount.Root>'
);
- };
- const Chars = () => {
- if (props.stats.selectedCharacters === null)
- return <span>{props.stats.totalCharacters.toLocaleString()}</span>;
- return (
- <>
- <span>{props.stats.selectedCharacters.toLocaleString()}</span>
- <span class="opacity-50">
- {' '}
- / {props.stats.totalCharacters.toLocaleString()}
- </span>
- </>
- );
- };
-
- const toggleExpanded = () => {
- setIsExpanded(!isExpanded());
- };
-
- const Details = () => (
- <div class="w-64 text-sm">
- <div class="flex justify-between mb-1">
- <span>Words</span>
- <span>{Words()}</span>
- </div>
- <div class="flex justify-between">
- <span>Characters</span>
- <span>{Chars()}</span>
- </div>
- </div>
+ }
+ return ctx;
+}
+
+function Root(props: ParentProps<{ stats: Store<WordcountStats> }>) {
+ return (
+ <WordcountContext.Provider value={{ stats: props.stats }}>
+ {props.children}
+ </WordcountContext.Provider>
);
+}
+
+/**
+ * Renders the word count, showing selected/total when text is selected.
+ */
+function Words(props: { class?: string }): JSX.Element {
+ const { stats } = useWordcountContext();
return (
- <div class="relative flex w-fit gap-1 items-center p-1">
- <Button
- variant="ghost"
- size="icon-md"
- label="Wordcount"
- onClick={toggleExpanded}
+ <span class={props.class}>
+ <Show
+ when={stats.selectedWords !== null}
+ fallback={<span>{stats.totalWords.toLocaleString()}</span>}
>
- <Stats class=" size-5 opacity-50" />
- </Button>
-
- <Show when={isExpanded()}>
- <HoverCard placement="top-start">
- <HoverCard.Trigger>
- <div class="text-sm text-ink-extra-muted flex w-32 justify-between h-7 rounded items-center hover:bg-hover hover-transition-bg p-1">
- <span>
- <span class="font-semibold">
- {simpleWordCount().toLocaleString()}
- </span>{' '}
- {simpleWordCount() === 1 ? 'word' : 'words'}
- </span>
- <CaretUp class="text-ink-extra-muted size-3" />
- </div>
- </HoverCard.Trigger>
- <HoverCard.Content>
- <Details />
- </HoverCard.Content>
- </HoverCard>
+ <span>{stats.selectedWords?.toLocaleString()}</span>
+ <span class="opacity-50"> / {stats.totalWords.toLocaleString()}</span>
</Show>
- </div>
+ </span>
);
}
+
+/**
+ * Renders the character count, showing selected/total when text is selected.
+ */
+function Characters(props: { class?: string }): JSX.Element {
+ const { stats } = useWordcountContext();
+
+ return (
+ <span class={props.class}>
+ <Show
+ when={stats.selectedCharacters !== null}
+ fallback={<span>{stats.totalCharacters.toLocaleString()}</span>}
+ >
+ <span>{stats.selectedCharacters?.toLocaleString()}</span>
+ <span class="opacity-50">
+ {' '}
+ / {stats.totalCharacters.toLocaleString()}
+ </span>
+ </Show>
+ </span>
+ );
+}
+
+/**
+ * Simple word count value (selected if available, otherwise total).
+ */
+function SimpleWordCount(props: { class?: string }): JSX.Element {
+ const { stats } = useWordcountContext();
+ const count = () =>
+ stats.selectedWords !== null ? stats.selectedWords : stats.totalWords;
+
+ return <span class={props.class}>{count().toLocaleString()}</span>;
+}
+
+/**
+ * Renders "word" or "words" based on count (for labels).
+ */
+function WordLabel(): JSX.Element {
+ const { stats } = useWordcountContext();
+ const count = () =>
+ stats.selectedWords !== null ? stats.selectedWords : stats.totalWords;
+
+ return <>{count() === 1 ? 'word' : 'words'}</>;
+}
+
+/**
+ * Simple character count value (selected if available, otherwise total).
+ */
+function SimpleCharacterCount(props: { class?: string }): JSX.Element {
+ const { stats } = useWordcountContext();
+ const count = () =>
+ stats.selectedCharacters !== null
+ ? stats.selectedCharacters
+ : stats.totalCharacters;
+
+ return <span class={props.class}>{count().toLocaleString()}</span>;
+}
+
+/**
+ * Renders "character" or "characters" based on count (for labels).
+ */
+function CharacterLabel(): JSX.Element {
+ const { stats } = useWordcountContext();
+ const count = () =>
+ stats.selectedCharacters !== null
+ ? stats.selectedCharacters
+ : stats.totalCharacters;
+
+ return <>{count() === 1 ? 'character' : 'characters'}</>;
+}
+
+export const Wordcount = {
+ Root,
+ Words,
+ Characters,
+ SimpleWordCount,
+ WordLabel,
+ SimpleCharacterCount,
+ CharacterLabel,
+};
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index 17aeba4a22..e944f444be 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -344,3 +344,8 @@ export const ENABLE_AUTO_UPDATE_UI = resolveFeatureFlag(
);
export const ENABLE_CALLKIT = resolveFeatureFlag('ENABLE_CALLKIT', false);
+
+export const ENABLE_MARKDOWN_SIDE_PANEL = resolveFeatureFlag(
+ 'ENABLE_MARKDOWN_SIDE_PANEL',
+ false
+);
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsx
index 8ce1c4f974..7ce6dc252b 100644
--- a/js/app/packages/entity/src/composed/ListEntity.tsx
+++ b/js/app/packages/entity/src/composed/ListEntity.tsx
@@ -186,12 +186,10 @@ export function ListEntity(props: ListEntityProps) {
'soup-list-entity @container/entity w-full relative group/narrow flex flex-col',
{
'min-h-10': !isMobile(),
- 'bg-accent/8': props.checked,
+ 'bg-accent/8': props.checked || (props.highlighted && !isMobile()),
'hover:bg-hover group-data-expanded/cm-trigger:bg-hover':
!props.checked && !props.highlighted && !props.hovered,
'bg-hover': props.hovered && !props.highlighted && !props.checked,
- 'bg-accent/8 outline-1 outline-accent/20 -outline-offset-1':
- props.highlighted && !isMobile(),
}
)}
onMouseMove={props.onMouseMove}
diff --git a/js/app/packages/theme/constants.ts b/js/app/packages/theme/constants.ts
index 8475906f4f..864517993a 100644
--- a/js/app/packages/theme/constants.ts
+++ b/js/app/packages/theme/constants.ts
@@ -63,7 +63,7 @@ export const DEFAULT_THEMES = [
a4: { l: 0.65, c: 0.20, h: 219 },
b0: { l: 0.96, c: 0.00, h: 59 },
b1: { l: 0.92, c: 0.00, h: 59 },
- b2: { l: 0.89, c: 0.00, h: 59 },
+ b2: { l: 0.91, c: 0.00, h: 59 },
b3: { l: 0.93, c: 0.00, h: 59 },
b4: { l: 0.85, c: 0.00, h: 59 },
c0: { l: 0.14, c: 0.00, h: 59 },
@@ -77,7 +77,7 @@ export const DEFAULT_THEMES = [
id: 'Macro Dark',
name: 'Macro Dark',
version: 2,
- depth: 0.15,
+ depth: 0.35,
tokens: {
a0: { l: 0.75, c: 0.20, h: 59 },
a1: { l: 0.75, c: 0.20, h: 99 },
diff --git a/js/app/packages/ui/components/Layer.tsx b/js/app/packages/ui/components/Layer.tsx
index 84435f08a0..40bfde02e4 100644
--- a/js/app/packages/ui/components/Layer.tsx
+++ b/js/app/packages/ui/components/Layer.tsx
@@ -42,7 +42,7 @@ export function Layer(props: LayerProps) {
'--color-ink-muted': 'var(--c1)',
'--color-ink-extra-muted': 'var(--c2)',
'--color-ink-disabled': 'var(--c3)',
- '--color-ink-placeholder': 'var(--c4)',
+ '--color-ink-placeholder': 'oklch(var(--c4) / 0.5))',
}}
>
{props.children}