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
1 change: 1 addition & 0 deletions apps/desktop/src/settings/DesktopClientSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const clientSettings: ClientSettings = {
notificationMode: "notifications-and-sound",
inAppNotificationsEnabled: true,
appearanceContrast: 100,
pdfAppearance: "dark",
browserDefaultViewport: { _tag: "preset", width: 1024, height: 600, presetId: "nest-hub" },
browserDefaultZoomFactor: 1.25,
browserDefaultAppearance: "dark",
Expand Down
59 changes: 59 additions & 0 deletions apps/mobile/src/components/PdfAppearance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { useGT } from "gt-react-native";
import { useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
import { useState, type ReactNode } from "react";
import { Platform, StyleSheet, View } from "react-native";

import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { mobilePreferencesAtom } from "../state/preferences";
import { ControlPill } from "./ui/ControlPill";

export function PdfAppearance(props: { readonly children: ReactNode }) {
const gt = useGT();
const preferences = useAtomValue(mobilePreferencesAtom);
const appearance = AsyncResult.isSuccess(preferences)
? (preferences.value.pdfAppearance ?? "match-app")
: "match-app";
const { themeAppearance } = useAppearancePreferences();
const [override, setOverride] = useState<boolean | null>(null);
const dark =
override ??
(appearance === "dark" || (appearance === "match-app" && themeAppearance === "dark"));

return (
<View className="flex-1 bg-card">
<View className="items-end px-3 py-1">
<ControlPill
icon={dark ? "moon" : "sun.max"}
accessibilityLabel={dark ? gt("Restore original colors") : gt("Invert colors")}
variant={dark ? "primary" : "circle"}
onPress={() => setOverride(!dark)}
/>
</View>
<View
style={{
flex: 1,
isolation: "isolate",
backgroundColor: "white",
filter:
Platform.OS === "android" && dark
? [{ invert: 1 }, { hueRotate: "180deg" }]
: undefined,
}}
>
{props.children}
{Platform.OS === "ios" && dark ? (
// iOS supports blending but not the invert filter.
<View
pointerEvents="none"
accessible={false}
style={[
StyleSheet.absoluteFill,
{ backgroundColor: "white", mixBlendMode: "difference" },
]}
/>
) : null}
</View>
</View>
);
}
9 changes: 9 additions & 0 deletions apps/mobile/src/components/PdfPreview.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { pdfInitialPage, pdfLinkUrl, preparePdfPreview } from "../lib/pdfPreview
import { m } from "../i18n/messages";
import { tryOpenExternalUrl } from "../lib/openExternalUrl";
import { ControlPill } from "./ui/ControlPill";
import { PdfAppearance } from "./PdfAppearance";

const preparedPdfAtom = Atom.family((uri: string) =>
Atom.make(
Expand Down Expand Up @@ -49,6 +50,14 @@ const preparedPdfAtom = Atom.family((uri: string) =>
);

export function PdfPreview(props: { readonly uri: string }) {
return (
<PdfAppearance key={props.uri}>
<PdfContent uri={props.uri} />
</PdfAppearance>
);
}

function PdfContent(props: { readonly uri: string }) {
const gt = useGT();
const atom = preparedPdfAtom(props.uri);
const prepared = useAtomValue(atom);
Expand Down
47 changes: 25 additions & 22 deletions apps/mobile/src/components/PdfPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { View } from "react-native";
import { WebView } from "react-native-webview";

import { FilePreviewLoading, FilePreviewNotice } from "../features/files/FilePreviewFeedback";
import { PdfAppearance } from "./PdfAppearance";
import { webViewDecelerationRate } from "../lib/webViewDecelerationRate";

export function PdfPreview(props: { readonly uri: string }) {
Expand All @@ -14,28 +15,30 @@ export function PdfPreview(props: { readonly uri: string }) {
{error ? (
<FilePreviewNotice title={gt("Could not load PDF")}>{error}</FilePreviewNotice>
) : null}
<WebView
source={{ uri: props.uri }}
originWhitelist={["*"]}
automaticallyAdjustContentInsets={false}
decelerationRate={webViewDecelerationRate}
contentInsetAdjustmentBehavior="never"
startInLoadingState
onError={(event) =>
setError(event.nativeEvent.description || gt("The PDF could not be loaded."))
}
onHttpError={(event) =>
setError(
gt("The server returned HTTP {statusCode}.", {
statusCode: event.nativeEvent.statusCode,
}),
)
}
renderLoading={() => (
<FilePreviewLoading message={gt("Loading PDF...")} background="card" />
)}
style={{ flex: 1, backgroundColor: "transparent" }}
/>
<PdfAppearance key={props.uri}>
<WebView
source={{ uri: props.uri }}
originWhitelist={["*"]}
automaticallyAdjustContentInsets={false}
decelerationRate={webViewDecelerationRate}
contentInsetAdjustmentBehavior="never"
startInLoadingState
onError={(event) =>
setError(event.nativeEvent.description || gt("The PDF could not be loaded."))
}
onHttpError={(event) =>
setError(
gt("The server returned HTTP {statusCode}.", {
statusCode: event.nativeEvent.statusCode,
}),
)
}
renderLoading={() => (
<FilePreviewLoading message={gt("Loading PDF...")} background="card" />
)}
style={{ flex: 1, backgroundColor: "transparent" }}
/>
</PdfAppearance>
</View>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CodeAppearanceSection } from "./appearance/sections/CodeAppearanceSecti
import { TerminalAppearanceSection } from "./appearance/sections/TerminalAppearanceSection";
import { TextAppearanceSection } from "./appearance/sections/TextAppearanceSection";
import { ThemeAppearanceSection } from "./appearance/sections/ThemeAppearanceSection";
import { PdfAppearanceSection } from "./appearance/sections/PdfAppearanceSection";
import { ToolCallsAppearanceSection } from "./appearance/sections/ToolCallsAppearanceSection";

export function SettingsAppearanceRouteScreen() {
Expand All @@ -31,6 +32,7 @@ export function SettingsAppearanceRouteScreen() {
<TextAppearanceSection />
<TerminalAppearanceSection />
<CodeAppearanceSection />
<PdfAppearanceSection />
<ToolCallsAppearanceSection />
</ScrollView>
</SettingsScreen>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { msg, useGT, useMessages } from "gt-react-native";
import { useAtomValue } from "@effect/atom-react";
import type { PdfAppearance } from "@t3tools/contracts/settings";
import { AsyncResult } from "effect/reactivity";
import { View } from "react-native";

import { ListChoiceRow } from "../../../../components/ui/ListChoiceRow";
import { mobilePreferencesAtom, saveMobilePreferences } from "../../../../state/preferences";
import { useAtomCommand } from "../../../../state/use-atom-command";
import { SettingsSection } from "../../components/SettingsSection";

const OPTIONS: ReadonlyArray<readonly [PdfAppearance, string]> = [
["match-app", msg("Match theme")],
["original", msg("Original colors")],
["dark", msg("Inverted colors")],
];

export function PdfAppearanceSection() {
const gt = useGT();
const m = useMessages();
const preferences = useAtomValue(mobilePreferencesAtom);
const savePreferences = useAtomCommand(saveMobilePreferences);
const ready = AsyncResult.isSuccess(preferences);
const appearance = ready ? (preferences.value.pdfAppearance ?? "match-app") : "match-app";
return (
<SettingsSection title={gt("PDF colors")}>
<View accessibilityRole="radiogroup">
{OPTIONS.map(([value, label], index) => (
<ListChoiceRow
key={value}
label={m(label)}
disabled={!ready}
selected={appearance === value}
onPress={() => {
void savePreferences({ pdfAppearance: value });
}}
separated={index > 0}
/>
))}
</View>
</SettingsSection>
);
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5464,5 +5464,11 @@
"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.",
"6dc1e8c15f62989d": "Originalfarben wiederherstellen",
"0d576a2c32b02d5d": "Farben invertieren",
"66104e819c8d2122": "Design übernehmen",
"a368bf0b43feb260": "Originalfarben",
"4d2fa01e838b9549": "Invertierte Farben",
"1c19f2863386a317": "PDF-Farben"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5466,5 +5466,11 @@
"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.",
"6dc1e8c15f62989d": "Restore original colors",
"0d576a2c32b02d5d": "Invert colors",
"66104e819c8d2122": "Match theme",
"a368bf0b43feb260": "Original colors",
"4d2fa01e838b9549": "Inverted colors",
"1c19f2863386a317": "PDF colors"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -5458,5 +5458,11 @@
"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.",
"6dc1e8c15f62989d": "Restaurar colores originales",
"0d576a2c32b02d5d": "Invertir colores",
"66104e819c8d2122": "Seguir el tema",
"a368bf0b43feb260": "Colores originales",
"4d2fa01e838b9549": "Colores invertidos",
"1c19f2863386a317": "Colores del PDF"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5458,5 +5458,11 @@
"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.",
"6dc1e8c15f62989d": "Rétablir les couleurs d’origine",
"0d576a2c32b02d5d": "Inverser les couleurs",
"66104e819c8d2122": "Suivre le thème",
"a368bf0b43feb260": "Couleurs d’origine",
"4d2fa01e838b9549": "Couleurs inversées",
"1c19f2863386a317": "Couleurs du PDF"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -5439,5 +5439,11 @@
"ad208e3e32c85029": "すべて非表示",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "チャット内のツール呼び出し",
"8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。"
"8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。",
"6dc1e8c15f62989d": "元の色に戻す",
"0d576a2c32b02d5d": "色を反転",
"66104e819c8d2122": "テーマに合わせる",
"a368bf0b43feb260": "元の色",
"4d2fa01e838b9549": "反転した色",
"1c19f2863386a317": "PDFの色"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -5443,5 +5443,11 @@
"ad208e3e32c85029": "모두 숨기기",
"3328503592789bed": "Zen",
"856812e7e1fc445e": "채팅의 도구 호출",
"8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다."
"8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다.",
"6dc1e8c15f62989d": "원래 색상으로 복원",
"0d576a2c32b02d5d": "색상 반전",
"66104e819c8d2122": "테마에 맞추기",
"a368bf0b43feb260": "원래 색상",
"4d2fa01e838b9549": "반전된 색상",
"1c19f2863386a317": "PDF 색상"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -5458,5 +5458,11 @@
"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.",
"6dc1e8c15f62989d": "Restaurar cores originais",
"0d576a2c32b02d5d": "Inverter cores",
"66104e819c8d2122": "Seguir o tema",
"a368bf0b43feb260": "Cores originais",
"4d2fa01e838b9549": "Cores invertidas",
"1c19f2863386a317": "Cores do PDF"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5538,5 +5538,11 @@
"ad208e3e32c85029": "Скрывать все",
"3328503592789bed": "Дзен",
"856812e7e1fc445e": "Вызовы инструментов в чате",
"8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда."
"8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда.",
"6dc1e8c15f62989d": "Восстановить исходные цвета",
"0d576a2c32b02d5d": "Инвертировать цвета",
"66104e819c8d2122": "Как в теме",
"a368bf0b43feb260": "Исходные цвета",
"4d2fa01e838b9549": "Инвертированные цвета",
"1c19f2863386a317": "Цвета PDF"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -5464,5 +5464,11 @@
"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.",
"6dc1e8c15f62989d": "Återställ originalfärger",
"0d576a2c32b02d5d": "Invertera färger",
"66104e819c8d2122": "Följ temat",
"a368bf0b43feb260": "Originalfärger",
"4d2fa01e838b9549": "Inverterade färger",
"1c19f2863386a317": "PDF-färger"
}
8 changes: 7 additions & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5449,5 +5449,11 @@
"ad208e3e32c85029": "全部隐藏",
"3328503592789bed": "专注模式",
"856812e7e1fc445e": "聊天中的工具调用",
"8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。"
"8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。",
"6dc1e8c15f62989d": "恢复原始颜色",
"0d576a2c32b02d5d": "反转颜色",
"66104e819c8d2122": "跟随主题",
"a368bf0b43feb260": "原始颜色",
"4d2fa01e838b9549": "反转颜色",
"1c19f2863386a317": "PDF 颜色"
}
9 changes: 9 additions & 0 deletions apps/mobile/src/persistence/mobile-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from "@t3tools/contracts";
import { ToolCallVisibility } from "@t3tools/contracts/settings";
import type { AndroidNavigationStyle } from "../lib/androidNavigationStyle";
import type { PdfAppearance } from "@t3tools/contracts/settings";
import type { ComposerEnterBehavior } from "../lib/composerEnterBehavior";
import type { FollowUpBehavior } from "../lib/followUpBehavior";
import { isMicrophoneKind, type MicrophoneEntry } from "../lib/microphonePriority";
Expand Down Expand Up @@ -147,6 +148,7 @@ export interface Preferences {
readonly lightThemeId?: MobileThemeId;
readonly darkThemeId?: MobileThemeId;
readonly themeMode?: MobileThemeMode;
readonly pdfAppearance?: PdfAppearance;
readonly androidNavigationStyle?: AndroidNavigationStyle;
readonly baseFontSize?: number;
readonly terminalFontSize?: number | null;
Expand Down Expand Up @@ -240,6 +242,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
lightThemeId?: MobileThemeId;
darkThemeId?: MobileThemeId;
themeMode?: MobileThemeMode;
pdfAppearance?: PdfAppearance;
androidNavigationStyle?: AndroidNavigationStyle;
baseFontSize?: number;
terminalFontSize?: number | null;
Expand Down Expand Up @@ -342,6 +345,12 @@ function sanitizePreferences(parsed: Preferences): Preferences {
preferences.codeFontSize = parsed.codeFontSize;
}
if (typeof parsed.codeWordBreak === "boolean") preferences.codeWordBreak = parsed.codeWordBreak;
if (
parsed.pdfAppearance === "match-app" ||
parsed.pdfAppearance === "original" ||
parsed.pdfAppearance === "dark"
)
preferences.pdfAppearance = parsed.pdfAppearance;
if (typeof parsed.mathRenderingEnabled === "boolean")
preferences.mathRenderingEnabled = parsed.mathRenderingEnabled;
if (typeof parsed.crashReportsEnabled === "boolean") {
Expand Down
Loading
Loading