GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #46 from Yarden-zamir/feat/pr-owner-filter · TomCohenDev/t3code@05c2fbb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • apps/web/src
    • components
      • Sidebar.tsx
      • filters
        • FilterChip.tsx
      • pullRequest
        • PullRequestFilterChips.tsx
        • PullRequestListEmptyState.tsx
        • PullRequestListFilters.tsx
        • PullRequestOwnerSubmenu.tsx
        • pullRequestFilterChips.logic.test.ts
        • pullRequestFilterChips.logic.ts
        • pullRequestList.logic.ts
        • pullRequestListPreferences.ts
        • pullRequestOwnerFilter.logic.test.ts
        • pullRequestOwnerFilter.logic.ts
      • settings
        • PullRequestFilterChipsSettingsRow.tsx
        • RepositoryOwnerFiltersSettingsRow.tsx
        • SettingsPanels.tsx
        • settingsSearch.ts
      • sidebar
        • SidebarOwnerFilter.tsx
        • SidebarThreadHeader.tsx
        • ownerFilter.logic.test.ts
        • ownerFilter.logic.ts
        • useSidebarOwnerFilter.ts
    • routes
      • _chat.pull-requests.tsx
  • docs
    • fork.md
  • packages/contracts/src
    • environment.ts
    • settings.test.ts
    • settings.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ This is a personal fork of [pingdotgg/t3code](https://github.com/pingdotgg/t3cod
2929
- **Pull request watch remark filter:** select which comments and reviews wake an agent that watches a pull request, by author role, login and agent marker (`pullRequestWatchRemarkFilter`).
3030
- **Agent session import limits:** set the import window and the message limit for imported agent sessions (`agentSessionImportWindowDays`, `agentSessionImportMaxMessages`).
3131

32+
**Filters**
33+
34+
- **Repository owner filters:** filter the pull request page and the sidebar by the account or organization that owns each repository. Show only some owners, or hide them. Type `org:` or `-org:` in the pull request search (`repositoryOwnerFilters`).
35+
- **Pull request filter chips:** the active pull request filters show as chips above the list. Flip a chip between "is" and "is not", or remove it. An empty list names the filters that emptied it (`pullRequestFilterChips`).
36+
3237
**Scripts and terminal**
3338

3439
- **Global scripts:** scripts for every project and pinned script buttons. Global pins show in the title bar and next to the thread details toggle; project pins show only next to the toggle. Right-click opens the in-app pin menu. A global script's preview opens as a floating popup. An action with "Open as an app overlay" opens its page in a large panel over the app instead, and runs its command only when the page is down (`previewOverlay`). Scripts can run in the background (`globalScripts`, `pinnedGlobalScriptIds`, `pinnedProjectScriptIds`).
Collapse file

‎apps/web/src/components/Sidebar.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/Sidebar.tsx
+70-18Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ import {
282282
import { SidebarContent, SidebarGroup, useSidebar } from "./ui/sidebar";
283283
import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
284284
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";
285288
import { Menu, MenuItem, MenuPopup, MenuSeparator, MenuShortcut, MenuTrigger } from "./ui/menu";
286289
import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
287290
import { MiddleTruncate } from "./ui/middle-truncate";
@@ -2582,6 +2585,18 @@ export default function Sidebar() {
25822585
);
25832586
const projectGroupsRef = useRef(projectGroups);
25842587
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 });
25852600
// Threads on non-primary environments (T3 Connect, hosted) resolve their
25862601
// provider entry from their own environment's config: default instance ids
25872602
// are driver slugs, so a flat map would collide across environments.
@@ -2628,26 +2643,28 @@ export default function Sidebar() {
26282643
// app restarts keep it.
26292644
const persistedProjectScopeKey = useUiStateStore((store) => store.sidebarProjectScopeKey);
26302645
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`).
26312648
const projectScopeKey = useMemo(
26322649
() =>
26332650
resolveSidebarProjectScopeKey({
2634-
groups: projectGroups,
2651+
groups: visibleProjectGroups,
26352652
key: persistedProjectScopeKey,
26362653
settings: projectGroupingSettings,
26372654
}),
2638-
[persistedProjectScopeKey, projectGroups, projectGroupingSettings],
2655+
[persistedProjectScopeKey, visibleProjectGroups, projectGroupingSettings],
26392656
);
26402657
// {value, label} items let Base UI drive the combobox selection contract
26412658
// while the popup search filters the same collection.
26422659
const projectScopeItems = useMemo(
26432660
() => [
26442661
{ value: "all", label: "All projects" },
2645-
...projectGroups.map((project) => ({
2662+
...visibleProjectGroups.map((project) => ({
26462663
value: project.projectKey,
26472664
label: project.displayName,
26482665
})),
26492666
],
2650-
[projectGroups],
2667+
[visibleProjectGroups],
26512668
);
26522669
// Same-named projects on two machines are only told apart by where they
26532670
// live, so rows on another machine carry its icon once the catalog spans
@@ -2705,8 +2722,8 @@ export default function Sidebar() {
27052722
() =>
27062723
projectScopeKey === null
27072724
? null
2708-
: (projectGroups.find((project) => project.projectKey === projectScopeKey) ?? null),
2709-
[projectGroups, projectScopeKey],
2725+
: (visibleProjectGroups.find((project) => project.projectKey === projectScopeKey) ?? null),
2726+
[visibleProjectGroups, projectScopeKey],
27102727
);
27112728
const scopedProjectKeys = useMemo(
27122729
() =>
@@ -2719,6 +2736,8 @@ export default function Sidebar() {
27192736
),
27202737
[scopedProjectGroup],
27212738
);
2739+
// The scope lies inside the owner filter, so the scope wins when both are set.
2740+
const draftProjectKeys = scopedProjectKeys ?? ownerVisibleProjectKeys;
27222741
// Configs identify scratch projects, so both they and live project snapshots
27232742
// must arrive before a persisted scope can be considered missing.
27242743
const allProjectSnapshotsReady = useAllEnvironmentProjectSnapshotsReady();
@@ -2758,8 +2777,8 @@ export default function Sidebar() {
27582777
continue;
27592778
}
27602779
if (
2761-
scopedProjectKeys !== null &&
2762-
!scopedProjectKeys.has(`${session.environmentId}:${session.projectId}`)
2780+
draftProjectKeys !== null &&
2781+
!draftProjectKeys.has(`${session.environmentId}:${session.projectId}`)
27632782
) {
27642783
continue;
27652784
}
@@ -2771,7 +2790,7 @@ export default function Sidebar() {
27712790
// hidden now, and bulk actions must never count or touch invisible rows.
27722791
useEffect(() => {
27732792
clearSelection();
2774-
}, [clearSelection, projectScopeKey]);
2793+
}, [clearSelection, ownerFilter, projectScopeKey]);
27752794

27762795
const openProjectSettings = useCallback(
27772796
(projectGroup: SidebarProjectSnapshot, projectRef?: ScopedProjectRef) => {
@@ -2847,7 +2866,10 @@ export default function Sidebar() {
28472866
const preciseNow = new Date().toISOString();
28482867
// Subagent child threads live in the parent's Agents surface, not the
28492868
// 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+
);
28512873
inboxReturns.observe(workingShelfEnabled ? threads : null);
28522874
const pinned: EnvironmentThreadShell[] = [];
28532875
const active: EnvironmentThreadShell[] = [];
@@ -2950,6 +2972,7 @@ export default function Sidebar() {
29502972
}, [
29512973
nowMinute,
29522974
optimisticDrop,
2975+
ownerVisibleProjectKeys,
29532976
scopedProjectKeys,
29542977
serverConfigs,
29552978
snoozeWakeTick,
@@ -3026,7 +3049,10 @@ export default function Sidebar() {
30263049
// filter context changes so a scope/search flip never inherits a deep
30273050
// page state.
30283051
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+
]);
30303056
const lastSettledResetKeyRef = useRef(settledResetKey);
30313057
if (lastSettledResetKeyRef.current !== settledResetKey) {
30323058
lastSettledResetKeyRef.current = settledResetKey;
@@ -4689,12 +4715,17 @@ export default function Sidebar() {
46894715
AuthOrchestrationOperateScope,
46904716
),
46914717
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,
46984729
isPinned,
46994730
isSettled,
47004731
autoSettleEnabled: thread.autoSettleDisabledAt == null,
@@ -4921,6 +4952,7 @@ export default function Sidebar() {
49214952
handleMultiSelectContextMenu,
49224953
markThreadUnread,
49234954
openProjectSettings,
4955+
ownerVisibleProjectKeys,
49244956
projectScopeKey,
49254957
projectByKey,
49264958
serverConfigs,
@@ -5062,6 +5094,15 @@ export default function Sidebar() {
50625094
<SidebarThreadHeader
50635095
searchFieldRef={headerSearchRef}
50645096
hasProjects={projectGroups.length > 0}
5097+
ownerFilter={
5098+
repositoryOwnerFiltersEnabled ? (
5099+
<SidebarOwnerFilterMenu
5100+
options={ownerOptions}
5101+
filter={savedOwnerFilter}
5102+
onChange={setOwnerFilter}
5103+
/>
5104+
) : null
5105+
}
50655106
projectScope={
50665107
<Combobox
50675108
items={projectScopeItems}
@@ -5212,6 +5253,13 @@ export default function Sidebar() {
52125253
activeSearchResultIndex={activeSearchResultIndex}
52135254
onClearSearch={clearThreadSearch}
52145255
/>
5256+
{ownerFilter !== null ? (
5257+
<SidebarOwnerFilterNotice
5258+
filter={savedOwnerFilter}
5259+
hiddenProjectCount={ownerHiddenProjectCount}
5260+
onChange={setOwnerFilter}
5261+
/>
5262+
) : null}
52155263
</SidebarGroup>
52165264
}
52175265
>
@@ -5472,7 +5520,7 @@ export default function Sidebar() {
54725520
key="draft-sessions"
54735521
projectByKey={projectByKey}
54745522
projectDisplayNameByKey={projectDisplayNameByKey}
5475-
scopedProjectKeys={scopedProjectKeys}
5523+
scopedProjectKeys={draftProjectKeys}
54765524
routeDraftId={routeDraftIdForRows}
54775525
onNavigateToDraft={navigateToDraft}
54785526
onDraftContextMenu={handleDraftContextMenu}
@@ -5644,6 +5692,10 @@ export default function Sidebar() {
56445692
</>
56455693
) : scopedProjectGroup ? (
56465694
`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"
56475699
) : (
56485700
"No threads yet"
56495701
)}
Collapse file

‎apps/web/src/components/filters/FilterChip.tsx‎

Copy file name to clipboard
+96Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { XIcon } from "lucide-react";
2+
3+
import { cn } from "~/lib/utils";
4+
import { Button } from "../ui/button";
5+
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
6+
7+
/**
8+
* Fork: how a filter compares. A field with one value per item (an owner, a project) has one
9+
* operator for the whole filter. A field with many values per item (labels) has one per value.
10+
*/
11+
export type FilterOperator = "is" | "is_not";
12+
13+
export const flipFilterOperator = (operator: FilterOperator): FilterOperator =>
14+
operator === "is" ? "is_not" : "is";
15+
16+
const operatorLabel = (operator: FilterOperator) => (operator === "is_not" ? "is not" : "is");
17+
18+
/** Fork: a filter as the sentence that its chip reads, such as "Owner is not qlik-trial". */
19+
export function filterSentence(filter: {
20+
readonly field: string;
21+
readonly operator: FilterOperator | null;
22+
readonly value: string;
23+
}): string {
24+
return filter.operator === null
25+
? `${filter.field}: ${filter.value}`
26+
: `${filter.field} ${operatorLabel(filter.operator)} ${filter.value}`;
27+
}
28+
29+
/**
30+
* Fork: one active filter, read as a sentence: "Owner is not qlik-trial". The operator is a
31+
* button when the filter can flip, and the cross removes the filter. A filter without a negative
32+
* form passes a null operator and reads "Review: approved".
33+
*
34+
* An exclusion hides items, so it must stay in view: the pull request page and the sidebar show
35+
* their active filters with this chip. If upstream T3 Code ships its own active-filter chips,
36+
* move both callers to those and delete this file.
37+
*/
38+
export function FilterChip({
39+
field,
40+
operator,
41+
value,
42+
detail,
43+
onFlip,
44+
onRemove,
45+
}: {
46+
/** What the filter reads, such as "Owner". */
47+
readonly field: string;
48+
readonly operator: FilterOperator | null;
49+
readonly value: string;
50+
/** Context after the value, such as "3 projects hidden". */
51+
readonly detail?: string | undefined;
52+
/** Present when the filter can flip between is and is not. */
53+
readonly onFlip?: (() => void) | undefined;
54+
readonly onRemove: () => void;
55+
}) {
56+
const operatorClass = cn(
57+
"shrink-0 rounded-sm px-0.5 font-medium",
58+
operator === "is_not" ? "text-warning-foreground" : "text-info-foreground",
59+
);
60+
return (
61+
<span className="inline-flex h-6 min-w-0 max-w-full items-center gap-1 rounded-full border border-border bg-muted pl-2.5 text-xs">
62+
<span className="shrink-0 text-muted-foreground">
63+
{operator === null ? `${field}:` : field}
64+
</span>
65+
{operator === null ? null : onFlip ? (
66+
<button
67+
type="button"
68+
className={cn(operatorClass, "cursor-pointer hover:bg-accent")}
69+
aria-label={`Change to "${operatorLabel(flipFilterOperator(operator))}"`}
70+
onClick={onFlip}
71+
>
72+
{operatorLabel(operator)}
73+
</button>
74+
) : (
75+
<span className={operatorClass}>{operatorLabel(operator)}</span>
76+
)}
77+
{/* A long list of values truncates, so the tooltip holds the whole filter. */}
78+
<Tooltip>
79+
<TooltipTrigger
80+
render={<span className="min-w-0 truncate text-foreground">{value}</span>}
81+
/>
82+
<TooltipPopup side="top">{filterSentence({ field, operator, value })}</TooltipPopup>
83+
</Tooltip>
84+
{detail ? <span className="shrink-0 text-muted-foreground">· {detail}</span> : null}
85+
<Button
86+
size="icon-micro"
87+
variant="ghost-muted"
88+
className="mr-0.5 shrink-0"
89+
aria-label={`Remove the ${field.toLowerCase()} filter`}
90+
onClick={onRemove}
91+
>
92+
<XIcon />
93+
</Button>
94+
</span>
95+
);
96+
}
Collapse file

‎apps/web/src/components/pullRequest/PullRequestFilterChips.tsx‎

Copy file name to clipboard
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { FilterChip } from "../filters/FilterChip";
2+
import { Button } from "../ui/button";
3+
import {
4+
clearPullRequestFilterChips,
5+
type PullRequestFilterChip,
6+
} from "./pullRequestFilterChips.logic";
7+
import type { PullRequestListPreferencePatch } from "./pullRequestListPreferences";
8+
9+
/**
10+
* Fork: the active menu filters above the pull request list, shown while the
11+
* `pullRequestFilterChips` setting is on. If upstream T3 Code ships its own active-filter chips,
12+
* drop this fork version and use theirs.
13+
*/
14+
export function PullRequestFilterChips({
15+
chips,
16+
onChange,
17+
}: {
18+
readonly chips: ReadonlyArray<PullRequestFilterChip>;
19+
readonly onChange: (patch: PullRequestListPreferencePatch) => void;
20+
}) {
21+
if (chips.length === 0) return null;
22+
return (
23+
<div role="group" aria-label="Active filters" className="flex flex-wrap items-center gap-1.5">
24+
{chips.map((chip) => {
25+
const flip = chip.flip;
26+
return (
27+
<FilterChip
28+
key={chip.key}
29+
field={chip.field}
30+
operator={chip.operator}
31+
value={chip.value}
32+
onFlip={flip ? () => onChange(flip) : undefined}
33+
onRemove={() => onChange(chip.remove)}
34+
/>
35+
);
36+
})}
37+
{chips.length > 1 ? (
38+
<Button
39+
size="xs"
40+
variant="ghost-muted"
41+
onClick={() => onChange(clearPullRequestFilterChips(chips))}
42+
>
43+
Clear all
44+
</Button>
45+
) : null}
46+
</div>
47+
);
48+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.