🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(home): keep the personal daily-brief hint out of workspaces (#22576)
AmAzing-7f0f687ce7c9
diff --git a/apps/server/src/routers/lambda/home.ts b/apps/server/src/routers/lambda/home.tsindex 9897b88271b..4f1245433ab 100644--- a/apps/server/src/routers/lambda/home.ts+++ b/apps/server/src/routers/lambda/home.ts@@ -21,7 +21,7 @@ const homeProcedure = wsCompatProcedure.use(serverDatabase).use(async (opts) =>ctx: {agentModel: new AgentModel(ctx.serverDB, ctx.userId, workspaceId),homeRepository: new HomeRepository(ctx.serverDB, ctx.userId, workspaceId),- homeService: new HomeService(ctx.userId),+ homeService: new HomeService(ctx.userId, workspaceId),},});});diff --git a/apps/server/src/services/home/index.test.ts b/apps/server/src/services/home/index.test.tsnew file mode 100644index 00000000000..c1dd3a42bf0--- /dev/null+++ b/apps/server/src/services/home/index.test.ts@@ -0,0 +1,46 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++vi.mock('@/envs/redis', () => ({+ getRedisConfig: vi.fn().mockReturnValue({}),+}));++vi.mock('@/server/modules/Redis', () => ({+ getJSONFromRedis: vi.fn(),+ initializeRedisWithPrefix: vi.fn().mockResolvedValue({}),+ isRedisEnabled: vi.fn().mockReturnValue(true),+ RedisKeyNamespace: { AI_GENERATION: 'aiGeneration' },+ RedisKeys: { aiGeneration: { homeBrief: (userId: string) => `home_brief:${userId}` } },+}));++const { HomeService } = await import('./index');+const { getJSONFromRedis } = await import('@/server/modules/Redis');++const personalBrief = {+ pairs: [{ hint: 'Continue [pickleball paddles](/agent/agt_1/tpc_1)…', welcome: 'Hi' }],+};++describe('HomeService.getDailyBrief', () => {+ beforeEach(() => {+ vi.mocked(getJSONFromRedis).mockReset().mockResolvedValue(personalBrief);+ });++ it('returns the cached brief in personal scope', async () => {+ const service = new HomeService('user_1');++ await expect(service.getDailyBrief()).resolves.toEqual(personalBrief);+ expect(getJSONFromRedis).toHaveBeenCalledWith(expect.anything(), 'home_brief:user_1');+ });++ it('does not surface the personal brief inside a workspace', async () => {+ const service = new HomeService('user_1', 'ws_1');++ await expect(service.getDailyBrief()).resolves.toEqual({ pairs: [] });+ expect(getJSONFromRedis).not.toHaveBeenCalled();+ });++ it('returns empty pairs when the cached payload is malformed', async () => {+ vi.mocked(getJSONFromRedis).mockResolvedValue({ pairs: 'oops' });++ await expect(new HomeService('user_1').getDailyBrief()).resolves.toEqual({ pairs: [] });+ });+});diff --git a/apps/server/src/services/home/index.ts b/apps/server/src/services/home/index.tsindex e6434570cf4..819a9aef7df 100644--- a/apps/server/src/services/home/index.ts+++ b/apps/server/src/services/home/index.ts@@ -29,17 +29,26 @@ export interface HomeBriefData {*/export class HomeService {private readonly userId: string;+ private readonly workspaceId?: string;- constructor(userId: string) {+ constructor(userId: string, workspaceId?: string) {this.userId = userId;+ this.workspaceId = workspaceId;}/*** Read the cached daily brief for this user. Returns `{ pairs: [] }` when* Redis is disabled, the key is missing, or the payload is malformed —* callers can render unconditionally without a null check.+ *+ * The brief is generated from the user's personal-scope topics and tasks+ * only, so inside a workspace it would surface personal conversations (and+ * links to personal agents). Workspaces get no brief until one is generated+ * per workspace.*/async getDailyBrief(): Promise<HomeBriefData> {+ if (this.workspaceId) return { pairs: [] };+const data = await this.readDailyBriefFromRedis();return data ?? { pairs: [] };}