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(soup-view): save group-by as history entry state (#3917)

gbirman7124c923f004
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 daa90baa0c..421cd7833b 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
@@ -909,10 +909,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
`macro:pref:soup:${contentId}:sort`,
{ default: [] }
);
- const [groupByPref, setGroupByPref] = usePreference<string | undefined>(
- `macro:pref:soup:${contentId}:groupBy`,
- { default: undefined }
- );
// Preview-pane open state is transient per history entry: captured into
// per-entry state on nav-away and restored on back/forward. Read
@@ -939,6 +935,20 @@ export const SoupViewList = (props: SoupViewListProps) => {
);
onCleanup(collapsedCaptorTeardown);
+ // Active grouping is per-entry state too, so back/forward restores the
+ // grouping the user left each entry with. `null` (vs. key absent) records
+ // an explicit "no grouping" choice, which would otherwise be
+ // indistinguishable from a fresh entry.
+ const persistedGroupBy = panel.handle.currentEntryState()?.['soup.groupBy'] as
+ | string
+ | null
+ | undefined;
+ const groupByCaptorTeardown = panel.handle.registerEntryStateCaptor(
+ 'soup.groupBy',
+ () => soup.grouping.activeGroupId() ?? null
+ );
+ onCleanup(groupByCaptorTeardown);
+
onMount(() => {
batch(() => {
const savedSort = sortPref();
@@ -950,8 +960,13 @@ export const SoupViewList = (props: SoupViewListProps) => {
}
// soup state is shared at the SplitPanel level, so a prior view in the
// same split (e.g. tasks) may have left grouping state behind. Always
- // reset to this view's saved or initial grouping, even when undefined.
- soup.grouping.setActiveGroupId(groupByPref() ?? props.initialGroupBy);
+ // reset to this entry's captured or initial grouping, even when
+ // undefined.
+ soup.grouping.setActiveGroupId(
+ persistedGroupBy !== undefined
+ ? (persistedGroupBy ?? undefined)
+ : props.initialGroupBy
+ );
soup.grouping.collapseAll(persistedCollapsedGroups ?? []);
// Apply view-supplied client filters only when per-entry state didn't
@@ -981,13 +996,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
{ defer: true }
)
);
- createEffect(
- on(
- () => soup.grouping.activeGroupId(),
- (id) => setGroupByPref(id),
- { defer: true }
- )
- );
onCleanup(() => {
if (isProjectList) return;