Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/closura-arc-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
packages/contracts/src/threadMetadataMcp.test.ts \
apps/web/src/components/threadActionMenu.logic.test.ts \
apps/web/src/components/sidebar/threadListFilter.logic.test.ts \
packages/client-runtime/src/state/threadAttribution.test.ts \
apps/server/src/orchestration-v2/ThreadLaunchService.test.ts \
apps/server/src/orchestration-v2/SubagentProjection.test.ts \
packages/shared/src/threadPlacement.test.ts \
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ export function resolveSidebarRowAccessibility(input: {
readonly title: string;
readonly statusLabel: string | null;
readonly projectDisplayName: string | null;
readonly attributionLabel?: string | null;
readonly isActive: boolean;
}): { readonly label: string; readonly current: "page" | undefined } {
return {
label: [input.title, input.statusLabel, input.projectDisplayName].filter(Boolean).join(", "),
label: [
input.title,
input.statusLabel,
input.projectDisplayName,
input.attributionLabel ? `from ${input.attributionLabel}` : null,
]
.filter(Boolean)
.join(", "),
current: input.isActive ? "page" : undefined,
};
}
Expand Down
20 changes: 18 additions & 2 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { SidebarThreadFilterMenu } from "./sidebar/SidebarThreadFilterMenu";
import { matchesThreadListFilter, threadListFilterOf } from "./sidebar/threadListFilter.logic";
import {
resolveThreadAttributions,
threadAttributionKey,
} from "@t3tools/client-runtime/state/thread-attribution";
import { threadRoutingUpdateFromMenuAction } from "./threadActionMenu.logic";
import { attachSidebarTree } from "../lib/sidebarTree";
import { type EnvironmentId, type ScopedProjectRef } from "@t3tools/contracts";
Expand Down Expand Up @@ -333,6 +337,7 @@ const sidebarProviderEntriesAtom = Atom.make((get) => {

const EMPTY_PROVIDER_ENTRIES: ReadonlyMap<string, SidebarProviderEntry> = new Map();
const EMPTY_THREADS: readonly EnvironmentThreadShell[] = [];
const NO_MACHINE_OWNERS = {};

const SETTLED_TAIL_INITIAL_COUNT = 10;
const SETTLED_TAIL_PAGE_COUNT = 25;
Expand Down Expand Up @@ -1104,11 +1109,20 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const threads = useQuietThreadShells();
const promotingDraftThreadKeys = usePromotingDraftThreadKeys();
const threadListFilter = useClientSettings(threadListFilterOf);
// Search always looks across every inbox and environment.
const founderByEnvironmentId = useClientSettings((settings) => settings.founderByEnvironmentId);
const threadAttributions = resolveThreadAttributions(
threads,
founderByEnvironmentId ?? NO_MACHINE_OWNERS,
);
const attributionOf = (thread: Pick<EnvironmentThreadShell, "environmentId" | "id">) =>
threadAttributions.get(threadAttributionKey(thread)) ?? "unknown";
// Search always looks across every inbox, sender and environment.
const inboxThreads =
threadSearchQuery.trim().length > 0
? threads
: threads.filter((thread) => matchesThreadListFilter(thread, threadListFilter));
: threads.filter((thread) =>
matchesThreadListFilter(thread, threadListFilter, attributionOf(thread)),
);
const listedThreads =
promotingDraftThreadKeys.length === 0
? inboxThreads
Expand Down Expand Up @@ -2993,6 +3007,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
hasProjects={projectGroups.length > 0}
threadFilter={
<SidebarThreadFilterMenu
attributionOf={attributionOf}
countedThreads={() =>
filterSidebarV2VisibleThreads(
threads,
Expand Down Expand Up @@ -3465,6 +3480,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null
}
currentEnvironmentId={primaryEnvironmentId}
attribution={attributionOf(thread)}
environmentLabel={
environmentLabelById.get(thread.environmentId) ?? null
}
Expand Down
62 changes: 61 additions & 1 deletion apps/web/src/components/settings/NewThreadInboxSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { updateClientSettings, useClientSettings } from "../../hooks/useSettings";
import type { EnvironmentId, Founder } from "@t3tools/contracts";

import {
getClientSettings,
updateClientSettings,
useClientSettings,
} from "../../hooks/useSettings";
import { useEnvironmentIdentities } from "../../state/environments";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { SettingsRow } from "./settingsLayout";
import { searchableSetting } from "./settingsSearch";
Expand Down Expand Up @@ -34,3 +41,56 @@ export function NewThreadInboxRow() {
/>
);
}

const UNSET = "unset";

/** Which founder each machine belongs to, for threads older than inbox attribution. */
export function MachineOwnersRow() {
const environments = useEnvironmentIdentities();
const owners = useClientSettings((settings) => settings.founderByEnvironmentId) ?? {};
const setOwner = (environmentId: EnvironmentId, founder: Founder | null) => {
// Read at change time, so a second quick edit or another tab's edit is not overwritten.
const next = { ...getClientSettings().founderByEnvironmentId };
if (founder === null) delete next[environmentId];
else next[environmentId] = founder;
void updateClientSettings({ founderByEnvironmentId: next });
};
return (
<SettingsRow
{...searchableSetting("machine-owners")}
description="Older threads without sender details are credited to the machine's owner. Unset machines show as Unknown."
>
<div className="flex flex-col gap-2 pt-2">
{environments.map(({ environmentId, label }) => {
const owner = owners[environmentId];
return (
<div key={environmentId} className="flex items-center justify-between gap-4">
<span className="min-w-0 truncate text-sm">{label}</span>
<div className="w-40 shrink-0">
<Select
value={owner ?? UNSET}
onValueChange={(value) =>
setOwner(environmentId, value === "kameron" || value === "jeff" ? value : null)
}
>
<SelectTrigger
size="sm"
className="w-full min-w-0"
aria-label={`Owner of ${label}`}
>
<SelectValue>{owner ? OWNER_LABELS[owner] : "Not set"}</SelectValue>
</SelectTrigger>
<SelectPopup align="end" alignItemWithTrigger={false}>
<SelectItem value={UNSET}>Not set</SelectItem>
<SelectItem value="kameron">Kameron</SelectItem>
<SelectItem value="jeff">Jeff</SelectItem>
</SelectPopup>
</Select>
</div>
</div>
);
})}
</div>
</SettingsRow>
);
}
3 changes: 2 additions & 1 deletion apps/web/src/components/settings/SettingsPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { scopedIdleCompaction } from "./scopedSettings";
import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";
import { ThreadTitleInstructionsSettings } from "./ThreadTitleInstructionsSettings";
import { SnoozePresetsRow } from "./SnoozePresetsSettings";
import { NewThreadInboxRow } from "./NewThreadInboxSettings";
import { MachineOwnersRow, NewThreadInboxRow } from "./NewThreadInboxSettings";
import { useDesktopUpdateState } from "../../state/desktopUpdate";
import { managedTelemetryOffMessage, usePrimaryManagedPolicy } from "../../state/managedPolicy";
import {
Expand Down Expand Up @@ -1844,6 +1844,7 @@ export function ThreadsSettingsPanel() {
{!isProjectScope ? (
<SettingsSection id="inbox" title="Inbox">
<NewThreadInboxRow />
<MachineOwnersRow />
</SettingsSection>
) : null}

Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/components/settings/settingsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,12 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/threads",
searchTerms: ["inbox owner founder kameron jeff attribute filed"],
},
{
id: "machine-owners",
title: "Machine owners",
to: "/settings/threads",
searchTerms: ["environment founder kameron jeff attribution from sender badge"],
},
{
id: "add-project-starts-in",
title: "Add project starts in",
Expand Down
62 changes: 54 additions & 8 deletions apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import {
type Founder,
type InboxChoice,
} from "@t3tools/contracts";
import {
THREAD_ATTRIBUTION_LABELS,
THREAD_ATTRIBUTIONS,
} from "@t3tools/client-runtime/state/thread-attribution";
import type { ThreadAttribution } from "@t3tools/contracts/settings";
import { SlidersHorizontalIcon } from "lucide-react";
import type { ReactNode } from "react";

Expand Down Expand Up @@ -38,15 +43,17 @@ const INBOX_LABELS: Record<InboxChoice, string> = {
shared: "Shared",
};

type CountedThreads = Parameters<typeof threadListFilterCounts>[0];
type CountedThread = Parameters<typeof threadListFilterCounts>[0][number];
const LAST_OPTION_NOTE = ", the last one shown, so it stays checked";

/** Chooses which inboxes and environments the thread list shows. Search still finds every thread. */
export function SidebarThreadFilterMenu({
export function SidebarThreadFilterMenu<T extends CountedThread>({
countedThreads,
attributionOf,
}: {
/** Called only while the menu is open. */
countedThreads: () => CountedThreads;
countedThreads: () => ReadonlyArray<T>;
attributionOf: (thread: T) => ThreadAttribution;
}) {
const filter = useClientSettings(threadListFilterOf);
const owner = useClientSettings((settings) => settings.founderInboxOwner);
Expand All @@ -61,11 +68,16 @@ export function SidebarThreadFilterMenu({
changed.environments
? `${hiddenCount} environment${hiddenCount === 1 ? "" : "s"} hidden`
: null,
changed.from
? `from ${THREAD_ATTRIBUTIONS.filter((from) => !filter.hiddenAttributions.includes(from))
.map((from) => THREAD_ATTRIBUTION_LABELS[from])
.join(", ")}`
: null,
].filter((part) => part !== null);
const label =
summary.length === 0
? "Filter threads by inbox and environment"
: `Filter threads by inbox and environment (${summary.join("; ")})`;
? "Filter threads by inbox, sender and environment"
: `Filter threads by inbox, sender and environment (${summary.join("; ")})`;
return (
<Menu>
<MenuTrigger render={<SidebarHeaderIconButton label={label} />}>
Expand All @@ -80,6 +92,7 @@ export function SidebarThreadFilterMenu({
<MenuPopup align="end" className="w-[min(16rem,var(--available-width))]">
<SidebarThreadFilterOptions
countedThreads={countedThreads}
attributionOf={attributionOf}
filter={filter}
owner={owner}
environments={environments}
Expand All @@ -91,21 +104,26 @@ export function SidebarThreadFilterMenu({
}

// Mounted only while the menu is open, so counting never runs on streaming ticks.
function SidebarThreadFilterOptions({
function SidebarThreadFilterOptions<T extends CountedThread>({
countedThreads,
attributionOf,
filter,
owner,
environments,
isChanged,
}: {
countedThreads: () => CountedThreads;
countedThreads: () => ReadonlyArray<T>;
attributionOf: (thread: T) => ThreadAttribution;
filter: ThreadListFilter;
owner: Founder | undefined;
environments: ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string }>;
isChanged: boolean;
}) {
const connectedEnvironmentIds = useConnectedEnvironmentIds();
const counts = threadListFilterCounts(countedThreads(), filter);
const counts = threadListFilterCounts(countedThreads(), filter, attributionOf);
const shownAttributions = THREAD_ATTRIBUTIONS.filter(
(from) => !filter.hiddenAttributions.includes(from),
);
const inboxOrder = inboxMenuOrder(owner);
const environmentIds = environments.map((environment) => environment.environmentId);
const shownEnvironmentIds = environmentIds.filter(
Expand Down Expand Up @@ -136,6 +154,33 @@ function SidebarThreadFilterOptions({
);
})}
</MenuGroup>
<MenuSeparator />
<MenuGroup>
<MenuGroupLabel>From</MenuGroupLabel>
{THREAD_ATTRIBUTIONS.map((from) => {
const checked = shownAttributions.includes(from);
const isLast = checked && shownAttributions.length === 1;
const count = counts.from.get(from) ?? 0;
return (
<MenuCheckboxItem
key={from}
checked={checked}
disabled={isLast}
aria-label={`From ${THREAD_ATTRIBUTION_LABELS[from]}, ${count} active${isLast ? LAST_OPTION_NOTE : ""}`}
onCheckedChange={() => {
const shown = toggleFilterOption(shownAttributions, from, THREAD_ATTRIBUTIONS);
void updateClientSettings({
sidebarHiddenThreadAttributions: THREAD_ATTRIBUTIONS.filter(
(candidate) => !shown.includes(candidate),
),
});
}}
>
<FilterOptionRow label={THREAD_ATTRIBUTION_LABELS[from]} count={count} />
</MenuCheckboxItem>
);
})}
</MenuGroup>
{environments.length > 1 ? (
<>
<MenuSeparator />
Expand Down Expand Up @@ -189,6 +234,7 @@ function SidebarThreadFilterOptions({
void updateClientSettings({
founderInboxFilter: effectiveInboxFilter({ founderInboxOwner: owner }),
sidebarHiddenEnvironmentIds: [],
sidebarHiddenThreadAttributions: [],
})
}
>
Expand Down
Loading
Loading