From a40e6b22a268bb526a96ce6397ea9d11f942131f Mon Sep 17 00:00:00 2001 From: CarsonJF Date: Thu, 12 Nov 2026 19:31:51 -0500 Subject: [PATCH 001/141] feat(web): add client-side thread groups store Groups, per-project default history, per-thread overrides and collapsed state persist to localStorage. A thread's group resolves from its override, else the project default in effect when it was created, so changing a default never moves older threads. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/threadGroupsStore.test.ts | 106 +++++++++++++++++ apps/web/src/threadGroupsStore.ts | 158 +++++++++++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 apps/web/src/threadGroupsStore.test.ts create mode 100644 apps/web/src/threadGroupsStore.ts diff --git a/apps/web/src/threadGroupsStore.test.ts b/apps/web/src/threadGroupsStore.test.ts new file mode 100644 index 000000000000..617f8589d28e --- /dev/null +++ b/apps/web/src/threadGroupsStore.test.ts @@ -0,0 +1,106 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { + createThreadGroup, + deleteThreadGroup, + EMPTY_THREAD_GROUPS_STATE, + readPersistedThreadGroups, + resolveThreadGroupId, + setProjectDefaultGroup, + setThreadGroup, + threadGroupActions, + useThreadGroupsStore, +} from "./threadGroupsStore"; + +const PROJECT = "env-1:project-1"; + +function thread(threadKey: string, createdAt: string) { + return { threadKey, projectKey: PROJECT, createdAt }; +} + +function withGroups(...names: string[]) { + return names.reduce( + (state, name) => createThreadGroup(state, { id: name, name }), + EMPTY_THREAD_GROUPS_STATE, + ); +} + +describe("resolveThreadGroupId", () => { + it("puts threads created after a project default into that group", () => { + const state = setProjectDefaultGroup( + withGroups("xn"), + [PROJECT], + "xn", + "2026-10-26T10:00:00.000Z", + ); + + expect(resolveThreadGroupId(state, thread("new", "2026-10-26T11:00:00.000Z"))).toBe("xn"); + expect(resolveThreadGroupId(state, thread("old", "2026-10-26T09:00:00.000Z"))).toBeNull(); + }); + + it("changing a project default only affects threads created afterwards", () => { + const first = setProjectDefaultGroup( + withGroups("xn", "other"), + [PROJECT], + "xn", + "2026-10-26T10:00:00.000Z", + ); + const changed = setProjectDefaultGroup(first, [PROJECT], "other", "2026-10-26T12:00:00.000Z"); + + expect(resolveThreadGroupId(changed, thread("before", "2026-10-26T11:00:00.000Z"))).toBe("xn"); + expect(resolveThreadGroupId(changed, thread("after", "2026-10-26T13:00:00.000Z"))).toBe( + "other", + ); + }); + + it("lets a thread override its project default, including opting out of every group", () => { + const defaulted = setProjectDefaultGroup( + withGroups("xn", "other"), + [PROJECT], + "xn", + "2026-10-26T10:00:00.000Z", + ); + const moved = setThreadGroup(defaulted, "a", "other"); + const ungrouped = setThreadGroup(moved, "b", null); + + expect(resolveThreadGroupId(ungrouped, thread("a", "2026-10-26T11:00:00.000Z"))).toBe("other"); + expect(resolveThreadGroupId(ungrouped, thread("b", "2026-10-26T11:00:00.000Z"))).toBeNull(); + expect(resolveThreadGroupId(ungrouped, thread("c", "2026-10-26T11:00:00.000Z"))).toBe("xn"); + }); + + it("ungroups every member of a deleted group without restoring older defaults", () => { + const state = setThreadGroup( + setProjectDefaultGroup( + setProjectDefaultGroup(withGroups("xn", "other"), [PROJECT], "xn", "2026-10-26T10:00:00Z"), + [PROJECT], + "other", + "2026-10-26T12:00:00.000Z", + ), + "moved", + "other", + ); + const deleted = deleteThreadGroup({ ...state, collapsed: { other: true } }, "other"); + + expect(deleted.groups.map((group) => group.id)).toEqual(["xn"]); + expect(deleted.collapsed).toEqual({}); + expect(resolveThreadGroupId(deleted, thread("moved", "2026-10-26T11:00:00.000Z"))).toBeNull(); + expect(resolveThreadGroupId(deleted, thread("later", "2026-10-26T13:00:00.000Z"))).toBeNull(); + expect(resolveThreadGroupId(deleted, thread("earlier", "2026-10-26T11:00:00.000Z"))).toBe("xn"); + }); +}); + +describe("threadGroupActions", () => { + it("persists groups and collapsed state so they survive a reload", () => { + useThreadGroupsStore.setState(EMPTY_THREAD_GROUPS_STATE, true); + const groupId = threadGroupActions.create("xnproductions"); + threadGroupActions.setProjectDefault([PROJECT], groupId); + threadGroupActions.setThreadGroup("env-1:thread-1", null); + threadGroupActions.toggleCollapsed(groupId); + + const reloaded = readPersistedThreadGroups(); + + expect(reloaded).toEqual(useThreadGroupsStore.getState()); + expect(reloaded.collapsed[groupId]).toBe(true); + expect(reloaded.groups).toEqual([{ id: groupId, name: "xnproductions" }]); + }); +}); diff --git a/apps/web/src/threadGroupsStore.ts b/apps/web/src/threadGroupsStore.ts new file mode 100644 index 000000000000..d111bd8ffc33 --- /dev/null +++ b/apps/web/src/threadGroupsStore.ts @@ -0,0 +1,158 @@ +import * as Schema from "effect/Schema"; +import { create } from "zustand"; + +import { getLocalStorageItem, setLocalStorageItem } from "./hooks/useLocalStorage"; +import { randomUUID } from "./lib/utils"; + +export const THREAD_GROUPS_STORAGE_KEY = "t3code:thread-groups:v1"; + +const ThreadGroup = Schema.Struct({ id: Schema.String, name: Schema.String }); +export type ThreadGroup = typeof ThreadGroup.Type; + +const ProjectDefaultEntry = Schema.Struct({ + groupId: Schema.NullOr(Schema.String), + since: Schema.String, +}); + +export const ThreadGroupsStateSchema = Schema.Struct({ + groups: Schema.Array(ThreadGroup), + // Append-only per project so a new default never moves threads created before it. + projectDefaults: Schema.Record(Schema.String, Schema.Array(ProjectDefaultEntry)), + // `null` pins a thread outside every group, overriding its project default. + threadOverrides: Schema.Record(Schema.String, Schema.NullOr(Schema.String)), + collapsed: Schema.Record(Schema.String, Schema.Boolean), +}); +export type ThreadGroupsState = typeof ThreadGroupsStateSchema.Type; + +export const EMPTY_THREAD_GROUPS_STATE: ThreadGroupsState = { + groups: [], + projectDefaults: {}, + threadOverrides: {}, + collapsed: {}, +}; + +function existingGroupId(state: ThreadGroupsState, groupId: string | null | undefined) { + return groupId != null && state.groups.some((group) => group.id === groupId) ? groupId : null; +} + +export function projectDefaultGroupId(state: ThreadGroupsState, projectKey: string): string | null { + return existingGroupId(state, state.projectDefaults[projectKey]?.at(-1)?.groupId); +} + +export function resolveThreadGroupId( + state: ThreadGroupsState, + thread: { readonly threadKey: string; readonly projectKey: string; readonly createdAt: string }, +): string | null { + if (Object.hasOwn(state.threadOverrides, thread.threadKey)) { + return existingGroupId(state, state.threadOverrides[thread.threadKey]); + } + const createdAtMs = Date.parse(thread.createdAt); + const entry = state.projectDefaults[thread.projectKey]?.findLast( + (candidate) => Date.parse(candidate.since) <= createdAtMs, + ); + return existingGroupId(state, entry?.groupId); +} + +export function createThreadGroup(state: ThreadGroupsState, group: ThreadGroup): ThreadGroupsState { + return { ...state, groups: [...state.groups, group] }; +} + +export function renameThreadGroup( + state: ThreadGroupsState, + groupId: string, + name: string, +): ThreadGroupsState { + return { + ...state, + groups: state.groups.map((group) => (group.id === groupId ? { ...group, name } : group)), + }; +} + +export function deleteThreadGroup(state: ThreadGroupsState, groupId: string): ThreadGroupsState { + const { [groupId]: _removed, ...collapsed } = state.collapsed; + return { + groups: state.groups.filter((group) => group.id !== groupId), + projectDefaults: Object.fromEntries( + Object.entries(state.projectDefaults).map(([projectKey, entries]) => [ + projectKey, + entries.map((entry) => (entry.groupId === groupId ? { ...entry, groupId: null } : entry)), + ]), + ), + threadOverrides: Object.fromEntries( + Object.entries(state.threadOverrides).map(([threadKey, override]) => [ + threadKey, + override === groupId ? null : override, + ]), + ), + collapsed, + }; +} + +export function setProjectDefaultGroup( + state: ThreadGroupsState, + projectKeys: ReadonlyArray, + groupId: string | null, + since: string, +): ThreadGroupsState { + const projectDefaults = { ...state.projectDefaults }; + for (const projectKey of projectKeys) { + if (projectDefaultGroupId(state, projectKey) === groupId) continue; + projectDefaults[projectKey] = [...(projectDefaults[projectKey] ?? []), { groupId, since }]; + } + return { ...state, projectDefaults }; +} + +export function setThreadGroup( + state: ThreadGroupsState, + threadKey: string, + groupId: string | null, +): ThreadGroupsState { + return { ...state, threadOverrides: { ...state.threadOverrides, [threadKey]: groupId } }; +} + +export function readPersistedThreadGroups(): ThreadGroupsState { + try { + return ( + getLocalStorageItem(THREAD_GROUPS_STORAGE_KEY, ThreadGroupsStateSchema) ?? + EMPTY_THREAD_GROUPS_STATE + ); + } catch (error) { + console.error("[THREAD_GROUPS] Could not read stored groups.", error); + return EMPTY_THREAD_GROUPS_STATE; + } +} + +export const useThreadGroupsStore = create(() => readPersistedThreadGroups()); + +useThreadGroupsStore.subscribe((state) => { + try { + setLocalStorageItem(THREAD_GROUPS_STORAGE_KEY, state, ThreadGroupsStateSchema); + } catch (error) { + console.error("[THREAD_GROUPS] Could not persist groups.", error); + } +}); + +const update = (apply: (state: ThreadGroupsState) => ThreadGroupsState) => + useThreadGroupsStore.setState((state) => apply(state), true); + +export const threadGroupActions = { + create: (name: string): string => { + const id = randomUUID(); + update((state) => createThreadGroup(state, { id, name })); + return id; + }, + rename: (groupId: string, name: string) => + update((state) => renameThreadGroup(state, groupId, name)), + delete: (groupId: string) => update((state) => deleteThreadGroup(state, groupId)), + setProjectDefault: (projectKeys: ReadonlyArray, groupId: string | null) => + update((state) => + setProjectDefaultGroup(state, projectKeys, groupId, new Date().toISOString()), + ), + setThreadGroup: (threadKey: string, groupId: string | null) => + update((state) => setThreadGroup(state, threadKey, groupId)), + toggleCollapsed: (groupId: string) => + update((state) => ({ + ...state, + collapsed: { ...state.collapsed, [groupId]: !state.collapsed[groupId] }, + })), +}; From 150c0def50a97af7825294689a83a5f72b083691 Mon Sep 17 00:00:00 2001 From: CarsonJF Date: Mon, 26 Oct 2026 20:39:39 -0400 Subject: [PATCH 002/141] feat(web): show thread groups as collapsible sidebar sections Active threads resolve to a group (thread override, else the project default in effect when the thread was created) and render under collapsible group headers with rename and delete. The thread context menu gains Move to group, including No group and New group. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/Sidebar.tsx | 69 +++++++++++++- .../src/components/ThreadGroupNameDialog.tsx | 94 +++++++++++++++++++ .../sidebar/SidebarThreadGroupHeader.tsx | 78 +++++++++++++++ .../components/sidebar/SidebarThreadRow.tsx | 14 +++ .../src/components/threadActionMenu.logic.ts | 60 +++++++++--- apps/web/src/components/threadGroupMenu.ts | 57 +++++++++++ .../web/src/hooks/useThreadActionMenu.test.ts | 4 + apps/web/src/hooks/useThreadActionMenu.ts | 6 ++ apps/web/src/routes/__root.tsx | 2 + apps/web/src/threadGroupsStore.ts | 35 ++++++- 10 files changed, 399 insertions(+), 20 deletions(-) create mode 100644 apps/web/src/components/ThreadGroupNameDialog.tsx create mode 100644 apps/web/src/components/sidebar/SidebarThreadGroupHeader.tsx create mode 100644 apps/web/src/components/threadGroupMenu.ts diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 45e00246e2c6..1e4b5be90a50 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -120,6 +120,7 @@ import { type SidebarProjectSnapshot, } from "../sidebarProjectGrouping"; import { resolveProjectExpanded, useUiStateStore } from "../uiStateStore"; +import { splitThreadsByGroup, useThreadGroupsStore } from "../threadGroupsStore"; import { getThreadKeysToDeselectAfterDelete, useThreadSelectionStore, @@ -269,6 +270,7 @@ import { useShownThreadRouteTarget } from "../hooks/useShownThreadRouteTarget"; import { SidebarSearchResultRow, SortableThreadRow, + StaticThreadRow, type SidebarProviderEntry, type SidebarSweepAction, } from "./sidebar/SidebarThreadRow"; @@ -282,6 +284,8 @@ import { SidebarSectionHeader, SidebarSectionPlaceholder, } from "./sidebar/SidebarListMarkers"; +import { SidebarThreadGroupHeader } from "./sidebar/SidebarThreadGroupHeader"; +import { handleThreadGroupMenuAction, readThreadGroupMenuState } from "./threadGroupMenu"; function sameSidebarProviderEntries( left: ReadonlyMap, @@ -498,8 +502,22 @@ function useSidebarThreads(input: { clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`, }); - const { pinnedThreads, activeThreads, workingThreads, snoozedThreads, settledThreads } = - partition; + const { pinnedThreads, workingThreads, snoozedThreads, settledThreads } = partition; + const threadGroupsState = useThreadGroupsStore(); + const { ungrouped: activeThreads, groups } = splitThreadsByGroup( + partition.activeThreads, + threadGroupsState, + ); + const threadGroupSections = groups.map(({ group, threads: groupThreads }) => { + const expanded = threadGroupsState.collapsed[group.id] !== true; + return { + group, + count: groupThreads.length, + expanded, + threads: expanded ? groupThreads : routeThreadOnly(groupThreads, routeRowThreadKey), + }; + }); + const groupedThreads = threadGroupSections.flatMap((section) => section.threads); // Older settled threads load in pages; the shelf lists them only as far as they are loaded. const olderSettledShelf = useOlderSettledShelf({ scopes: olderSettledScopes([...serverConfigs.keys()], scopedProjectKeys), @@ -557,6 +575,7 @@ function useSidebarThreads(input: { ...(projectFolders === null ? activeThreads : projectFolders.flatMap((folder) => folder.threads)), + ...groupedThreads, ...visibleWorkingThreads, ...visibleSnoozedThreads, ...renderedSettledThreads, @@ -564,7 +583,7 @@ function useSidebarThreads(input: { const sectionByThreadKey = new Map(); for (const [list, section] of [ [pinnedThreads, "pinned"], - [activeThreads, "active"], + [partition.activeThreads, "active"], [workingThreads, "working"], [snoozedThreads, "snoozed"], [settledThreads, "settled"], @@ -573,11 +592,17 @@ function useSidebarThreads(input: { } return { ...partition, + activeThreads, + threadGroupSections, + groupedThreadCount: groups.reduce( + (sum, { threads: groupThreads }) => sum + groupThreads.length, + 0, + ), threads, workingShelfEnabled, searchableThreads: [ ...pinnedThreads, - ...activeThreads, + ...partition.activeThreads, ...workingThreads, ...snoozedThreads, ...settledThreads, @@ -1315,6 +1340,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve draggableThreadKeys, activeReorderableThreadKeys, activeThreads, + threadGroupSections, + groupedThreadCount, workingThreads, snoozedThreads, settledThreads, @@ -2704,12 +2731,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve titleRegeneration: configLoaded, }, snoozePresets, + threadGroups: readThreadGroupMenuState(thread), }), position, source, ), ); if (clicked._tag === "Failure" || clicked.value === null) return; + if (await handleThreadGroupMenuAction(clicked.value, thread)) return; if (threadActionRequiresOperate(clicked.value) && !checkThreadOperations([thread])) return; if (clicked.value?.startsWith("snooze:")) { const preset = @@ -3364,6 +3393,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve visibleDraftSessionCount === 0 && pinnedThreads.length + activeThreads.length + + groupedThreadCount + workingThreads.length + snoozedThreads.length === 0 && @@ -3449,6 +3479,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve section: SidebarSection, // The tree row of the project folder this row sits in. folderRow?: string, + grouped = false, ) => { const threadKey = scopedThreadKey( scopeThreadRef(thread.environmentId, thread.id), @@ -3462,8 +3493,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve : isCard ? "card" : "slim"; + const ThreadRow = grouped ? StaticThreadRow : SortableThreadRow; return ( - , ]; + let threadGroupsRendered = false; + const pushThreadGroups = () => { + threadGroupsRendered = true; + for (const section of threadGroupSections) { + items.push( + , + ); + for (const thread of section.threads) { + items.push(renderThreadRow(thread, "active", undefined, true)); + } + } + }; for (const item of sidebarListItems) { + if ( + !threadGroupsRendered && + item.kind === "marker" && + (item.marker === "working-header" || + item.marker === "snoozed-header" || + item.marker === "settled-header") + ) { + pushThreadGroups(); + } if (item.kind === "thread") { // Folders draw active rows in their own place below. if (projectFolders !== null && item.section === "active") continue; @@ -3721,6 +3779,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve break; } } + if (!threadGroupsRendered) pushThreadGroups(); return items; })()} {settledShelfExpanded && hiddenSettledCount > 0 ? ( diff --git a/apps/web/src/components/ThreadGroupNameDialog.tsx b/apps/web/src/components/ThreadGroupNameDialog.tsx new file mode 100644 index 000000000000..bad16fc2a071 --- /dev/null +++ b/apps/web/src/components/ThreadGroupNameDialog.tsx @@ -0,0 +1,94 @@ +import { useEffect, useState } from "react"; +import { create } from "zustand"; + +import { threadGroupActions } from "../threadGroupsStore"; +import { Button } from "./ui/button"; +import { + Dialog, + DialogFooter, + DialogHeader, + DialogPanel, + DialogPopup, + DialogTitle, +} from "./ui/dialog"; +import { Input } from "./ui/input"; + +type Request = { + readonly title: string; + readonly submitLabel: string; + readonly initialName: string; + readonly resolve: (name: string | null) => void; +}; +const useRequest = create<{ request: Request | null }>(() => ({ request: null })); + +export function requestThreadGroupName(options: Omit): Promise { + useRequest.getState().request?.resolve(null); + return new Promise((resolve) => useRequest.setState({ request: { ...options, resolve } })); +} + +export async function createThreadGroupFromPrompt(): Promise { + const name = await requestThreadGroupName({ + title: "New group", + submitLabel: "Create", + initialName: "", + }); + return name === null ? null : threadGroupActions.create(name); +} + +function finish(name: string | null) { + const request = useRequest.getState().request; + useRequest.setState({ request: null }); + request?.resolve(name); +} + +export function ThreadGroupNameDialogHost() { + const request = useRequest((state) => state.request); + // oxlint-disable-next-line t3code/react-effect-budget -- settles a pending prompt if the host unmounts + useEffect(() => () => finish(null), []); + return request ? : null; +} + +function ThreadGroupNameDialog({ request }: { request: Request }) { + const [name, setName] = useState(request.initialName); + const trimmed = name.trim(); + return ( + { + if (!open) finish(null); + }} + > + +
{ + event.preventDefault(); + if (trimmed.length > 0) finish(trimmed); + }} + > + + {request.title} + + + setName(event.target.value)} + /> + + + + + +
+
+
+ ); +} diff --git a/apps/web/src/components/sidebar/SidebarThreadGroupHeader.tsx b/apps/web/src/components/sidebar/SidebarThreadGroupHeader.tsx new file mode 100644 index 000000000000..9bf5ebfb8a30 --- /dev/null +++ b/apps/web/src/components/sidebar/SidebarThreadGroupHeader.tsx @@ -0,0 +1,78 @@ +import { settlePromise } from "@t3tools/client-runtime/state/runtime"; +import type { MouseEvent } from "react"; + +import { useClientSettings } from "../../hooks/useSettings"; +import { readLocalApi } from "../../localApi"; +import { threadGroupActions, type ThreadGroup } from "../../threadGroupsStore"; +import { requestThreadGroupName } from "../ThreadGroupNameDialog"; +import { CollapsibleSectionHeader } from "../ui/collapsible-section-header"; + +async function openThreadGroupMenu(group: ThreadGroup, position: { x: number; y: number }) { + const api = readLocalApi(); + if (!api) return; + const clicked = await settlePromise(() => + api.contextMenu.show( + [ + { id: "rename" as const, label: "Rename group", icon: "pencil" }, + { id: "delete" as const, label: "Delete group", icon: "trash", destructive: true }, + ], + position, + ), + ); + if (clicked._tag === "Failure") return; + if (clicked.value === "rename") { + const name = await requestThreadGroupName({ + title: "Rename group", + submitLabel: "Rename", + initialName: group.name, + }); + if (name !== null) threadGroupActions.rename(group.id, name); + } else if (clicked.value === "delete") { + const confirmed = await settlePromise(() => + api.dialogs.confirm( + [ + `Delete group "${group.name}"?`, + "Its threads and projects stay; they become ungrouped.", + ].join("\n"), + { variant: "destructive" }, + ), + ); + if (confirmed._tag === "Failure" || !confirmed.value) return; + threadGroupActions.delete(group.id); + } +} + +export function SidebarThreadGroupHeader(props: { + group: ThreadGroup; + count: number; + expanded: boolean; +}) { + const redesign = useClientSettings((s) => s.redesignEnabled); + const collapsedCount = props.expanded ? null : props.count; + const count = redesign ? props.count : collapsedCount; + return ( +
  • { + event.preventDefault(); + void openThreadGroupMenu(props.group, { x: event.clientX, y: event.clientY }); + }} + > + threadGroupActions.toggleCollapsed(props.group.id)} + expanded={props.expanded} + tone="muted" + accessory={ + redesign && count !== null ? ( + {count} + ) : null + } + > + {props.group.name} + {!redesign && collapsedCount !== null ? ` (${collapsedCount})` : null} + +
  • + ); +} diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 878cbc894bb8..0bbff585e9ad 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -522,6 +522,20 @@ export function SortableThreadRow( // Keyed by variant so a card/slim switch remounts the row. return ; } + +// Thread-group rows sit outside the sortable list, whose drop targets are sections, not groups. +export function StaticThreadRow(props: Parameters[0]) { + const { + sortableId: _sortableId, + sortableDisabled: _disabled, + contextDrag: _drag, + ...rowProps + } = props; + const thread = + useThreadShell(scopeThreadRef(rowProps.thread.environmentId, rowProps.thread.id)) ?? + rowProps.thread; + return ; +} export type SidebarSweepAction = "settle" | "unsettle" | "unsnooze"; const dropVerbBadge: Record = { pin: ( diff --git a/apps/web/src/components/threadActionMenu.logic.ts b/apps/web/src/components/threadActionMenu.logic.ts index dc2d7687a2be..8ec8af8525e0 100644 --- a/apps/web/src/components/threadActionMenu.logic.ts +++ b/apps/web/src/components/threadActionMenu.logic.ts @@ -24,6 +24,10 @@ export type ThreadActionMenuId = | "regenerate-title" | "mark-unread" | "share-guest" + | "group" + | "group:none" + | "group:new" + | `group:set:${string}` | "copy" | "copy-path" | "copy-branch" @@ -123,28 +127,36 @@ export interface ThreadActionMenuState { readonly canShareWithGuest?: boolean; /** A No project thread with its own folder, on a server that can promote it. */ readonly canTurnIntoProject?: boolean; + readonly threadGroups?: { + readonly groups: ReadonlyArray<{ readonly id: string; readonly name: string }>; + readonly currentGroupId: string | null; + }; } -/** Local navigation, read markers, and copying remain available to read-only clients. */ +/** Local navigation, read markers, grouping, and copying remain available to read-only clients. */ export function threadActionRequiresOperate(action: ThreadActionMenuId): boolean { - return ![ - "find", - "new-thread-on-branch", - "project-settings", - "mark-unread", - "share-guest", - "copy", - "copy-path", - "copy-branch", - "copy-thread", - "copy-thread-id", - ].includes(action); + return ( + !action.startsWith("group") && + ![ + "find", + "new-thread-on-branch", + "project-settings", + "mark-unread", + "share-guest", + "copy", + "copy-path", + "copy-branch", + "copy-thread", + "copy-thread-id", + ].includes(action) + ); } export function buildThreadActionMenuItems( state: ThreadActionMenuState, resolve: MessageResolver = m, ): ReadonlyArray> { + const { threadGroups } = state; const items: ReadonlyArray> = [ ...(state.canFind ? [{ id: "find" as const, label: resolve(msg("Find in thread")), icon: "text-search" }] @@ -244,6 +256,28 @@ export function buildThreadActionMenuItems( }, ] : []), + ...(threadGroups + ? [ + { + id: "group" as const, + label: "Move to group", + icon: "folder", + children: [ + { + id: "group:none" as const, + label: "No group", + checked: threadGroups.currentGroupId === null, + }, + ...threadGroups.groups.map((group) => ({ + id: `group:set:${group.id}` as const, + label: group.name, + checked: group.id === threadGroups.currentGroupId, + })), + { id: "group:new" as const, label: "New group…", separatorBefore: true }, + ], + }, + ] + : []), ...(state.supports.autoSettleOptOut ? [ { diff --git a/apps/web/src/components/threadGroupMenu.ts b/apps/web/src/components/threadGroupMenu.ts new file mode 100644 index 000000000000..2ddef734b93c --- /dev/null +++ b/apps/web/src/components/threadGroupMenu.ts @@ -0,0 +1,57 @@ +import { + scopedProjectKey, + scopedThreadKey, + scopeProjectRef, + scopeThreadRef, +} from "@t3tools/client-runtime/environment"; +import type { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts"; + +import { + resolveThreadGroupId, + threadGroupActions, + useThreadGroupsStore, +} from "../threadGroupsStore"; +import { createThreadGroupFromPrompt } from "./ThreadGroupNameDialog"; +import type { ThreadActionMenuId, ThreadActionMenuState } from "./threadActionMenu.logic"; + +interface GroupableThread { + readonly environmentId: EnvironmentId; + readonly id: ThreadId; + readonly projectId: ProjectId; + readonly createdAt: string; +} + +const threadKeyOf = (thread: GroupableThread) => + scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)); + +export function readThreadGroupMenuState( + thread: GroupableThread, +): NonNullable { + const state = useThreadGroupsStore.getState(); + return { + groups: state.groups, + currentGroupId: resolveThreadGroupId(state, { + threadKey: threadKeyOf(thread), + projectKey: scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)), + createdAt: thread.createdAt, + }), + }; +} + +/** Returns whether `action` was a group action, so callers can stop handling it. */ +export async function handleThreadGroupMenuAction( + action: ThreadActionMenuId, + thread: GroupableThread, +): Promise { + if (action === "group:none") { + threadGroupActions.setThreadGroup(threadKeyOf(thread), null); + } else if (action === "group:new") { + const groupId = await createThreadGroupFromPrompt(); + if (groupId !== null) threadGroupActions.setThreadGroup(threadKeyOf(thread), groupId); + } else if (action.startsWith("group:set:")) { + threadGroupActions.setThreadGroup(threadKeyOf(thread), action.slice("group:set:".length)); + } else { + return false; + } + return true; +} diff --git a/apps/web/src/hooks/useThreadActionMenu.test.ts b/apps/web/src/hooks/useThreadActionMenu.test.ts index 3c8255b04c08..cb583900b156 100644 --- a/apps/web/src/hooks/useThreadActionMenu.test.ts +++ b/apps/web/src/hooks/useThreadActionMenu.test.ts @@ -35,6 +35,10 @@ function recordEffect(action: string) { } vi.mock("../components/CustomSnoozeDialog", () => ({ requestCustomSnooze: vi.fn() })); +vi.mock("../components/threadGroupMenu", () => ({ + readThreadGroupMenuState: () => undefined, + handleThreadGroupMenuAction: async () => false, +})); vi.mock("react", () => ({ useCallback: (callback: unknown) => callback, useMemo: (factory: () => unknown) => factory(), diff --git a/apps/web/src/hooks/useThreadActionMenu.ts b/apps/web/src/hooks/useThreadActionMenu.ts index 4e5914d078c5..bc467f11b532 100644 --- a/apps/web/src/hooks/useThreadActionMenu.ts +++ b/apps/web/src/hooks/useThreadActionMenu.ts @@ -18,6 +18,10 @@ import { useRouter } from "@tanstack/react-router"; import { msg } from "gt-react"; import { pickSnoozePreset, resolveSnoozePresets } from "../components/Sidebar.snooze"; +import { + handleThreadGroupMenuAction, + readThreadGroupMenuState, +} from "../components/threadGroupMenu"; import { buildThreadActionMenuItems, threadActionRequiresOperate, @@ -154,10 +158,12 @@ export function useThreadActionMenu(input: { snoozePresets, canShareWithGuest, canTurnIntoProject: canTurnThreadIntoProject(threadRef), + threadGroups: readThreadGroupMenuState(thread), }); const clicked = await settlePromise(() => api.contextMenu.show(items, position)); if (clicked._tag === "Failure" || clicked.value === null) return; const action: ThreadActionMenuId = clicked.value; + if (await handleThreadGroupMenuAction(action, thread)) return; if ( threadActionRequiresOperate(action) && !readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope) diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index 3cbef77306c8..03e0dfb51a1a 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -18,6 +18,7 @@ import { APP_DISPLAY_NAME, APP_VERSION } from "../branding"; import { AppSidebarLayout } from "../components/AppSidebarLayout"; import { CommandPalette } from "../components/CommandPalette"; import { CustomSnoozeDialogHost } from "../components/CustomSnoozeDialog"; +import { ThreadGroupNameDialogHost } from "../components/ThreadGroupNameDialog"; import { GuestShareDialogHost } from "../components/chat/GuestShareControls"; import { UseInAnotherAppDialogHost } from "../components/mcp/UseInAnotherAppDialog"; import { AddProjectToMachineDialogHost } from "../components/AddProjectToMachineDialog"; @@ -200,6 +201,7 @@ function RootRouteBranch() { + diff --git a/apps/web/src/threadGroupsStore.ts b/apps/web/src/threadGroupsStore.ts index d111bd8ffc33..10466a1eb513 100644 --- a/apps/web/src/threadGroupsStore.ts +++ b/apps/web/src/threadGroupsStore.ts @@ -1,10 +1,17 @@ +import { + scopedProjectKey, + scopedThreadKey, + scopeProjectRef, + scopeThreadRef, +} from "@t3tools/client-runtime/environment"; +import type { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts"; import * as Schema from "effect/Schema"; import { create } from "zustand"; import { getLocalStorageItem, setLocalStorageItem } from "./hooks/useLocalStorage"; import { randomUUID } from "./lib/utils"; -export const THREAD_GROUPS_STORAGE_KEY = "t3code:thread-groups:v1"; +const THREAD_GROUPS_STORAGE_KEY = "t3code:thread-groups:v1"; const ThreadGroup = Schema.Struct({ id: Schema.String, name: Schema.String }); export type ThreadGroup = typeof ThreadGroup.Type; @@ -53,11 +60,35 @@ export function resolveThreadGroupId( return existingGroupId(state, entry?.groupId); } +export function splitThreadsByGroup< + T extends { + readonly environmentId: EnvironmentId; + readonly id: ThreadId; + readonly projectId: ProjectId; + readonly createdAt: string; + }, +>(threads: readonly T[], state: ThreadGroupsState) { + const byGroupId = new Map(state.groups.map((group) => [group.id, [] as T[]])); + const ungrouped: T[] = []; + for (const thread of threads) { + const groupId = resolveThreadGroupId(state, { + threadKey: scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), + projectKey: scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)), + createdAt: thread.createdAt, + }); + (groupId === null ? ungrouped : byGroupId.get(groupId)!).push(thread); + } + return { + ungrouped, + groups: state.groups.map((group) => ({ group, threads: byGroupId.get(group.id)! })), + }; +} + export function createThreadGroup(state: ThreadGroupsState, group: ThreadGroup): ThreadGroupsState { return { ...state, groups: [...state.groups, group] }; } -export function renameThreadGroup( +function renameThreadGroup( state: ThreadGroupsState, groupId: string, name: string, From bf8c7b3558a252d186c3cb0d8cb32ba11bee5830 Mon Sep 17 00:00:00 2001 From: CarsonJF Date: Mon, 26 Oct 2026 20:39:48 -0400 Subject: [PATCH 003/141] feat(web): set a project's default thread group in project settings New threads in the project start in the chosen group; threads created before the change keep their group. Logical projects with several members show Mixed until a value is picked. Co-Authored-By: Claude Opus 5.5 --- .../settings/ProjectDefaultGroupRow.tsx | 63 +++++++++++++++++++ .../settings/ProjectSettingsPanel.tsx | 2 + 2 files changed, 65 insertions(+) create mode 100644 apps/web/src/components/settings/ProjectDefaultGroupRow.tsx diff --git a/apps/web/src/components/settings/ProjectDefaultGroupRow.tsx b/apps/web/src/components/settings/ProjectDefaultGroupRow.tsx new file mode 100644 index 000000000000..dec48a0fe333 --- /dev/null +++ b/apps/web/src/components/settings/ProjectDefaultGroupRow.tsx @@ -0,0 +1,63 @@ +import { scopedProjectKey } from "@t3tools/client-runtime/environment"; +import type { ScopedProjectRef } from "@t3tools/contracts"; + +import { + projectDefaultGroupId, + threadGroupActions, + useThreadGroupsStore, +} from "../../threadGroupsStore"; +import { createThreadGroupFromPrompt } from "../ThreadGroupNameDialog"; +import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select"; +import { SettingsRow } from "./settingsLayout"; + +const NO_GROUP = "none"; +const NEW_GROUP = "new"; + +export function ProjectDefaultGroupRow({ + memberProjectRefs, +}: { + memberProjectRefs: readonly ScopedProjectRef[]; +}) { + const state = useThreadGroupsStore(); + const projectKeys = memberProjectRefs.map(scopedProjectKey); + const defaults = new Set(projectKeys.map((key) => projectDefaultGroupId(state, key))); + const current = defaults.size === 1 ? ([...defaults][0] ?? NO_GROUP) : null; + const labels = new Map(state.groups.map((group) => [group.id, group.name])); + return ( + { + if (value === NEW_GROUP) { + void createThreadGroupFromPrompt().then((groupId) => { + if (groupId !== null) threadGroupActions.setProjectDefault(projectKeys, groupId); + }); + } else if (value !== null) { + threadGroupActions.setProjectDefault(projectKeys, value === NO_GROUP ? null : value); + } + }} + > + + + {(value: string | null) => + value === null ? "Mixed" : (labels.get(value) ?? "No group") + } + + + + No group + {state.groups.map((group) => ( + + {group.name} + + ))} + New group… + + + } + /> + ); +} diff --git a/apps/web/src/components/settings/ProjectSettingsPanel.tsx b/apps/web/src/components/settings/ProjectSettingsPanel.tsx index c4ed6e4ff33b..e1907d350057 100644 --- a/apps/web/src/components/settings/ProjectSettingsPanel.tsx +++ b/apps/web/src/components/settings/ProjectSettingsPanel.tsx @@ -53,6 +53,7 @@ import { ProjectFaviconPickerDialog, } from "./ProjectFaviconPickerDialog"; import { ProjectActionsSettings } from "./ProjectActionsSettings"; +import { ProjectDefaultGroupRow } from "./ProjectDefaultGroupRow"; import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings"; import { ProjectRepositoriesSettings } from "./ProjectRepositoriesSettings"; import { @@ -690,6 +691,7 @@ function ProjectDetail({ /> ) : null} + From d8e6bdfe26f86431c28ab5f64a567bd0a8075224 Mon Sep 17 00:00:00 2001 From: CarsonJF Date: Mon, 26 Oct 2026 22:42:56 -0400 Subject: [PATCH 004/141] ci(custom): rebase onto upstream nightlies and publish a Windows build Fork-only pipeline: rebases custom onto the newest upstream nightly tag, runs focused checks, builds the Windows x64 NSIS installer with the update feed pointed at this fork, and publishes it as a release. Lives only in new files so rebases never conflict on it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/custom-nightly.yml | 336 +++++++++++++++++++++++++++ CUSTOM.md | 58 +++++ 2 files changed, 394 insertions(+) create mode 100644 .github/workflows/custom-nightly.yml create mode 100644 CUSTOM.md diff --git a/.github/workflows/custom-nightly.yml b/.github/workflows/custom-nightly.yml new file mode 100644 index 000000000000..00d0179c69a8 --- /dev/null +++ b/.github/workflows/custom-nightly.yml @@ -0,0 +1,336 @@ +# Fork-only pipeline: rebase `custom` onto the newest upstream nightly and ship +# a Windows x64 build of it. See CUSTOM.md. Upstream's release workflows are +# disabled on this fork; this file must stay the only active workflow. +name: Custom nightly + +on: + schedule: + - cron: "17 */3 * * *" + workflow_dispatch: + inputs: + upstream_tag: + description: "Upstream nightly tag to build (default: newest published)" + required: false + type: string + force: + description: "Rebuild and replace the release even if one exists for this tag" + required: false + default: false + type: boolean + +concurrency: + group: custom-nightly + cancel-in-progress: false + +permissions: + contents: read + +env: + UPSTREAM_REPO: pingdotgg/t3code + BRANCH: custom + +jobs: + prepare: + name: Rebase and check + if: github.repository != 'pingdotgg/t3code' + runs-on: ubuntu-latest + timeout-minutes: 45 + permissions: + contents: read + actions: write + outputs: + skip: ${{ steps.resolve.outputs.skip }} + upstream_tag: ${{ steps.resolve.outputs.upstream_tag }} + version: ${{ steps.resolve.outputs.version }} + release_tag: ${{ steps.resolve.outputs.release_tag }} + sha: ${{ steps.rebase.outputs.sha }} + failure: ${{ steps.rebase.outputs.failure || steps.checks.outputs.failure }} + env: + GH_TOKEN: ${{ github.token }} + steps: + - id: resolve + name: Resolve newest upstream nightly + env: + INPUT_TAG: ${{ inputs.upstream_tag }} + FORCE: ${{ inputs.force }} + run: | + set -euo pipefail + tag="${INPUT_TAG:-}" + if [[ -z "$tag" ]]; then + # Published releases only, so the Linux CLI archive embedded below exists. + tag="$(gh release list -R "$UPSTREAM_REPO" --exclude-drafts --limit 40 --json tagName -q '.[].tagName' \ + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-nightly\.[0-9]{8}\.[0-9]+$' | head -n 1)" + fi + [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-nightly\.[0-9]{8}\.[0-9]+$ ]] || { echo "Bad upstream tag: '$tag'" >&2; exit 1; } + release_tag="${tag}-custom" + skip=false + if gh release view "$release_tag" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 && [[ "$FORCE" != "true" ]]; then + skip=true + echo "Release $release_tag already exists; nothing to do." + fi + { + echo "upstream_tag=$tag" + echo "version=${tag#v}" + echo "release_tag=$release_tag" + echo "skip=$skip" + } >> "$GITHUB_OUTPUT" + + # Inherited upstream workflows would run (or queue forever on upstream's + # runners) when this job pushes. Re-disable any that upstream adds. + - name: Keep inherited workflows disabled + if: steps.resolve.outputs.skip != 'true' + run: | + set -euo pipefail + gh workflow list -R "$GITHUB_REPOSITORY" --all --json path,state \ + -q '.[] | select(.state == "active" and .path != ".github/workflows/custom-nightly.yml") | .path' \ + | while read -r path; do + echo "Disabling $path" + gh workflow disable "$(basename "$path")" -R "$GITHUB_REPOSITORY" + done + + - name: Checkout + if: steps.resolve.outputs.skip != 'true' + uses: actions/checkout@v6 + with: + ref: ${{ env.BRANCH }} + fetch-depth: 0 + ssh-key: ${{ secrets.CUSTOM_NIGHTLY_DEPLOY_KEY }} + sparse-checkout: | + /* + !/.repos/ + sparse-checkout-cone-mode: false + + # custom = + our commits. Our commits are whatever + # custom has that upstream main does not; nothing is pushed on conflict. + - id: rebase + name: Rebase onto the upstream nightly + if: steps.resolve.outputs.skip != 'true' + env: + TAG: ${{ steps.resolve.outputs.upstream_tag }} + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config rerere.enabled true + git config rerere.autoupdate true + git remote add upstream "/${UPSTREAM_REPO}.git" + git fetch --no-tags upstream main "+refs/tags/${TAG}:refs/tags/${TAG}" + tag_sha="$(git rev-parse "${TAG}^{commit}")" + old_tip="$(git rev-parse HEAD)" + old_base="$(git merge-base HEAD upstream/main)" + echo "old_tip=$old_tip" >> "$GITHUB_OUTPUT" + echo "Our commits:"; git log --oneline "$old_base..HEAD" + if ! git rebase --onto "$tag_sha" "$old_base" HEAD; then + { + echo "failure<> "$GITHUB_OUTPUT" + git rebase --abort + exit 1 + fi + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "tag_sha=$tag_sha" >> "$GITHUB_OUTPUT" + + - name: Setup Vite+ + if: steps.resolve.outputs.skip != 'true' + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: true + run-install: false + + # Format, lint, knip, typecheck of affected packages, and tests beside + # our changed files, measured against the upstream nightly commit. + - id: checks + name: Focused checks for our commits + if: steps.resolve.outputs.skip != 'true' + env: + TAG_SHA: ${{ steps.rebase.outputs.tag_sha }} + run: | + set -euo pipefail + vp install + # Web tests beside our changes run in headless Chromium. + node apps/web/node_modules/playwright/cli.js install --with-deps --only-shell chromium + if ! vp run check:changed "$TAG_SHA"; then + echo "failure=Focused checks (vp run check:changed) failed after rebasing onto ${TAG_SHA}." >> "$GITHUB_OUTPUT" + exit 1 + fi + + - name: Push custom and mirror main + if: steps.resolve.outputs.skip != 'true' + env: + OLD_TIP: ${{ steps.rebase.outputs.old_tip }} + run: | + set -euo pipefail + git push --force-with-lease="refs/heads/${BRANCH}:${OLD_TIP}" origin "HEAD:refs/heads/${BRANCH}" + git push --force origin "refs/remotes/upstream/main:refs/heads/main" + + build: + name: Build Windows x64 + needs: [prepare] + if: needs.prepare.outputs.skip == 'false' + runs-on: windows-latest + timeout-minutes: 90 + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.prepare.outputs.version }} + # Feed baked into app-update.yml: this fork's releases, nightly channel. + T3CODE_DESKTOP_UPDATE_REPOSITORY: ${{ github.repository }} + T3CODE_TELEMETRY_CHANNEL: dev + # Optional T3 Connect public config (repo variables); unset disables it. + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }} + T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }} + defaults: + run: + shell: bash + steps: + # actions/checkout's cleanup trips over the .repos gitlinks on Windows. + - name: Checkout + env: + SHA: ${{ needs.prepare.outputs.sha }} + GIT_TERMINAL_PROMPT: "0" + run: | + set -euo pipefail + git init . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --no-tags --depth=1 origin "$SHA" + git sparse-checkout set --no-cone '/*' '!/.repos/' + git -c checkout.workers=0 checkout --detach FETCH_HEAD + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: false + run-install: false + + - name: Install + run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts... + + - name: Build JS bundle + run: | + set -euo pipefail + node scripts/update-release-package-versions.ts "$VERSION" + vp run build:desktop + + # The WSL backend runs the Linux CLI inside the distro; reuse upstream's + # archive for the same nightly (our commits are client-only). + - name: Download upstream Linux CLI archive for WSL + run: gh release download "${{ needs.prepare.outputs.upstream_tag }}" -R "$UPSTREAM_REPO" -p "t3-*-linux-x64.tar.gz" -D wsl-runtime + + - name: Build installer + run: | + set -euo pipefail + vp run dist:desktop:artifact --platform win --target nsis --arch x64 \ + --build-version "$VERSION" --skip-build --keep-stage --verbose \ + --wsl-runtime "$(cygpath -w "$(ls "$PWD"/wsl-runtime/t3-*-linux-x64.tar.gz)")" + tmp="$(cygpath -u "$(node -p 'require("os").tmpdir()')")" + feed="$(ls "$tmp"/t3code-desktop-win-stage-*/app/dist/win-unpacked/resources/app-update.yml | head -n 1)" + cat "$feed" + grep -qx "owner: ${GITHUB_REPOSITORY%/*}" "$feed" + # electron-updater verifies update signatures only when publisherName is set. + if grep -q publisherName "$feed"; then echo "Unsigned build must not set publisherName" >&2; exit 1; fi + ls -la release + + - uses: actions/upload-artifact@v7 + with: + name: desktop-win-x64 + path: | + release/*.exe + release/*.blockmap + release/nightly.yml + if-no-files-found: error + retention-days: 7 + + publish: + name: Publish release + needs: [prepare, build] + runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + contents: write + issues: write + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }} + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + VERSION: ${{ needs.prepare.outputs.version }} + SHA: ${{ needs.prepare.outputs.sha }} + steps: + - uses: actions/download-artifact@v8 + with: + name: desktop-win-x64 + path: dist + + - name: Verify feed manifest + run: | + set -euo pipefail + cat dist/nightly.yml + grep -qx "version: '\?${VERSION}'\?" dist/nightly.yml + url="$(sed -n 's/^ *- url: //p' dist/nightly.yml)" + test -f "dist/$url" + (cd dist && sha256sum ./*) + + # The tag is pushed with the deploy key: GITHUB_TOKEN may not create refs + # to commits that change workflow files. + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ needs.prepare.outputs.sha }} + path: repo + ssh-key: ${{ secrets.CUSTOM_NIGHTLY_DEPLOY_KEY }} + sparse-checkout: /CUSTOM.md + sparse-checkout-cone-mode: false + + - name: Create release + run: | + set -euo pipefail + if gh release view "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + gh release delete "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --cleanup-tag --yes + fi + git -C repo tag -f "$RELEASE_TAG" "$SHA" + git -C repo push -f origin "refs/tags/$RELEASE_TAG" + notes="Upstream nightly [${UPSTREAM_TAG}](https://github.com/${UPSTREAM_REPO}/releases/tag/${UPSTREAM_TAG}) plus the commits on \`custom\` (${SHA:0:12}). Windows x64 only, unsigned." + gh release create "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --verify-tag --prerelease --latest=false \ + --title "T3 Code Nightly ${VERSION} + custom (${SHA:0:12})" --notes "$notes" dist/* + + - name: Close failure issue + run: | + set -euo pipefail + for n in $(gh issue list -R "$GITHUB_REPOSITORY" --state open --search 'in:title "custom-nightly failed"' --json number -q '.[].number'); do + gh issue close "$n" -R "$GITHUB_REPOSITORY" --comment "Fixed: published ${RELEASE_TAG} in ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}." + done + + report_failure: + name: Report failure + needs: [prepare, build, publish] + if: failure() + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + issues: write + env: + GH_TOKEN: ${{ github.token }} + DETAIL: ${{ needs.prepare.outputs.failure }} + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + RESULTS: "prepare=${{ needs.prepare.result }} build=${{ needs.build.result }} publish=${{ needs.publish.result }}" + steps: + - name: Open or update the failure issue + run: | + set -euo pipefail + run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + body="$(printf '%s\n\n%s\n\n%s\n\n%s\n' \ + "Custom nightly for upstream \`${UPSTREAM_TAG:-unknown}\` failed: ${run_url}" \ + "Jobs: ${RESULTS}" \ + "${DETAIL:-See the run log for details.}" \ + "Nothing was published and \`custom\` was not pushed unless the build or publish step failed afterwards. See CUSTOM.md for how to resolve.")" + n="$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search 'in:title "custom-nightly failed"' --json number -q '.[0].number')" + if [[ -n "$n" ]]; then + gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "$body" + else + gh issue create -R "$GITHUB_REPOSITORY" --title "custom-nightly failed" --body "$body" + fi diff --git a/CUSTOM.md b/CUSTOM.md new file mode 100644 index 000000000000..9b039efecff9 --- /dev/null +++ b/CUSTOM.md @@ -0,0 +1,58 @@ +# CarsonJF/t3code custom build + +This fork ships **latest upstream nightly + the commits on `custom`** as a Windows x64 +installer that auto-updates from this fork's releases. + +## Branches + +- `main`: pure mirror of `pingdotgg/t3code` main. Never commit to it; the pipeline force-updates it. +- `custom` (default branch): the upstream nightly tag plus our commits. Our commits are + everything on `custom` that is not on upstream main. CI files live only in new files + (`.github/workflows/custom-nightly.yml`, this file), so rebases never conflict on them. + +## How the pipeline works + +`.github/workflows/custom-nightly.yml` runs every 3 hours (and on demand): + +1. Finds the newest published upstream `v*-nightly.*` release. If this fork already has a + release `-custom`, it stops. +2. Rebases our commits onto that tag (`git rebase --onto `), runs + `vp run check:changed ` (format, lint, knip, affected typecheck, tests beside our + changes), then pushes `custom` with `--force-with-lease` and mirrors `main`. +3. Builds the NSIS installer on `windows-latest` with the upstream version number, the + update feed pointed at this fork (`T3CODE_DESKTOP_UPDATE_REPOSITORY`), `dev` telemetry, + and upstream's Linux CLI archive of the same nightly as the WSL runtime. +4. Publishes a prerelease with the `.exe`, `.exe.blockmap` and `nightly.yml`. + +Any failure opens (or comments on) one issue titled `custom-nightly failed`; a later +successful run closes it. A conflicted rebase is aborted, so `custom` is never pushed +half-rebased. Pushes use the `CUSTOM_NIGHTLY_DEPLOY_KEY` secret (a write deploy key), because +`GITHUB_TOKEN` cannot push commits that touch workflow files. + +The job also re-disables every other workflow on the fork, so inherited upstream +workflows never run here. + +## Pause / resume + + gh workflow disable custom-nightly.yml -R CarsonJF/t3code + gh workflow enable custom-nightly.yml -R CarsonJF/t3code + +Run now: `gh workflow run custom-nightly.yml -R CarsonJF/t3code` (add `-f force=true` to +rebuild an existing release, `-f upstream_tag=v...` to pick a tag). + +## Resolving a rebase conflict + + git fetch upstream --tags && git fetch origin + git switch custom && git reset --hard origin/custom + git rebase --onto $(git merge-base HEAD upstream/main) + # fix conflicts, git add, git rebase --continue + git push --force-with-lease origin custom + gh workflow run custom-nightly.yml -R CarsonJF/t3code + +## Installing the first build + +Download `T3-Code--x64.exe` from the newest release and run it. It installs over +the stock T3 Code (Nightly) (same app id, product name and data directory), keeping all +data and settings. SmartScreen warns because it is unsigned: More info, then Run anyway. +From then on the app updates from this fork's releases. Reinstalling a stock installer +switches updates back to upstream. From cdad7edf0413c0f54e90a10bf82251814f792cad Mon Sep 17 00:00:00 2001 From: CarsonJF Date: Tue, 27 Oct 2026 01:34:47 -0400 Subject: [PATCH 005/141] feat(web): color and icon for thread groups Groups get an optional color and icon, set in a combined New/Edit group dialog (reuses the project icon picker). The sidebar header shows the icon or a color dot, a tinted background, and a colored label. Co-Authored-By: Claude Sonnet 5.5 --- apps/web/src/components/ThreadGroupIcon.tsx | 66 ++++++++++++++++ .../src/components/ThreadGroupNameDialog.tsx | 79 ++++++++++++++++--- .../sidebar/SidebarThreadGroupHeader.tsx | 32 +++++--- apps/web/src/threadGroupsStore.test.ts | 16 ++++ apps/web/src/threadGroupsStore.ts | 36 ++++++--- 5 files changed, 199 insertions(+), 30 deletions(-) create mode 100644 apps/web/src/components/ThreadGroupIcon.tsx diff --git a/apps/web/src/components/ThreadGroupIcon.tsx b/apps/web/src/components/ThreadGroupIcon.tsx new file mode 100644 index 000000000000..ae22a0007418 --- /dev/null +++ b/apps/web/src/components/ThreadGroupIcon.tsx @@ -0,0 +1,66 @@ +import { FolderCodeIcon } from "lucide-react"; +import { createElement, lazy, Suspense } from "react"; + +import { projectIconColorClassName } from "../projectIconColors"; +import type { ThreadGroup } from "../threadGroupsStore"; +import { cn } from "~/lib/utils"; +import { ProjectMonogram } from "./ProjectMonogram"; + +const LucideGroupIcon = lazy(() => + import("../lib/lucideIconByName").then(({ lucideIconByName }) => ({ + default: function LucideGroupIcon(props: { name: string; className: string }) { + return createElement(lucideIconByName(props.name) ?? FolderCodeIcon, { + className: props.className, + }); + }, + })), +); + +export function threadGroupColorClassName(group: Pick): string | null { + return group.color ? projectIconColorClassName(group.color) : null; +} + +/** The group's icon, or a color dot when it only has a color. */ +export function ThreadGroupIcon({ group }: { group: Pick }) { + const { icon } = group; + const colorClassName = threadGroupColorClassName(group); + if (icon?.kind === "emoji") { + return ( + + ); + } + if (icon?.kind === "monogram") { + return ( + + ); + } + if (icon?.kind === "lucide") { + const className = cn("size-3.5", colorClassName ?? projectIconColorClassName(icon.color)); + return ( + + ); + } + if (colorClassName) { + return ( +