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: search in placeholder text (#158)

gbirman02bed7c88d96
diff --git a/js/app/packages/app/component/HelpDrawer.tsx b/js/app/packages/app/component/HelpDrawer.tsx
index bbf9a24179..562d060802 100644
--- a/js/app/packages/app/component/HelpDrawer.tsx
+++ b/js/app/packages/app/component/HelpDrawer.tsx
@@ -5,7 +5,7 @@ import { fileSelector } from '@core/directive/fileSelector';
import { TOKENS } from '@core/hotkey/tokens';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { isMobileWidth } from '@core/mobile/mobileWidth';
-import type { View } from '@core/types/view';
+import type { ViewId } from '@core/types/view';
import CloseIcon from '@icon/regular/x.svg';
import { authServiceClient } from '@service-auth/client';
import { useTutorialCompleted } from '@service-gql/client';
@@ -15,12 +15,12 @@ import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
false && fileSelector;
-export function HelpDrawer(props: { view?: View }) {
+export function HelpDrawer(props: { viewId?: ViewId }) {
const emailActive = useEmailLinksStatus();
return (
<Switch>
- <Match when={props.view === 'emails' && !emailActive()}>
+ <Match when={props.viewId === 'emails' && !emailActive()}>
<HelpDrawerInner
title={'Macro is better with email.'}
subtitle={
@@ -46,7 +46,7 @@ export function HelpDrawer(props: { view?: View }) {
}}
/>
</Match>
- <Match when={props.view === 'emails' && emailActive()}>
+ <Match when={props.viewId === 'emails' && emailActive()}>
<HelpDrawerInner
title={'Email is better with Macro.'}
subtitle={
@@ -78,7 +78,7 @@ export function HelpDrawer(props: { view?: View }) {
]}
/>
</Match>
- <Match when={props.view === 'inbox'}>
+ <Match when={props.viewId === 'inbox'}>
<HelpDrawerInner
title={'Your unified inbox.'}
subtitle={
@@ -108,7 +108,7 @@ export function HelpDrawer(props: { view?: View }) {
}
/>
</Match>
- <Match when={props.view === 'comms'}>
+ <Match when={props.viewId === 'comms'}>
<HelpDrawerInner
title={'Message teammates.'}
subtitle={
@@ -129,7 +129,7 @@ export function HelpDrawer(props: { view?: View }) {
]}
/>
</Match>
- <Match when={props.view === 'docs'}>
+ <Match when={props.viewId === 'docs'}>
<HelpDrawerInner
title={'Documents. Interlinked.'}
subtitle={
@@ -150,7 +150,7 @@ export function HelpDrawer(props: { view?: View }) {
]}
/>
</Match>
- <Match when={props.view === 'ai'}>
+ <Match when={props.viewId === 'ai'}>
<HelpDrawerInner
title={'Ask AI anything.'}
subtitle={
@@ -177,7 +177,7 @@ export function HelpDrawer(props: { view?: View }) {
]}
/>
</Match>
- <Match when={props.view === 'folders'}>
+ <Match when={props.viewId === 'folders'}>
<HelpDrawerInner
title={'All your files, organized.'}
subtitle={
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsx
index 698f879062..6a6766f857 100644
--- a/js/app/packages/app/component/Soup.tsx
+++ b/js/app/packages/app/component/Soup.tsx
@@ -20,6 +20,7 @@ import {
VIEWS,
type View,
type ViewId,
+ type ViewLabel,
} from '@core/types/view';
import { handleFileFolderDrop } from '@core/util/upload';
import { ContextMenu } from '@kobalte/core/context-menu';
@@ -60,9 +61,8 @@ import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
import { UnifiedListView } from './UnifiedListView';
import {
VIEWCONFIG_BASE,
- VIEWCONFIG_DEFAULTS_NAMES,
+ VIEWCONFIG_DEFAULTS_IDS,
type ViewConfigBase,
- type ViewConfigDefaultsName,
} from './ViewConfig';
false && fileFolderDrop;
@@ -323,7 +323,7 @@ export function Soup() {
const TabContextMenu = (props: { value: ViewId; label: string }) => {
const [isModalOpen, setIsModalOpen] = createSignal(false);
const isDefaultView = () =>
- VIEWCONFIG_DEFAULTS_NAMES.includes(props.value as View);
+ VIEWCONFIG_DEFAULTS_IDS.includes(props.value as View);
return (
<Show when={!isDefaultView()}>
<ContextMenu>
@@ -451,7 +451,7 @@ export function Soup() {
</Show>
</div>
<Show when={showHelpDrawer().has(selectedView())}>
- <HelpDrawer view={view().view} />
+ <HelpDrawer viewId={view().id} />
</Show>
</div>
);
@@ -495,14 +495,14 @@ export const useUpsertSavedViewMutation = () => {
viewData:
| {
config: ViewConfigBase;
- id?: ViewConfigDefaultsName | string;
- name: string;
+ id?: ViewId;
+ name: ViewLabel;
}
| {
- id: ViewConfigDefaultsName | string;
+ id: ViewId;
}
) => {
- const isDefaultView = VIEWCONFIG_DEFAULTS_NAMES.includes(
+ const isDefaultView = VIEWCONFIG_DEFAULTS_IDS.includes(
viewData.id as View
);
if ('config' in viewData) {
diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsx
index a89280ab4b..76c28a6797 100644
--- a/js/app/packages/app/component/SoupContext.tsx
+++ b/js/app/packages/app/component/SoupContext.tsx
@@ -37,6 +37,7 @@ import type { SplitHandle } from './split-layout/layoutManager';
import {
VIEWCONFIG_BASE,
VIEWCONFIG_DEFAULTS,
+ VIEWCONFIG_DEFAULTS_IDS,
type ViewConfigBase,
type ViewConfigEnhanced,
type ViewData,
@@ -56,7 +57,9 @@ export type UnifiedListContext = {
setShowHelpDrawer: Setter<Set<string>>;
};
-const DEFAULT_VIEW_ID = 'all';
+const DEFAULT_VIEW_ID: View = 'all';
+
+const DEFAULT_VIEW_IDS_SET = new Set(VIEWCONFIG_DEFAULTS_IDS);
export function createSoupContext(): UnifiedListContext {
const [selectedView, setSelectedView] = createSignal<ViewId>(DEFAULT_VIEW_ID);
@@ -109,7 +112,7 @@ function createViewData(
): ViewData {
return {
id: (viewProps?.id || view) ?? '',
- view,
+ view: viewProps?.view ?? view,
filters: {
notificationFilter:
viewProps?.filters?.notificationFilter ??
@@ -662,12 +665,11 @@ const useAllViews = ({
// Filter viewsData to exclude items that are not in savedViewConfigs, except for default views
const savedViewIds = new Set(savedViewConfigs.map((view) => view.id));
- const defaultViewIds = new Set(Object.keys(VIEWCONFIG_DEFAULTS));
const filteredViewsData = Object.fromEntries(
Object.entries(viewsData).filter(
([viewId, viewData]) =>
savedViewIds.has(viewId) ||
- defaultViewIds.has(viewId) ||
+ DEFAULT_VIEW_IDS_SET.has(viewId as View) ||
viewData.viewType !== undefined
)
);
diff --git a/js/app/packages/app/component/UnifiedListEmptyState.tsx b/js/app/packages/app/component/UnifiedListEmptyState.tsx
index 832d1edc89..e818001888 100644
--- a/js/app/packages/app/component/UnifiedListEmptyState.tsx
+++ b/js/app/packages/app/component/UnifiedListEmptyState.tsx
@@ -5,7 +5,7 @@ import { fileSelector } from '@core/directive/fileSelector';
import { folderSelector } from '@core/directive/folderSelector';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { isMobileWidth } from '@core/mobile/mobileWidth';
-import type { View } from '@core/types/view';
+import type { ViewId } from '@core/types/view';
import { handleFolderSelect } from '@core/util/upload';
import { Match, onMount, Show, Switch } from 'solid-js';
import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
@@ -13,7 +13,7 @@ import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
false && fileSelector;
false && folderSelector;
-export function EmptyState(props: { view?: View }) {
+export function EmptyState(props: { viewId?: ViewId }) {
const emailActive = useEmailLinksStatus();
const splitPanelContext = useSplitPanelOrThrow();
const {
@@ -21,7 +21,7 @@ export function EmptyState(props: { view?: View }) {
} = splitPanelContext;
return (
<Switch>
- <Match when={props.view === 'emails' && !emailActive()}>
+ <Match when={props.viewId === 'emails' && !emailActive()}>
{(_) => {
onMount(() =>
setShowHelpDrawer((prev) => new Set([...prev, 'emails']))
@@ -31,12 +31,13 @@ export function EmptyState(props: { view?: View }) {
</Match>
<Match
when={
- (props.view === 'emails' || props.view === 'inbox') && emailActive()
+ (props.viewId === 'emails' || props.viewId === 'inbox') &&
+ emailActive()
}
>
<EmptyStateInner emptyMessage={'Inbox zero.'} />
</Match>
- <Match when={props.view === 'inbox' && !emailActive()}>
+ <Match when={props.viewId === 'inbox' && !emailActive()}>
{(_) => {
onMount(() =>
setShowHelpDrawer((prev) => new Set([...prev, 'inbox']))
@@ -48,7 +49,7 @@ export function EmptyState(props: { view?: View }) {
);
}}
</Match>
- <Match when={props.view === 'comms'}>
+ <Match when={props.viewId === 'comms'}>
{(_) => {
onMount(() =>
setShowHelpDrawer((prev) => new Set([...prev, 'comms']))
@@ -56,7 +57,7 @@ export function EmptyState(props: { view?: View }) {
return <EmptyStateInner emptyMessage={'No messages to show.'} />;
}}
</Match>
- <Match when={props.view === 'docs'}>
+ <Match when={props.viewId === 'docs'}>
{(_) => {
onMount(() =>
setShowHelpDrawer((prev) => new Set([...prev, 'docs']))
@@ -64,13 +65,13 @@ export function EmptyState(props: { view?: View }) {
return <EmptyStateInner showDropZone />;
}}
</Match>
- <Match when={props.view === 'ai'}>
+ <Match when={props.viewId === 'ai'}>
{(_) => {
onMount(() => setShowHelpDrawer((prev) => new Set([...prev, 'ai'])));
return <EmptyStateInner emptyMessage={'No AI chats to show.'} />;
}}
</Match>
- <Match when={props.view === 'folders'}>
+ <Match when={props.viewId === 'folders'}>
{(_) => {
onMount(() =>
setShowHelpDrawer((prev) => new Set([...prev, 'folders']))
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index 4e220e7d87..35b1b3284e 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -124,7 +124,7 @@ import {
KNOWN_FILE_TYPES,
type SortOptions,
VIEWCONFIG_BASE,
- VIEWCONFIG_DEFAULTS_NAMES,
+ VIEWCONFIG_DEFAULTS_IDS,
type ViewConfigBase,
type ViewData,
} from './ViewConfig';
@@ -906,7 +906,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
config,
});
// only for default views
- if (VIEWCONFIG_DEFAULTS_NAMES.includes(view_.id as any)) {
+ if (VIEWCONFIG_DEFAULTS_IDS.includes(view_.id as any)) {
// Reset initialConfigSignal to current config after save
const currentConfig = stringifiedCurrentViewConfigBase();
if (currentConfig !== null && currentConfig !== undefined) {
@@ -1183,7 +1183,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
<UnifiedListComponent
entityListRef={setLocalEntityListRef}
virtualizerHandle={setVirtualizerHandle}
- emptyState={<EmptyState view={view()?.view} />}
+ emptyState={<EmptyState viewId={view()?.id} />}
hasRefinementsFromBase={isViewConfigChanged}
>
{(innerProps) => {
@@ -1454,6 +1454,7 @@ function SearchBar(props: {
entityListRefSignal: [entityListRef],
} = splitContext.unifiedListContext;
const viewData = createMemo(() => viewsDataStore[selectedView()]);
+ const viewName = createMemo(() => viewData().view);
let inputRef: HTMLInputElement | undefined;
@@ -1569,7 +1570,7 @@ function SearchBar(props: {
<input
ref={inputRef}
id={`search-input-${selectedView()}`}
- placeholder="Search"
+ placeholder={`Search in ${viewName()}`}
value={searchText()}
onInput={(e) => {
debouncedSetSearch(e.target.value);
diff --git a/js/app/packages/app/component/ViewConfig.tsx b/js/app/packages/app/component/ViewConfig.tsx
index 9a419ffb2c..74c0386cc0 100644
--- a/js/app/packages/app/component/ViewConfig.tsx
+++ b/js/app/packages/app/component/ViewConfig.tsx
@@ -1,4 +1,9 @@
-import { VIEWS, type View, type ViewId } from '@core/types/view';
+import {
+ VIEWS,
+ type View,
+ type ViewId,
+ type ViewLabel,
+} from '@core/types/view';
import type { WithCustomUserInput } from '@core/user';
import type { DeepPartial } from '@core/util/withRequired';
import {
@@ -19,7 +24,7 @@ export type ViewType = 'project';
export type ViewData = {
id: ViewId;
- view: View;
+ view: ViewLabel;
viewType?: ViewType;
highlightedId: string | undefined;
selectedEntity: EntityData | undefined;
@@ -88,8 +93,8 @@ export type ViewConfigBase = {
};
export type ViewConfigEnhanced = {
- id: View | string;
- view: View;
+ id: ViewId;
+ view: ViewLabel;
searchText?: string;
hideToolbar?: true;
onLoadingChange?: (isLoading: boolean) => void;
@@ -141,7 +146,7 @@ export const PROJECT_VIEWCONFIG_BASE: ViewConfigBase = {
const ALL_VIEWCONFIG_DEFAULTS = {
inbox: {
- view: 'inbox',
+ view: 'Inbox',
filters: {
notificationFilter: 'notDone',
emailFilter: 'sent',
@@ -166,7 +171,7 @@ const ALL_VIEWCONFIG_DEFAULTS = {
},
},
emails: {
- view: 'emails',
+ view: 'Emails',
filters: {
typeFilter: ['email'],
},
@@ -201,7 +206,7 @@ const ALL_VIEWCONFIG_DEFAULTS = {
},
},
comms: {
- view: 'comms',
+ view: 'Comms',
filters: {
typeFilter: ['channel'],
},
@@ -210,25 +215,25 @@ const ALL_VIEWCONFIG_DEFAULTS = {
},
},
docs: {
- view: 'docs',
+ view: 'Docs',
filters: {
typeFilter: ['document'],
},
},
ai: {
- view: 'ai',
+ view: 'Ai',
filters: {
typeFilter: ['chat'],
},
},
folders: {
- view: 'folders',
+ view: 'Folders',
filters: {
typeFilter: ['project'],
},
},
all: {
- view: 'all',
+ view: 'All',
sort: {
sortBy: 'viewed_at',
},
@@ -249,18 +254,9 @@ export const VIEWCONFIG_DEFAULTS = Object.fromEntries(
)
) as Record<View, Omit<ViewConfigEnhanced, 'id'>>;
-export type ViewConfigDefaultsName = keyof typeof VIEWCONFIG_DEFAULTS;
-export const VIEWCONFIG_DEFAULTS_NAMES = Object.keys(
+export const VIEWCONFIG_DEFAULTS_IDS = Object.keys(
VIEWCONFIG_DEFAULTS
-) as ViewConfigDefaultsName[];
-
-export type NewViewData =
- | {
- config: ViewConfigEnhanced;
- id: ViewConfigDefaultsName;
- name: ViewConfigDefaultsName;
- }
- | { config: ViewConfigEnhanced; id: string; name: string };
+) as View[];
export const VIEWCONFIG_FILTER_SHOW_OPTIONS: readonly FilterOptions['notificationFilter'][] =
['all', 'unread', 'notDone'] as const;
diff --git a/js/app/packages/app/component/split-layout/components/SplitTabs.tsx b/js/app/packages/app/component/split-layout/components/SplitTabs.tsx
index 58d0cc9bbd..45a51d0f2f 100644
--- a/js/app/packages/app/component/split-layout/components/SplitTabs.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitTabs.tsx
@@ -13,7 +13,8 @@ import {
} from 'solid-js';
import { useSplitPanelOrThrow } from '../layoutUtils';
-const titleCase = (str: string) => {
+// NOTE: unused since everything should already be correctly cased
+const _titleCase = (str: string) => {
return str
.split('')
.map((c, i) => (i === 0 ? c.toUpperCase() : c.toLowerCase()))
@@ -141,7 +142,7 @@ export function SplitTabs(props: {
createEffect(() => {
if (isActive()) {
- panel.handle.setDisplayName(titleCase(label));
+ panel.handle.setDisplayName(label);
}
});
@@ -162,7 +163,7 @@ export function SplitTabs(props: {
<span class="text-xs font-mono opacity-70 mr-0.5">
{(i() + 1).toString()}
</span>
- <span class="truncate">{titleCase(label)}</span>
+ <span class="truncate">{label}</span>
</span>
{/* <Show when={isActive()}>
<BrightJoins dots={[true, true, true, true]} />
diff --git a/js/app/packages/block-project/component/Block.tsx b/js/app/packages/block-project/component/Block.tsx
index 18bf31c7b3..9260939223 100644
--- a/js/app/packages/block-project/component/Block.tsx
+++ b/js/app/packages/block-project/component/Block.tsx
@@ -86,6 +86,7 @@ const Block: Component = () => {
setViewDataStore(projectId, {
...PROJECT_VIEWCONFIG_BASE,
id: projectId,
+ view: name() ?? 'folder',
filters: {
...PROJECT_VIEWCONFIG_BASE.filters,
projectFilter: projectId,
diff --git a/js/app/packages/core/types/view.ts b/js/app/packages/core/types/view.ts
index 44375363e2..aebe62c345 100644
--- a/js/app/packages/core/types/view.ts
+++ b/js/app/packages/core/types/view.ts
@@ -31,3 +31,6 @@ export const VIEWS = VIEW_DEFINITIONS.filter((v) => !v.disabled).map(
/** equal to View type for default view, otherwise a uuid type */
export type ViewId = View | string;
+
+/** equal to upper case View type for default view, otherwise a custom string label */
+export type ViewLabel = string;