Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(types): keep the user's own workspace rail order in preference (#23073)

Arvin Xuc3502d27ad2d
diff --git a/packages/types/src/user/preference.test.ts b/packages/types/src/user/preference.test.ts
index c1b377acbd6..c898b905efc 100644
--- a/packages/types/src/user/preference.test.ts
+++ b/packages/types/src/user/preference.test.ts
@@ -17,4 +17,14 @@ describe('UserPreferenceSchema', () => {
expect(parsed).toMatchObject({ [key]: ['id-1', 'id-2'] });
},
);
+
+ // The rail order is replaced as a whole on every write, so it must survive intact.
+ it('preserves the workspace rail order instead of stripping it', () => {
+ const parsed = UserPreferenceSchema.parse({
+ telemetry: null,
+ workspace: { order: ['ws-2', 'ws-1'] },
+ });
+
+ expect(parsed).toMatchObject({ workspace: { order: ['ws-2', 'ws-1'] } });
+ });
});
diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.ts
index d0d7adb3f64..12dc00197b6 100644
--- a/packages/types/src/user/preference.ts
+++ b/packages/types/src/user/preference.ts
@@ -305,6 +305,21 @@ export const UserIntegrationPreferenceSchema = z.object({
github: GithubIntegrationPreferenceSchema.optional(),
});
+/**
+ * Per-user preferences across all of the user's workspaces — the user-level
+ * counterpart to {@link WorkspaceUserPreference}, which holds preferences inside
+ * one workspace. Workspaces are shared; how a user arranges them is not.
+ */
+export interface UserWorkspacePreference {
+ /**
+ * The user's own order of the workspace rail, as workspace ids. The personal
+ * space is pinned on top and never listed. Workspaces missing here (newly
+ * joined or created) follow in the server's order; ids of workspaces the user
+ * left are skipped on read and dropped on the next write.
+ */
+ order?: string[];
+}
+
export interface UserPreference {
/** Last-used app for "Open working directory in…" split button. Empty/unknown values fall back to platform default. */
defaultOpenInApp?: string;
@@ -389,6 +404,8 @@ export interface UserPreference {
* whether to use cmd + enter to send message
*/
useCmdEnterToSend?: boolean;
+ /** This user's own view over the workspaces they belong to. */
+ workspace?: UserWorkspacePreference;
}
export type ReferralStatusString =
@@ -458,5 +475,6 @@ export const UserPreferenceSchema = z
topicIncludeCompleted: z.boolean().optional(),
topicSortBy: z.enum(['createdAt', 'updatedAt']).optional(),
useCmdEnterToSend: z.boolean().optional(),
+ workspace: z.object({ order: z.array(z.string()).optional() }).optional(),
})
.partial();