Skip to content
Open
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
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {{started} Review-Leitfaden gestartet} other {{started} Review-Leitfäden gestartet}}",
"5dce4a54eaffeccf": "{started, plural, one {Versucht, {started} Review-Leitfaden zu starten} other {Versucht, {started} Review-Leitfäden zu starten}}",
"420bea546d5f8802": "Thread kopiert",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Thread konnte nicht kopiert werden",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR-Link kopiert",
"1b88f6a5e9fdeea7": "PR-Link konnte nicht kopiert werden",
"b063ecd06059857f": "Wird komprimiert, bevor der Cache abläuft…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {Started {started} review guide} other {Started {started} review guides}}",
"5dce4a54eaffeccf": "{started, plural, one {Tried to start {started} review guide} other {Tried to start {started} review guides}}",
"420bea546d5f8802": "Thread copied",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Failed to copy thread",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR link copied",
"1b88f6a5e9fdeea7": "Failed to copy PR link",
"b063ecd06059857f": "Compacting before the cache expires…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {Inició {started} guía de revisión} other {Inició {started} guías de revisión}}",
"5dce4a54eaffeccf": "{started, plural, one {Intentó iniciar {started} guía de revisión} other {Intentó iniciar {started} guías de revisión}}",
"420bea546d5f8802": "Hilo copiado",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "No se pudo copiar el hilo",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "Enlace de la PR copiado",
"1b88f6a5e9fdeea7": "No se pudo copiar el enlace de la PR",
"b063ecd06059857f": "Compactando antes de que caduque la caché…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {{started} guide de revue lancé} other {{started} guides de revue lancés}}",
"5dce4a54eaffeccf": "{started, plural, one {Tentative de lancer {started} guide de revue} other {Tentative de lancer {started} guides de revue}}",
"420bea546d5f8802": "Fil copié",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Échec de la copie du fil",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "Lien de la PR copié",
"1b88f6a5e9fdeea7": "Échec de la copie du lien de la PR",
"b063ecd06059857f": "Compactage avant l’expiration du cache…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, other {{started} 件のレビューガイドを開始しました}}",
"5dce4a54eaffeccf": "{started, plural, other {{started} 件のレビューガイドを開始しようとしました}}",
"420bea546d5f8802": "スレッドをコピーしました",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "スレッドをコピーできませんでした",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR のリンクをコピーしました",
"1b88f6a5e9fdeea7": "PR のリンクをコピーできませんでした",
"b063ecd06059857f": "キャッシュの期限切れ前に圧縮しています…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, other {검토 가이드 {started}개 시작함}}",
"5dce4a54eaffeccf": "{started, plural, other {검토 가이드 {started}개 시작 시도함}}",
"420bea546d5f8802": "스레드 복사됨",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "스레드를 복사하지 못했습니다",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR 링크 복사됨",
"1b88f6a5e9fdeea7": "PR 링크를 복사하지 못했습니다",
"b063ecd06059857f": "캐시가 만료되기 전에 압축하는 중…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {Iniciou {started} guia de revisão} other {Iniciou {started} guias de revisão}}",
"5dce4a54eaffeccf": "{started, plural, one {Tentou iniciar {started} guia de revisão} other {Tentou iniciar {started} guias de revisão}}",
"420bea546d5f8802": "Thread copiada",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Falha ao copiar a thread",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "Link do PR copiado",
"1b88f6a5e9fdeea7": "Falha ao copiar o link do PR",
"b063ecd06059857f": "Compactando antes de o cache expirar…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {Начато {started} руководство по ревью} few {Начато {started} руководства по ревью} many {Начато {started} руководств по ревью} other {Начато {started} руководства по ревью}}",
"5dce4a54eaffeccf": "{started, plural, one {Попытка начать {started} руководство по ревью} few {Попытка начать {started} руководства по ревью} many {Попытка начать {started} руководств по ревью} other {Попытка начать {started} руководства по ревью}}",
"420bea546d5f8802": "Тред скопирован",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Не удалось скопировать тред",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "Ссылка на PR скопирована",
"1b88f6a5e9fdeea7": "Не удалось скопировать ссылку на PR",
"b063ecd06059857f": "Сжатие до истечения кеша…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {Startade {started} granskningsguide} other {Startade {started} granskningsguider}}",
"5dce4a54eaffeccf": "{started, plural, one {Försökte starta {started} granskningsguide} other {Försökte starta {started} granskningsguider}}",
"420bea546d5f8802": "Tråden kopierades",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Det gick inte att kopiera tråden",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR-länken kopierades",
"1b88f6a5e9fdeea7": "Det gick inte att kopiera PR-länken",
"b063ecd06059857f": "Komprimerar innan cachen går ut…",
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, other {已开始 {started} 份审查导览}}",
"5dce4a54eaffeccf": "{started, plural, other {尝试开始 {started} 份审查导览}}",
"420bea546d5f8802": "已复制会话",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "无法复制会话",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "已复制 PR 链接",
"1b88f6a5e9fdeea7": "无法复制 PR 链接",
"b063ecd06059857f": "正在缓存过期前压缩…",
Expand Down
34 changes: 34 additions & 0 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { describe, expect, it } from "vite-plus/test";
import * as Cause from "effect/Cause";
import { AsyncResult } from "effect/reactivity";
import {
buildBulkCopyContextMenuItem,
bulkThreadCopyText,
shouldCreateNewThreadInCurrentProject,
deleteSelectedThreadEntries,
getFallbackThreadIdAfterDelete,
Expand Down Expand Up @@ -61,6 +63,38 @@ import {

const localEnvironmentId = EnvironmentId.make("environment-local");

describe("bulkThreadCopyText", () => {
const entries = [
{ id: "t1", title: "Lead gen", branch: "t3/ops", path: "/repo/.t3/ops" },
{ id: "t2", title: "Sales\ncalls", branch: "t3/ops", path: "/repo/.t3/ops" },
{ id: "t3", title: "Lead gen", branch: null, path: "/repo" },
];

it.each([
["copy-thread-id", "t1\nt2\nt3", 3, "thread IDs"],
["copy-title", "Lead gen\nSales calls\nLead gen", 3, "titles"],
["copy-branch", "t3/ops", 1, "branches"],
["copy-path", "/repo/.t3/ops\n/repo", 2, "paths"],
] as const)(
"copies %s one per line, listing shared worktrees once",
(action, text, count, noun) => {
expect(bulkThreadCopyText(entries, action)).toEqual({ text, count, noun });
},
);

it("disables thread chips past the paste limit", () => {
const many = Array.from({ length: 201 }, (_, index) => ({ ...entries[2]!, id: `t${index}` }));
const threads = (selection: typeof entries) =>
buildBulkCopyContextMenuItem(selection).children?.find((item) => item.id === "copy-thread");
expect(threads(entries)?.disabled).toBeUndefined();
expect(threads(many)).toMatchObject({ disabled: true, label: "Threads (up to 200)" });
});

it("copies nothing when no selected thread has the value", () => {
expect(bulkThreadCopyText([entries[2]!], "copy-branch")).toBeNull();
});
});

describe("deleteSelectedThreadEntries", () => {
const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;
const success = AsyncResult.success(undefined);
Expand Down
63 changes: 63 additions & 0 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from "@t3tools/client-runtime/state/thread-search";
import { foldSearchQuery, rankSearchItems, scoreThreadSearch } from "@t3tools/shared/paletteSearch";
import {
COMPOSER_CONTEXT_MAX_RECORDS,
type ContextMenuItem,
type EnvironmentId,
type ResolvedKeybindingsConfig,
Expand Down Expand Up @@ -634,6 +635,68 @@ export function buildBulkUnpinContextMenuItem(input: {
return { id: "unpin", label: m(msg("Unpin ({count})", { count: input.pinnedCount })) };
}

export type BulkThreadCopyAction =
| "copy-path"
| "copy-branch"
| "copy-thread"
| "copy-title"
| "copy-thread-id";

export interface BulkThreadCopyEntry {
readonly id: string;
readonly title: string;
readonly branch: string | null;
readonly path: string | null;
}

export function buildBulkCopyContextMenuItem(
entries: readonly BulkThreadCopyEntry[],
): ContextMenuItem<"copy" | BulkThreadCopyAction> {
return {
id: "copy",
label: m(msg("Copy ({count})", { count: entries.length })),
separatorBefore: true,
children: [
...(entries.some((entry) => entry.path)
? [{ id: "copy-path" as const, label: m(msg("Paths")) }]
: []),
...(entries.some((entry) => entry.branch)
? [{ id: "copy-branch" as const, label: m(msg("Branches")) }]
: []),
// More records than this fail to decode on paste, so they would not come back as chips.
entries.length > COMPOSER_CONTEXT_MAX_RECORDS
? {
id: "copy-thread" as const,
label: m(msg("Threads (up to {count})", { count: COMPOSER_CONTEXT_MAX_RECORDS })),
disabled: true,
}
: { id: "copy-thread" as const, label: m(msg("Threads")) },
{ id: "copy-title", label: m(msg("Titles")) },
{ id: "copy-thread-id", label: m(msg("Thread IDs")) },
],
};
}

const BULK_COPY_FIELDS = {
"copy-path": { field: "path", noun: "paths" },
"copy-branch": { field: "branch", noun: "branches" },
"copy-title": { field: "title", noun: "titles" },
"copy-thread-id": { field: "id", noun: "thread IDs" },
} as const;

/** One line per thread; branches and paths shared by several threads appear once. */
export function bulkThreadCopyText(
entries: readonly BulkThreadCopyEntry[],
action: keyof typeof BULK_COPY_FIELDS,
): { text: string; count: number; noun: string } | null {
const { field, noun } = BULK_COPY_FIELDS[action];
const values = entries.flatMap((entry) =>
field === "title" ? entry.title.replace(/\s*[\r\n]+\s*/g, " ") : (entry[field] ?? []),
);
const lines = field === "branch" || field === "path" ? [...new Set(values)] : values;
return lines.length === 0 ? null : { text: lines.join("\n"), count: lines.length, noun };
}

export interface ThreadStatusPill {
/** A `msg()` string; render it through `useMessages()`. */
label: string;
Expand Down
72 changes: 71 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { discardComposerDraft } from "../lib/discardComposerDraft";
import { requestCustomSnooze } from "./CustomSnoozeDialog";
import { useAtomValue } from "@effect/atom-react";
import * as Arr from "effect/Array";
import * as Option from "effect/Option";
import { Atom } from "effect/reactivity";
import * as Schema from "effect/Schema";
Expand Down Expand Up @@ -185,8 +186,10 @@ import {
filterSidebarV2VisibleThreads,
groupSidebarThreadsByProject,
sidebarFolderExpansionKeys,
buildBulkCopyContextMenuItem,
buildBulkTitleRegenerationContextMenuItem,
buildBulkUnpinContextMenuItem,
bulkThreadCopyText,
deleteSelectedThreadEntries,
filterSidebarProjectScopeItems,
firstValidTimestampMs,
Expand Down Expand Up @@ -241,7 +244,10 @@ import {
import { stackedThreadToast, toastManager } from "./ui/toast";
import { titleRegenerationToast } from "./threadTitleRegenerationToast";
import { copyThreadReference } from "../lib/copyThreadReference";
import { threadChipCopyTarget } from "@t3tools/client-runtime/thread-reference";
import {
threadChipCopyTarget,
threadChipsCopyTarget,
} from "@t3tools/client-runtime/thread-reference";
import { Button } from "./ui/button";
import { isProjectPinShortcut, ProjectPinButton } from "./ProjectPinButton";
import {
Expand Down Expand Up @@ -988,6 +994,40 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
);
},
});
const { copyToClipboard: copyLinesToClipboard } = useCopyToClipboard<{
count: number;
noun: string;
}>({
onCopy: ({ count, noun }) => {
toastManager.add({
type: "success",
title:
noun === "paths"
? gt("{count} paths copied", { count })
: noun === "branches"
? gt("{count} branches copied", { count })
: noun === "titles"
? gt("{count} titles copied", { count })
: gt("{count} thread IDs copied", { count }),
});
},
onError: (error, { noun }) => {
toastManager.add(
stackedThreadToast({
type: "error",
title:
noun === "paths"
? gt("Failed to copy paths")
: noun === "branches"
? gt("Failed to copy branches")
: noun === "titles"
? gt("Failed to copy titles")
: gt("Failed to copy thread IDs"),
description: thrownErrorMessage(error, m) ?? gt("An error occurred."),
}),
);
},
});
const boringSidebarEnabled = useClientSettings((settings) => settings.boringSidebarEnabled);
const folderRowsMultiline = useClientSettings((settings) => settings.boringSidebarMultilineRows);
const newThreadContext = useHandleNewThread();
Expand Down Expand Up @@ -2337,6 +2377,15 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const unpinMenuItem = buildBulkUnpinContextMenuItem({
pinnedCount: pinnedSelectedThreads.length,
});
const copyEntries = selectedThreads.map((thread) => ({
id: thread.id,
title: thread.title,
branch: thread.branch,
path:
thread.worktreePath ??
projectByKey.get(`${thread.environmentId}:${thread.projectId}`)?.workspaceRoot ??
null,
}));
// Presets sync across environments, so the first selected thread's stand for all.
const menuOpenedAt = new Date();
const snoozePresets = resolveSnoozePresets(
Expand Down Expand Up @@ -2389,6 +2438,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
]
: []),
{ id: "mark-unread", label: gt("Mark unread ({count})", { count }) },
buildBulkCopyContextMenuItem(copyEntries),

{
id: "delete",
label: gt("Delete ({count})", { count }),
Expand All @@ -2401,6 +2452,25 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
),
);
if (clicked._tag === "Failure" || clicked.value === null) return;
switch (clicked.value) {
case "copy-thread": {
const chips = selectedThreads.map((thread) => ({
threadRef: scopeThreadRef(thread.environmentId, thread.id),
title: thread.title,
}));
if (Arr.isReadonlyArrayNonEmpty(chips))
void copyThreadReference(threadChipsCopyTarget(chips, configuredHostedAppUrl(), m));
return;
}
case "copy-path":
case "copy-branch":
case "copy-title":
case "copy-thread-id": {
const copy = bulkThreadCopyText(copyEntries, clicked.value);
if (copy) copyLinesToClipboard(copy.text, copy);
return;
}
}
const actionTargets =
clicked.value === "unpin"
? pinnedSelectedThreads
Expand Down
17 changes: 16 additions & 1 deletion apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@
"672850007e49cfb6": "{started, plural, one {{started} Review-Leitfaden gestartet} other {{started} Review-Leitfäden gestartet}}",
"5dce4a54eaffeccf": "{started, plural, one {Versucht, {started} Review-Leitfaden zu starten} other {Versucht, {started} Review-Leitfäden zu starten}}",
"420bea546d5f8802": "Thread kopiert",
"ff21e10fe80fe57c": "{count} threads copied",
"2efb2dd3bf170f67": "Thread konnte nicht kopiert werden",
"ee8ae13545717b0e": "Failed to copy threads",
"6c03545936b55e0b": "PR-Link kopiert",
"1b88f6a5e9fdeea7": "PR-Link konnte nicht kopiert werden",
"b063ecd06059857f": "Wird komprimiert, bevor der Cache abläuft…",
Expand Down Expand Up @@ -2346,6 +2348,12 @@
"e7a50ab49cdfd076": "Wird neu erzeugt… ({count})",
"6523a0ca24b57fde": "Titel neu erzeugen ({count})",
"96adc8bf3106015d": "Loslösen ({count})",
"4aa20e259aa64ba9": "Copy ({count})",
"52c19ac19b08996b": "Paths",
"10e3b1efa85ed4b3": "Branches",
"7204fddf3be3612e": "Threads (up to {count})",
"07046e54864597e8": "Titles",
"ba72d92f88fdcfaa": "Thread IDs",
"ae7ca1b255c0177f": "Genehmigung ausstehend",
"a28d4938d473c33f": "Wartet auf Eingabe",
"c7c6c2345a741768": "Gastanfrage",
Expand All @@ -2358,6 +2366,14 @@
"e54720cac68f2adb": "Alle Projekte",
"ac47f86df1c31a4a": "Branch konnte nicht kopiert werden",
"4e6305459e784fea": "Thread-ID konnte nicht kopiert werden",
"7532a3cdf9b577a8": "{count} paths copied",
"b36e064c1ab0c50f": "{count} branches copied",
"d88c203698875573": "{count} titles copied",
"88ddfe0ade21a3de": "{count} thread IDs copied",
"e1ae0a8aaa41b49f": "Failed to copy paths",
"ffb2223d5cc4f94b": "Failed to copy branches",
"33fc222ddcd9d95d": "Failed to copy titles",
"80f13cf5599344f1": "Failed to copy thread IDs",
"5a79b7c910831c76": "Der Thread-Titel darf nicht leer sein",
"5c14b37b13312503": "Thread konnte nicht umbenannt werden",
"fc97f746bdabe59f": "Thread konnte nicht erledigt werden",
Expand Down Expand Up @@ -11252,7 +11268,6 @@
"81f82840d9589bc9": "Neue Worktrees starten vom Remote auf Standard zurücksetzen",
"f68e05c50f67ab91": "Neue Worktrees standardmäßig vom Remote starten",
"9fe97e290e08f82f": "Erstellung",
"10e3b1efa85ed4b3": "Branches",
"eb61b42f989896b8": "{domains} und {last}",
"fa338b04cd05c0cf": "{count, plural, one {{domains} und {count} weitere} other {{domains} und {count} weitere}}",
"f37c0766ca212865": "Niedrig",
Expand Down
Loading
Loading