Skip to content

Commit 5be8e11

Browse files
Saves collapsed groups on launchpad between uses (#3303)
1 parent e4be139 commit 5be8e11

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/constants.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ export type GlobalStorage = {
934934
'views:welcome:visible': boolean;
935935
'confirm:draft:storage': boolean;
936936
'home:sections:collapsed': string[];
937+
'launchpad:groups:collapsed': StoredFocusGroup[];
937938
'launchpad:indicator:hasLoaded': boolean;
938939
'launchpad:indicator:hasInteracted': string;
939940
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean } & {
@@ -1152,6 +1153,18 @@ export type WalkthroughSteps =
11521153
| 'integrations'
11531154
| 'more';
11541155

1156+
export type StoredFocusGroup =
1157+
| 'current-branch'
1158+
| 'pinned'
1159+
| 'mergeable'
1160+
| 'blocked'
1161+
| 'follow-up'
1162+
| 'needs-review'
1163+
| 'waiting-for-review'
1164+
| 'draft'
1165+
| 'other'
1166+
| 'snoozed';
1167+
11551168
export type TelemetryGlobalContext = {
11561169
debugging: boolean;
11571170
enabled: boolean;

src/plus/focus/focus.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function assertsFocusStepState(state: StepState<State>): asserts state is FocusS
122122

123123
const instanceCounter = getScopedCounter();
124124

125+
const defaultCollapsedGroups: FocusGroup[] = ['draft', 'other', 'snoozed'];
126+
125127
@command()
126128
export class FocusCommand extends QuickCommand<State> {
127129
private readonly source: Source;
@@ -175,11 +177,14 @@ export class FocusCommand extends QuickCommand<State> {
175177
await this.container.git.isDiscoveringRepositories;
176178
}
177179

178-
const collapsed = new Map<FocusGroup, boolean>([
179-
['draft', true],
180-
['other', true],
181-
['snoozed', true],
182-
]);
180+
let storedCollapsed = this.container.storage.get('launchpad:groups:collapsed') satisfies
181+
| FocusGroup[]
182+
| undefined;
183+
if (storedCollapsed == null) {
184+
storedCollapsed = defaultCollapsedGroups;
185+
}
186+
187+
const collapsed = new Map<FocusGroup, boolean>(storedCollapsed.map(g => [g, true]));
183188
if (state.initialGroup != null) {
184189
// set all to true except the initial group
185190
for (const [group] of groupMap) {
@@ -342,6 +347,12 @@ export class FocusCommand extends QuickCommand<State> {
342347
onDidSelect: () => {
343348
const collapsed = !context.collapsed.get(ui);
344349
context.collapsed.set(ui, collapsed);
350+
if (state.initialGroup == null) {
351+
void this.container.storage.store(
352+
'launchpad:groups:collapsed',
353+
Array.from(context.collapsed.keys()).filter(g => context.collapsed.get(g)),
354+
);
355+
}
345356

346357
if (this.container.telemetry.enabled) {
347358
updateTelemetryContext(context);

0 commit comments

Comments
 (0)