@@ -282,6 +282,9 @@ import { |
282 | 282 | import { SidebarContent, SidebarGroup, useSidebar } from "./ui/sidebar"; |
283 | 283 | import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome"; |
284 | 284 | import { SidebarHeaderIconButton, SidebarThreadHeader } from "./sidebar/SidebarThreadHeader"; |
| 285 | +import { SidebarOwnerFilterMenu, SidebarOwnerFilterNotice } from "./sidebar/SidebarOwnerFilter"; |
| 286 | +import { filterSidebarThreadsByOwner } from "./sidebar/ownerFilter.logic"; |
| 287 | +import { useSidebarOwnerFilter } from "./sidebar/useSidebarOwnerFilter"; |
285 | 288 | import { Menu, MenuItem, MenuPopup, MenuSeparator, MenuShortcut, MenuTrigger } from "./ui/menu"; |
286 | 289 | import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "./ui/tooltip"; |
287 | 290 | import { MiddleTruncate } from "./ui/middle-truncate"; |
@@ -2582,6 +2585,18 @@ export default function Sidebar() { |
2582 | 2585 | ); |
2583 | 2586 | const projectGroupsRef = useRef(projectGroups); |
2584 | 2587 | projectGroupsRef.current = projectGroups; |
| 2588 | + // Fork: the owner filter shows only or hides the projects of the selected repository owners. |
| 2589 | + // The project scope offers only the projects that it shows. |
| 2590 | + const { |
| 2591 | + repositoryOwnerFiltersEnabled, |
| 2592 | + savedOwnerFilter, |
| 2593 | + ownerFilter, |
| 2594 | + ownerOptions, |
| 2595 | + ownerVisibleProjectKeys, |
| 2596 | + visibleProjectGroups, |
| 2597 | + ownerHiddenProjectCount, |
| 2598 | + setOwnerFilter, |
| 2599 | + } = useSidebarOwnerFilter({ unsortedProjectGroups, projectGroups, projectGroupingSettings }); |
2585 | 2600 | // Threads on non-primary environments (T3 Connect, hosted) resolve their |
2586 | 2601 | // provider entry from their own environment's config: default instance ids |
2587 | 2602 | // are driver slugs, so a flat map would collide across environments. |
@@ -2628,26 +2643,28 @@ export default function Sidebar() { |
2628 | 2643 | // app restarts keep it. |
2629 | 2644 | const persistedProjectScopeKey = useUiStateStore((store) => store.sidebarProjectScopeKey); |
2630 | 2645 | const setProjectScopeKey = useUiStateStore((store) => store.setSidebarProjectScopeKey); |
| 2646 | + // Fork: a scope that the owner filter hides finds no group here, so the list shows every |
| 2647 | + // visible project. An owner change that hides the scope also clears it (`setOwnerFilter`). |
2631 | 2648 | const projectScopeKey = useMemo( |
2632 | 2649 | () => |
2633 | 2650 | resolveSidebarProjectScopeKey({ |
2634 | | - groups: projectGroups, |
| 2651 | + groups: visibleProjectGroups, |
2635 | 2652 | key: persistedProjectScopeKey, |
2636 | 2653 | settings: projectGroupingSettings, |
2637 | 2654 | }), |
2638 | | - [persistedProjectScopeKey, projectGroups, projectGroupingSettings], |
| 2655 | + [persistedProjectScopeKey, visibleProjectGroups, projectGroupingSettings], |
2639 | 2656 | ); |
2640 | 2657 | // {value, label} items let Base UI drive the combobox selection contract |
2641 | 2658 | // while the popup search filters the same collection. |
2642 | 2659 | const projectScopeItems = useMemo( |
2643 | 2660 | () => [ |
2644 | 2661 | { value: "all", label: "All projects" }, |
2645 | | - ...projectGroups.map((project) => ({ |
| 2662 | + ...visibleProjectGroups.map((project) => ({ |
2646 | 2663 | value: project.projectKey, |
2647 | 2664 | label: project.displayName, |
2648 | 2665 | })), |
2649 | 2666 | ], |
2650 | | - [projectGroups], |
| 2667 | + [visibleProjectGroups], |
2651 | 2668 | ); |
2652 | 2669 | // Same-named projects on two machines are only told apart by where they |
2653 | 2670 | // live, so rows on another machine carry its icon once the catalog spans |
@@ -2705,8 +2722,8 @@ export default function Sidebar() { |
2705 | 2722 | () => |
2706 | 2723 | projectScopeKey === null |
2707 | 2724 | ? null |
2708 | | - : (projectGroups.find((project) => project.projectKey === projectScopeKey) ?? null), |
2709 | | - [projectGroups, projectScopeKey], |
| 2725 | + : (visibleProjectGroups.find((project) => project.projectKey === projectScopeKey) ?? null), |
| 2726 | + [visibleProjectGroups, projectScopeKey], |
2710 | 2727 | ); |
2711 | 2728 | const scopedProjectKeys = useMemo( |
2712 | 2729 | () => |
@@ -2719,6 +2736,8 @@ export default function Sidebar() { |
2719 | 2736 | ), |
2720 | 2737 | [scopedProjectGroup], |
2721 | 2738 | ); |
| 2739 | + // The scope lies inside the owner filter, so the scope wins when both are set. |
| 2740 | + const draftProjectKeys = scopedProjectKeys ?? ownerVisibleProjectKeys; |
2722 | 2741 | // Configs identify scratch projects, so both they and live project snapshots |
2723 | 2742 | // must arrive before a persisted scope can be considered missing. |
2724 | 2743 | const allProjectSnapshotsReady = useAllEnvironmentProjectSnapshotsReady(); |
@@ -2758,8 +2777,8 @@ export default function Sidebar() { |
2758 | 2777 | continue; |
2759 | 2778 | } |
2760 | 2779 | if ( |
2761 | | - scopedProjectKeys !== null && |
2762 | | - !scopedProjectKeys.has(`${session.environmentId}:${session.projectId}`) |
| 2780 | + draftProjectKeys !== null && |
| 2781 | + !draftProjectKeys.has(`${session.environmentId}:${session.projectId}`) |
2763 | 2782 | ) { |
2764 | 2783 | continue; |
2765 | 2784 | } |
@@ -2771,7 +2790,7 @@ export default function Sidebar() { |
2771 | 2790 | // hidden now, and bulk actions must never count or touch invisible rows. |
2772 | 2791 | useEffect(() => { |
2773 | 2792 | clearSelection(); |
2774 | | - }, [clearSelection, projectScopeKey]); |
| 2793 | + }, [clearSelection, ownerFilter, projectScopeKey]); |
2775 | 2794 |
|
2776 | 2795 | const openProjectSettings = useCallback( |
2777 | 2796 | (projectGroup: SidebarProjectSnapshot, projectRef?: ScopedProjectRef) => { |
@@ -2847,7 +2866,10 @@ export default function Sidebar() { |
2847 | 2866 | const preciseNow = new Date().toISOString(); |
2848 | 2867 | // Subagent child threads live in the parent's Agents surface, not the |
2849 | 2868 | // sidebar roster (v2 models them as real threads with lineage). |
2850 | | - const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys); |
| 2869 | + const visible = filterSidebarV2VisibleThreads( |
| 2870 | + filterSidebarThreadsByOwner(threads, ownerVisibleProjectKeys), |
| 2871 | + scopedProjectKeys, |
| 2872 | + ); |
2851 | 2873 | inboxReturns.observe(workingShelfEnabled ? threads : null); |
2852 | 2874 | const pinned: EnvironmentThreadShell[] = []; |
2853 | 2875 | const active: EnvironmentThreadShell[] = []; |
@@ -2950,6 +2972,7 @@ export default function Sidebar() { |
2950 | 2972 | }, [ |
2951 | 2973 | nowMinute, |
2952 | 2974 | optimisticDrop, |
| 2975 | + ownerVisibleProjectKeys, |
2953 | 2976 | scopedProjectKeys, |
2954 | 2977 | serverConfigs, |
2955 | 2978 | snoozeWakeTick, |
@@ -3026,7 +3049,10 @@ export default function Sidebar() { |
3026 | 3049 | // filter context changes so a scope/search flip never inherits a deep |
3027 | 3050 | // page state. |
3028 | 3051 | const [settledVisibleCount, setSettledVisibleCount] = useState(SETTLED_TAIL_INITIAL_COUNT); |
3029 | | - const settledResetKey = projectScopeKey ?? "all"; |
| 3052 | + const settledResetKey = JSON.stringify([ |
| 3053 | + projectScopeKey, |
| 3054 | + ownerFilter ? [ownerFilter.operator, [...ownerFilter.owners]] : null, |
| 3055 | + ]); |
3030 | 3056 | const lastSettledResetKeyRef = useRef(settledResetKey); |
3031 | 3057 | if (lastSettledResetKeyRef.current !== settledResetKey) { |
3032 | 3058 | lastSettledResetKeyRef.current = settledResetKey; |
@@ -4689,12 +4715,17 @@ export default function Sidebar() { |
4689 | 4715 | AuthOrchestrationOperateScope, |
4690 | 4716 | ), |
4691 | 4717 | branch: thread.branch ?? null, |
4692 | | - projectFilter: threadProjectGroup |
4693 | | - ? { |
4694 | | - label: threadProjectGroup.displayName, |
4695 | | - isActive: projectScopeKey === threadProjectGroup.projectKey, |
4696 | | - } |
4697 | | - : null, |
| 4718 | + // A thread can show while the owner filter hides its project (it runs or waits |
| 4719 | + // for the user). Scoping to that project would show nothing, so the item stays out. |
| 4720 | + projectFilter: |
| 4721 | + threadProjectGroup && |
| 4722 | + (ownerVisibleProjectKeys === null || |
| 4723 | + ownerVisibleProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)) |
| 4724 | + ? { |
| 4725 | + label: threadProjectGroup.displayName, |
| 4726 | + isActive: projectScopeKey === threadProjectGroup.projectKey, |
| 4727 | + } |
| 4728 | + : null, |
4698 | 4729 | isPinned, |
4699 | 4730 | isSettled, |
4700 | 4731 | autoSettleEnabled: thread.autoSettleDisabledAt == null, |
@@ -4921,6 +4952,7 @@ export default function Sidebar() { |
4921 | 4952 | handleMultiSelectContextMenu, |
4922 | 4953 | markThreadUnread, |
4923 | 4954 | openProjectSettings, |
| 4955 | + ownerVisibleProjectKeys, |
4924 | 4956 | projectScopeKey, |
4925 | 4957 | projectByKey, |
4926 | 4958 | serverConfigs, |
@@ -5062,6 +5094,15 @@ export default function Sidebar() { |
5062 | 5094 | <SidebarThreadHeader |
5063 | 5095 | searchFieldRef={headerSearchRef} |
5064 | 5096 | hasProjects={projectGroups.length > 0} |
| 5097 | + ownerFilter={ |
| 5098 | + repositoryOwnerFiltersEnabled ? ( |
| 5099 | + <SidebarOwnerFilterMenu |
| 5100 | + options={ownerOptions} |
| 5101 | + filter={savedOwnerFilter} |
| 5102 | + onChange={setOwnerFilter} |
| 5103 | + /> |
| 5104 | + ) : null |
| 5105 | + } |
5065 | 5106 | projectScope={ |
5066 | 5107 | <Combobox |
5067 | 5108 | items={projectScopeItems} |
@@ -5212,6 +5253,13 @@ export default function Sidebar() { |
5212 | 5253 | activeSearchResultIndex={activeSearchResultIndex} |
5213 | 5254 | onClearSearch={clearThreadSearch} |
5214 | 5255 | /> |
| 5256 | + {ownerFilter !== null ? ( |
| 5257 | + <SidebarOwnerFilterNotice |
| 5258 | + filter={savedOwnerFilter} |
| 5259 | + hiddenProjectCount={ownerHiddenProjectCount} |
| 5260 | + onChange={setOwnerFilter} |
| 5261 | + /> |
| 5262 | + ) : null} |
5215 | 5263 | </SidebarGroup> |
5216 | 5264 | } |
5217 | 5265 | > |
@@ -5472,7 +5520,7 @@ export default function Sidebar() { |
5472 | 5520 | key="draft-sessions" |
5473 | 5521 | projectByKey={projectByKey} |
5474 | 5522 | projectDisplayNameByKey={projectDisplayNameByKey} |
5475 | | - scopedProjectKeys={scopedProjectKeys} |
| 5523 | + scopedProjectKeys={draftProjectKeys} |
5476 | 5524 | routeDraftId={routeDraftIdForRows} |
5477 | 5525 | onNavigateToDraft={navigateToDraft} |
5478 | 5526 | onDraftContextMenu={handleDraftContextMenu} |
@@ -5644,6 +5692,10 @@ export default function Sidebar() { |
5644 | 5692 | </> |
5645 | 5693 | ) : scopedProjectGroup ? ( |
5646 | 5694 | `No threads in ${scopedProjectGroup.displayName} yet` |
| 5695 | + ) : ownerFilter?.operator === "is" ? ( |
| 5696 | + "No threads in the projects of these owners" |
| 5697 | + ) : ownerFilter?.operator === "is_not" ? ( |
| 5698 | + "No threads outside the hidden owners" |
5647 | 5699 | ) : ( |
5648 | 5700 | "No threads yet" |
5649 | 5701 | )} |
|