Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

fix(agents): draw the per-rep Files sections at the scope the agent page mounts at

merged#2934CedarCopilot

CedarCopilot wants to merge 1 commit into staging from fix/agent-files-team-sections

Customer behavior verdict

Libra exercised 2 changed behaviors; none regressed.

Who this touches

  • Leaders see teammate sections in an agent’s user-scoped Files tab: no production calls in the last 7 days.
  • Teammate sections preserve member identity and read-only access: Libra cannot measure who uses this yet; it has not mapped this to a production entry point yet; it will trace it through the import graph on a coming run.
  • Deal and named-person views do not request or render teammate sections: no production calls in the last 7 days.
  • Leaders see teammate sections in an agent’s user-scoped Files tab: Held on this PR; the scenario fails when this is broken on purpose.
  • Teammate sections preserve member identity and read-only access: Held on this PR; the scenario fails when this is broken on purpose.

What Libra verified

  • Leaders see teammate sections in an agent’s user-scoped Files tab

    Libra ran this behavior against the change and confirmed the check detects when it breaks.

    Technical evidence
    • the Files tab creates one teammate section for every server-returned member at the agent's user path
    • each teammate section is labeled and scoped to that member's userId and remains read-only

    Changed code: AgentOutputTab.tsx.

  • Teammate sections preserve member identity and read-only access

    Libra ran this behavior against the change and confirmed the check detects when it breaks.

    Technical evidence
    • each generated teammate section has a distinct key and test id for each member
    • each generated teammate section uses its member userId as the listing scope while sharing the agent user path
    • each generated teammate section remains read-only

    Changed code: team-sections.ts.

Live on prod, watching, 2 days leftTimeline and evidence
  1. Opened
    Sep 24, 2026, 2:33 PM
  2. Sep 24, 2026, 2:50 PM
  3. Merged
    Sep 24, 2026, 3:00 PM
  4. Live on prod
    Sep 24, 2026, 3:00 PM
  5. Observed 5 hours
    Sep 24, 2026, 3:00 PM
  6. Watching

    Live on prod, watching, 2 days left

    Sep 24, 2026, 3:00 PM
  7. Pipelines steady after this deploy
    Sep 24, 2026, 3:00 PM

Behaviors Libra is checking

The agent Files tab displays per-representative team sections when mounted at the viewer's user scope, while omitting them for deal folders, named-user listings, and view-as read-only perspectives.Not checked
prod

Libra has verdicts on 0 of 1 tracked behaviors on prod; 1 is still being checked. Libra checks hourly for 3 days after each deploy.

Summary

  • The per-rep sections from #2929 never drew. The Files tab only asked for teammates' folders when scope.type === 'org', but the agent page mounts at the user scope (AgentView passes no scope, so it defaults to user, and fileScope is just that). Sahand (Aspire) and Arie saw only their own user/agent-{id} files, with no rep folders.
  • The gate is now showsTeamSections: on for anything except a deal folder, off when a person is named (targetUserId) or a view-as perspective is active. The server still decides who gets a non-empty list (agent.getTeamMembers, org admin or agent manager), so a rep still sees nothing extra.

Test plan

  • New showsTeamSections cases in team-sections.test.ts (user scope on, undefined scope on, deal folder / named person / view-as off); 8 pass.
  • apps/mail typecheck shows no errors in the touched files (the remaining ./+types/* errors are pre-existing generated-route types).
  • Checked against production data before the change: listAgentTeamMembers returns 5 reps for Sahand, 6 for Arie and ak, 3 for Peter, and none for a rep.
  • Not covered: no rendered-DOM test of the tab (the tab needs tRPC and file-tree mocks); the gate is unit tested instead. This is the same gap noted in #2929, and it is the reason this bug shipped.

Verify in prod

  • Axiom (cedar-prod):
    ['cedar-prod'] | where _time > ago(1h) and message == "[agent] getTeamMembers"
    | project _time, caller_user_id, agent_id, via, member_count, truncated
    
  • Working: opening an org agent's Files tab as a leader now logs this line on every open (before, it never appeared), with member_count equal to the reps who own rows. Expanding a rep's section then issues the confined listing, which logs [files] manager teammate-scope read only for a non-admin manager.
  • Regression: this line appearing with via: none is not logged by design; a rep opening the tab should produce no extra section.

Customer: Aspire, Pirros

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The PR appears safe to merge, though a tab-level regression test would better protect the fix.

Findings

  1. P2 Tab wiring remains untested ▶
Fix with agent prompt
### Issue 1
apps/mail/modules/agents/__tests__/team-sections.test.ts:87-90
The new tests check the scope helper, but not whether `AgentOutputTab` requests team members and renders their sections at the user-scope mount. The previous regression was in that connection, so these tests would still pass if rep folders disappeared from the Files tab again. A component test covering that path would protect the fix.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR enables teammate file sections at the agent page’s user-scope mount, while keeping them off in deal and named-person views.

  • The query and section rendering now share the new scope gate.
  • The gate has unit tests, but the tab’s query-to-render path remains untested.
Show production surfaces and changed-file mapping

Production surfaces

Libra has not measured any production surfaces for this change yet.

Changed files → surfaces

  • apps/mail/modules/agents/__tests__/team-sections.test.tsno production surface mapped
  • apps/mail/modules/agents/components/AgentOutputTab.tsxno production surface mapped
  • apps/mail/modules/agents/utils/team-sections.tsno production surface mapped