mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 04:36:59 +01:00
fix(control): solo user's own projects were excluded from /control
getOrgProjects(userId) called getOrgPeerIds which intentionally excludes the caller (it answers "who *else* is in my orgs"). That left a solo user — or anyone in an org alone, like every new signup before they invite teammates — with peerIds=[] and getOrgProjects returning []. Symptom: /api/control returned trackedProjectCount=0 and an empty projects array on cockpitapp.vercel.app, even with 10 active user_projects rows for the logged-in user. The control panel rendered no cards, so the whole outcome-tracking + sleep-mode + dispatch loop we shipped over the last several sessions had no surface to render against. Fix: union memberIds = [userId, ...peerIds] before the inArray lookup. The peer-only semantics live in getOrgEntityProjects (entity layer, with a readonly:true marker) which is correctly distinct. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 file changed
+5
-2
@@ -19,12 +19,15 @@ export async function getUserProjects(userId: string): Promise<UserProject[]> {
|
||||
* regardless of whether projects have been explicitly org-tagged.
|
||||
*/
|
||||
export async function getOrgProjects(userId: string): Promise<UserProject[]> {
|
||||
// Include the caller themselves — getOrgPeerIds excludes self by design (it
|
||||
// answers "who else is in my orgs"), but the caller's own projects belong in
|
||||
// the visible set too. Without this, a solo user with no org peers gets [].
|
||||
const peerIds = await getOrgPeerIds(userId);
|
||||
if (peerIds.length === 0) return [];
|
||||
const memberIds = [userId, ...peerIds];
|
||||
return db
|
||||
.select()
|
||||
.from(userProjects)
|
||||
.where(and(inArray(userProjects.userId, peerIds), eq(userProjects.isActive, true)))
|
||||
.where(and(inArray(userProjects.userId, memberIds), eq(userProjects.isActive, true)))
|
||||
.orderBy(asc(userProjects.position), asc(userProjects.createdAt));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user