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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useAtomValue } from "@effect/atom-react";
import type { StaticScreenProps } from "@react-navigation/native";
import {
hasIssueTrackerTeams,
issueTrackerBindings,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
Expand Down Expand Up @@ -167,6 +168,7 @@ export function SettingsIssueTrackerRouteScreen({
}: StaticScreenProps<{
readonly environmentId: EnvironmentId;
readonly tracker: string;
readonly accountId?: string;
}>) {
const gt = useGT();
const messages = useMessages();
Expand All @@ -176,17 +178,25 @@ export function SettingsIssueTrackerRouteScreen({
issueTrackerEnvironment.connections({ environmentId, input: {} }),
);
const canEdit = useAtomValue(issueTrackerEnvironment.connect.permissionAtom(environmentId));
const tracker = query.data?.trackers.find((entry) => entry.tracker === route.params.tracker);
const tracker = [...(query.data?.trackers ?? []), ...(query.data?.accounts ?? [])].find(
(entry) => entry.tracker === route.params.tracker && entry.accountId === route.params.accountId,
);
const disabled = !canWrite || !canEdit;
const usable = tracker?.connected === true && tracker.account !== null;
const canAddAccount =
tracker !== undefined &&
route.params.accountId === undefined &&
(tracker.connected ||
(query.data?.accounts ?? []).some((account) => account.tracker === tracker.tracker)) &&
environment?.serverConfig.environment.capabilities.issueTrackerAccounts === true;
return (
<DetailPage title={tracker?.displayName ?? gt("Issue tracker")}>
{!environment || !tracker ? (
<Unavailable />
) : (
<>
<Text selectable className="px-2 text-sm text-foreground-muted">
{issueTrackerSummary(tracker, query.data?.bindings ?? {}, messages)}
{issueTrackerSummary(tracker, issueTrackerBindings(query.data), messages)}
</Text>
<SettingsSection title={tracker.credential.label}>
<IssueTrackerCredentialForm
Expand All @@ -195,7 +205,7 @@ export function SettingsIssueTrackerRouteScreen({
disabled={disabled}
/>
</SettingsSection>
{usable && hasIssueTrackerTeams(tracker, query.data?.bindings ?? {}) ? (
{usable && hasIssueTrackerTeams(tracker, issueTrackerBindings(query.data)) ? (
<SettingsSection
title={gt("Projects")}
footer={gt(
Expand All @@ -206,13 +216,28 @@ export function SettingsIssueTrackerRouteScreen({
<IssueTrackerProjectRows
environmentId={environmentId}
tracker={tracker}
bindings={query.data?.bindings ?? {}}
bindings={issueTrackerBindings(query.data)}
refreshing={query.isPending}
refreshFailed={query.error !== null}
disabled={disabled}
/>
</SettingsSection>
) : null}
{canAddAccount ? (
<SettingsSection
title={gt("Another account")}
footer={gt("Connect a second {tracker} workspace or user.", {
tracker: tracker.displayName,
})}
>
<IssueTrackerCredentialForm
environmentId={environmentId}
tracker={tracker}
disabled={disabled}
addAccount
/>
</SettingsSection>
) : null}
</>
)}
</DetailPage>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
boundIssueTrackerScopes,
issueTrackerBindingFor,
issueTrackerBindings,
issueTrackerScopeOptions,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
Expand Down Expand Up @@ -80,7 +81,11 @@ function EnvironmentTrackers(props: {
const query = useEnvironmentQuery(
issueTrackerEnvironment.connections({ environmentId, input: {} }),
);
const trackers = query.data?.trackers ?? [];
const firstAccounts = query.data?.trackers ?? [];
const trackers = firstAccounts.flatMap((tracker) => [
tracker,
...(query.data?.accounts ?? []).filter((account) => account.tracker === tracker.tracker),
]);
if (trackers.length === 0) {
return query.error ? (
<SettingsSection title={props.title} footer={query.error}>
Expand All @@ -94,16 +99,21 @@ function EnvironmentTrackers(props: {
<SettingsSection title={props.title}>
{trackers.map((tracker, index) => (
<SettingsProviderRow
key={tracker.tracker}
key={`${tracker.tracker}-${tracker.accountId ?? ""}`}
icon={<IssueTrackerMark tracker={tracker.tracker} />}
label={tracker.displayName}
description={issueTrackerSummary(tracker, query.data?.bindings ?? {}, messages)}
label={
tracker.workspace
? `${tracker.displayName} · ${tracker.workspace}`
: tracker.displayName
}
description={issueTrackerSummary(tracker, issueTrackerBindings(query.data), messages)}
ready={tracker.connected && tracker.account !== null}
separated={index > 0}
onPress={() =>
navigation.navigate("SettingsIssueTracker", {
environmentId,
tracker: tracker.tracker,
...(tracker.accountId === undefined ? {} : { accountId: tracker.accountId }),
})
}
/>
Expand Down Expand Up @@ -133,6 +143,8 @@ export function IssueTrackerCredentialForm(props: {
readonly environmentId: EnvironmentId;
readonly tracker: IssueTrackerConnection;
readonly disabled: boolean;
/** Saves the credential as a new account instead of replacing this one's. */
readonly addAccount?: boolean;
}) {
const gt = useGT();
const { environmentId, tracker } = props;
Expand All @@ -143,7 +155,12 @@ export function IssueTrackerCredentialForm(props: {
const submit = async (token: string | null) => {
setBusy(true);
setFailure(null);
const result = await connect({ environmentId, input: { tracker: tracker.tracker, token } });
const result = await connect({
environmentId,
input: props.addAccount
? { tracker: tracker.tracker, token, addAccount: true }
: { tracker: tracker.tracker, accountId: tracker.accountId, token },
});
setBusy(false);
if (!AsyncResult.isFailure(result)) {
setDraft("");
Expand All @@ -154,14 +171,13 @@ export function IssueTrackerCredentialForm(props: {
};
const helpUrl = tracker.credential.helpUrl;
const locked = props.disabled || busy;
const replacing = tracker.connected && !props.addAccount;
return (
<View className="gap-3 p-4">
<SecretTextInput
accessibilityLabel={tracker.credential.label}
placeholder={
tracker.connected
? gt("Saved. Enter a new value to replace it")
: tracker.credential.label
replacing ? gt("Saved. Enter a new value to replace it") : tracker.credential.label
}
value={draft}
onChangeText={setDraft}
Expand All @@ -184,7 +200,7 @@ export function IssueTrackerCredentialForm(props: {
onPress={() => void tryOpenExternalUrl(helpUrl)}
/>
) : null}
{tracker.connected ? (
{replacing ? (
<Button
label={gt("Disconnect")}
tone="secondary"
Expand All @@ -195,7 +211,7 @@ export function IssueTrackerCredentialForm(props: {
) : null}
<Button
label={
tracker.connected
replacing
? gt("Replace", { $context: "verb, replaces a saved credential" })
: gt("Connect", { $context: "verb, connects an issue tracker" })
}
Expand Down Expand Up @@ -231,22 +247,22 @@ export function IssueTrackerProjectRows(props: {
if (held && !saving && !props.refreshing && !props.refreshFailed) setPicks({});
const busy = saving || (held && props.refreshing);
const bound = (projectId: ProjectId) =>
picks[projectId] ?? boundIssueTrackerScopes(tracker.tracker, props.bindings[projectId]);
picks[projectId] ?? boundIssueTrackerScopes(tracker, props.bindings[projectId]);
const change = async (projectId: ProjectId, scopes: ReadonlyArray<string>) => {
if (props.disabled || busy) return;
const binding = issueTrackerBindingFor(tracker.tracker, bound(projectId), scopes);
const binding = issueTrackerBindingFor(tracker, bound(projectId), scopes);
const before = picks[projectId];
setSaving(true);
setPicks((current) => ({
...current,
[projectId]: boundIssueTrackerScopes(tracker.tracker, binding ?? undefined),
[projectId]: boundIssueTrackerScopes(tracker, binding ?? undefined),
}));
const result = await bind({ environmentId, input: { projectId, binding } });
if (result._tag !== "Success") setPicks((current) => ({ ...current, [projectId]: before }));
setSaving(false);
};
return projects.map((project) => {
// A project bound to another tracker keeps that binding; this row shows it unbound.
// A project bound to another tracker or account keeps that binding; this row shows it unbound.
const value = bound(project.id);
const options = issueTrackerScopeOptions(tracker, value);
const toggle = (key: string) =>
Expand Down Expand Up @@ -278,7 +294,11 @@ export function IssueTrackerProjectRows(props: {
attributes: { disabled: locked || !scope.addable },
})),
]}
onPressAction={({ nativeEvent }) => void change(project.id, toggle(nativeEvent.event))}
onPressAction={({ nativeEvent }) => {
// Picking the checked "Not bound" must not clear a binding made with another account.
if (nativeEvent.event !== UNBOUND || value.length > 0)
void change(project.id, toggle(nativeEvent.event));
}}
>
<SettingsRow
icon="folder"
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5462,5 +5462,7 @@
"ad208e3e32c85029": "Alle ausblenden",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Tool-Aufrufe im Chat",
"8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt."
"8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt.",
"99d51127f573296b": "Weiteres Konto",
"8ec2c57414669b79": "Verbinde einen zweiten {tracker}-Workspace oder -Nutzer."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5464,5 +5464,7 @@
"ad208e3e32c85029": "Hide all",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Tool calls in chat",
"8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show."
"8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show.",
"99d51127f573296b": "Another account",
"8ec2c57414669b79": "Connect a second {tracker} workspace or user."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -5456,5 +5456,7 @@
"ad208e3e32c85029": "Ocultar todo",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Llamadas a herramientas en el chat",
"8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran."
"8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran.",
"99d51127f573296b": "Otra cuenta",
"8ec2c57414669b79": "Conecta un segundo espacio de trabajo o usuario de {tracker}."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5456,5 +5456,7 @@
"ad208e3e32c85029": "Tout masquer",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Appels d’outils dans la discussion",
"8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours."
"8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours.",
"99d51127f573296b": "Autre compte",
"8ec2c57414669b79": "Connectez un second espace de travail ou utilisateur {tracker}."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -5437,5 +5437,7 @@
"ad208e3e32c85029": "すべて非表示",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "チャット内のツール呼び出し",
"8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。"
"8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。",
"99d51127f573296b": "別のアカウント",
"8ec2c57414669b79": "2つ目の {tracker} ワークスペースまたはユーザーを接続します。"
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -5441,5 +5441,7 @@
"ad208e3e32c85029": "모두 숨기기",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "채팅의 도구 호출",
"8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다."
"8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다.",
"99d51127f573296b": "다른 계정",
"8ec2c57414669b79": "두 번째 {tracker} 워크스페이스 또는 사용자를 연결합니다."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -5456,5 +5456,7 @@
"ad208e3e32c85029": "Ocultar todas",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Chamadas de ferramentas no chat",
"8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem."
"8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem.",
"99d51127f573296b": "Outra conta",
"8ec2c57414669b79": "Conecte um segundo espaço de trabalho ou usuário do {tracker}."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5536,5 +5536,7 @@
"ad208e3e32c85029": "Скрывать все",
"3328503592789bed": "Дзен",
"856812e7e1fc445e": "Вызовы инструментов в чате",
"8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда."
"8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда.",
"99d51127f573296b": "Другой аккаунт",
"8ec2c57414669b79": "Подключите второе рабочее пространство или пользователя {tracker}."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -5462,5 +5462,7 @@
"ad208e3e32c85029": "Dölj alla",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "Verktygsanrop i chatten",
"8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid."
"8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid.",
"99d51127f573296b": "Ett konto till",
"8ec2c57414669b79": "Anslut en andra {tracker}-arbetsyta eller användare."
}
4 changes: 3 additions & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5447,5 +5447,7 @@
"ad208e3e32c85029": "全部隐藏",
"3328503592789bed": "专注模式",
"856812e7e1fc445e": "聊天中的工具调用",
"8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。"
"8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。",
"99d51127f573296b": "其他账号",
"8ec2c57414669b79": "连接第二个 {tracker} 工作区或用户。"
}
1 change: 1 addition & 0 deletions apps/server/src/environment/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const make = Effect.gen(function* () {
issues: true,
linkedThreadRefreshes: true,
issueLinkedThreads: true,
issueTrackerAccounts: true,
sideChats: true,
vcsBranchStatus: true,
inlineMessageContext: true,
Expand Down
Loading
Loading