paseo-dsh 0.2.21 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ import { Component, type ComponentType, type ReactNode } from "react";
2
+ import { Text, View } from "react-native";
3
+
4
+ export type Cleanup = () => void;
5
+
6
+ /** Never let a diagnostic path throw the app over. */
7
+ export function report(label: string, error: unknown): void {
8
+ try {
9
+ console.error(`[dsh-paseo] ${label}`, error);
10
+ } catch {
11
+ // A host without a working console still has to keep running.
12
+ }
13
+ }
14
+
15
+ /** Run a host-facing call; a throw becomes a logged no-op, not an app abort. */
16
+ export function guard<T>(label: string, run: () => T, fallback: T): T {
17
+ try {
18
+ return run();
19
+ } catch (error) {
20
+ report(label, error);
21
+ return fallback;
22
+ }
23
+ }
24
+
25
+ /** Start an async task and absorb both sync throws and rejections. */
26
+ export function guardAsync(label: string, run: () => Promise<unknown>): void {
27
+ try {
28
+ void run().catch((error: unknown) => {
29
+ report(label, error);
30
+ });
31
+ } catch (error) {
32
+ report(label, error);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Catches render failures in one plugin contribution.
38
+ *
39
+ * The host has no boundary around what a plugin draws: an uncaught render error
40
+ * goes through RN's fatal handler, and a release build aborts — the whole app
41
+ * disappears because one tool row could not render. Everything this plugin
42
+ * hands to the host is wrapped here instead.
43
+ */
44
+ class PluginBoundary extends Component<
45
+ { fallback: ReactNode; children: ReactNode },
46
+ { failed: boolean }
47
+ > {
48
+ state = { failed: false };
49
+
50
+ static getDerivedStateFromError(): { failed: boolean } {
51
+ return { failed: true };
52
+ }
53
+
54
+ componentDidCatch(error: Error): void {
55
+ report("render", error);
56
+ }
57
+
58
+ render(): ReactNode {
59
+ return this.state.failed ? this.props.fallback : this.props.children;
60
+ }
61
+ }
62
+
63
+ export function withPluginBoundary<P extends object>(
64
+ name: string,
65
+ Inner: ComponentType<P>,
66
+ fallback: (props: P) => ReactNode,
67
+ ): ComponentType<P> {
68
+ function Guarded(props: P) {
69
+ return (
70
+ <PluginBoundary fallback={fallback(props)}>
71
+ <Inner {...props} />
72
+ </PluginBoundary>
73
+ );
74
+ }
75
+ Guarded.displayName = `Guarded(${name})`;
76
+ return Guarded;
77
+ }
78
+
79
+ /** A one-line failure card, used where the contribution has no room for more. */
80
+ export function FailedRow({
81
+ theme,
82
+ message,
83
+ }: {
84
+ theme: { colors: { statusDanger: string } };
85
+ message: string;
86
+ }) {
87
+ return (
88
+ <View style={{ paddingVertical: 4 }}>
89
+ <Text style={{ color: theme.colors.statusDanger, fontSize: 12, lineHeight: 18 }}>
90
+ {message}
91
+ </Text>
92
+ </View>
93
+ );
94
+ }
95
+
96
+ /**
97
+ * Register one contribution. A host that refuses it (unknown icon, unresolvable
98
+ * label, missing surface) loses that entry only; the rest of the plugin and the
99
+ * app keep running. The returned cleanup is safe to call twice.
100
+ */
101
+ export function guardCleanup(label: string, run: () => Cleanup): Cleanup {
102
+ try {
103
+ const cleanup = run();
104
+ return () => {
105
+ try {
106
+ cleanup();
107
+ } catch (error) {
108
+ report(`${label} cleanup`, error);
109
+ }
110
+ };
111
+ } catch (error) {
112
+ report(label, error);
113
+ return () => {};
114
+ }
115
+ }
package/client/i18n.ts ADDED
@@ -0,0 +1,100 @@
1
+ import * as paseo from "@getpaseo/plugin/client";
2
+ import { useCallback } from "react";
3
+ import { Platform } from "react-native";
4
+ import { messages } from "./messages";
5
+
6
+ export type Translate = (key: string, args?: Record<string, unknown>) => string;
7
+
8
+ /**
9
+ * In the native apps the plugin draws its own strings from the bundled catalogs
10
+ * instead of going through the host's `useTranslation`.
11
+ *
12
+ * Paseo 0.16.0's native plugin runtime is where the i18n API is newest, and a
13
+ * throw from that hook reaches React during render — fatal in a release build.
14
+ * Nothing on this path depends on the host: catalogs ship in the bundle,
15
+ * missing keys already fall back to English, and the app language is read from
16
+ * the system locale, which is what the native clients start with. The desktop
17
+ * (web) host keeps the host hook, including live language switching.
18
+ */
19
+ const isNativeApp = Platform.OS !== "web";
20
+
21
+ function deviceLocale(): string {
22
+ try {
23
+ const locale = Intl.DateTimeFormat().resolvedOptions().locale;
24
+ if (typeof locale === "string" && locale !== "") return locale;
25
+ } catch {
26
+ // Hermes without Intl falls through to English.
27
+ }
28
+ return "en";
29
+ }
30
+
31
+ const localLocale = deviceLocale();
32
+
33
+ function catalogFor(locale: string): unknown {
34
+ return locale.toLowerCase().startsWith("zh")
35
+ ? messages.resources["zh-CN"]
36
+ : messages.resources.en;
37
+ }
38
+
39
+ function lookup(resource: unknown, key: string): string | undefined {
40
+ let node: unknown = resource;
41
+ for (const part of key.split(".")) {
42
+ if (typeof node !== "object" || node === null) return undefined;
43
+ node = (node as Record<string, unknown>)[part];
44
+ }
45
+ return typeof node === "string" ? node : undefined;
46
+ }
47
+
48
+ function interpolate(template: string, args?: Record<string, unknown>): string {
49
+ if (args === undefined) return template;
50
+ return template.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (_match, name: string) => {
51
+ const value = args[name];
52
+ if (value === undefined) return "";
53
+ if (value instanceof Date) return value.toLocaleString();
54
+ return String(value);
55
+ });
56
+ }
57
+
58
+ function pluralCategory(locale: string, count: number): "one" | "other" {
59
+ // Both catalogs only ever need English's one/other split; Chinese is `other`.
60
+ if (locale.toLowerCase().startsWith("zh")) return "other";
61
+ return Math.abs(count) === 1 ? "one" : "other";
62
+ }
63
+
64
+ /** Resolve one catalog key for a locale, with `{{name}}` and count support. */
65
+ export function translate(locale: string, key: string, args?: Record<string, unknown>): string {
66
+ const catalog = catalogFor(locale);
67
+ const count = typeof args?.count === "number" ? args.count : undefined;
68
+ if (count !== undefined) {
69
+ const plural = lookup(catalog, `${key}_${pluralCategory(locale, count)}`);
70
+ if (plural !== undefined) return interpolate(plural, args);
71
+ }
72
+ return interpolate(lookup(catalog, key) ?? key, args);
73
+ }
74
+
75
+ /** The label a host-owned registration takes: resolved on iOS, persistent elsewhere. */
76
+ export function translateForLabel(key: string): string {
77
+ return translate(localLocale, key);
78
+ }
79
+
80
+ function useLocalTranslation() {
81
+ const locale = localLocale;
82
+ const t = useCallback<Translate>((key, args) => translate(locale, key, args), [locale]);
83
+ return { locale, t };
84
+ }
85
+
86
+ const hostUseTranslation = (paseo as unknown as {
87
+ useTranslation?: (resources: unknown) => { locale: string; t: unknown };
88
+ }).useTranslation;
89
+
90
+ function useHostTranslation() {
91
+ if (hostUseTranslation === undefined) {
92
+ throw new Error("This Paseo client does not provide useTranslation");
93
+ }
94
+ const { locale, t } = hostUseTranslation(messages);
95
+ return { locale, t: t as unknown as Translate };
96
+ }
97
+
98
+ export const useTranslation: () => { locale: string; t: Translate } = isNativeApp
99
+ ? useLocalTranslation
100
+ : useHostTranslation;
@@ -0,0 +1,23 @@
1
+ import { Platform } from "react-native";
2
+ import { translateForLabel } from "./i18n";
3
+ import { messages } from "./messages";
4
+
5
+ /** Host-owned labels this plugin registers; each is a key in every catalog. */
6
+ export type PersistentKey = "plugins.page.title" | "settings.title";
7
+
8
+ /**
9
+ * The screen, sidebar and settings labels are persistent host-owned
10
+ * registrations, so they take a catalog message rather than a string: a `t()`
11
+ * result is a snapshot and would keep the language the plugin loaded with.
12
+ *
13
+ * Paseo 0.16.0's native apps are the exception. Their host registers and draws
14
+ * these labels before resolving a `PluginMessage`, so the object is either
15
+ * rejected while the contribution registers or reaches React as a child.
16
+ * Either path ends in an uncaught JS error, and release Hermes turns that into
17
+ * an abort of the whole app. Resolve the entry from the bundled catalog there;
18
+ * the desktop (web) host keeps the persistent message.
19
+ */
20
+ export function persistentLabel(key: PersistentKey) {
21
+ if (Platform.OS === "web") return messages.message(key);
22
+ return translateForLabel(key);
23
+ }
@@ -23,7 +23,8 @@
23
23
  "exitFullscreen": "Exit fullscreen",
24
24
  "close": "Close",
25
25
  "wrap": "Wrap",
26
- "noWrap": "No wrap"
26
+ "noWrap": "No wrap",
27
+ "renderFailed": "This row could not be rendered."
27
28
  },
28
29
  "tool": {
29
30
  "command": "Command",
@@ -118,6 +119,97 @@
118
119
  "label": "Command block minimum height cap",
119
120
  "hint": "The height the command block keeps even in a very small window, in pixels. Range 60 to 360."
120
121
  }
122
+ },
123
+ "renderFailed": "This screen could not be rendered."
124
+ },
125
+ "plugins": {
126
+ "page": {
127
+ "title": "DSH Plugins"
128
+ },
129
+ "header": {
130
+ "refresh": "Refresh",
131
+ "refreshing": "Refreshing…",
132
+ "checkUpdates": "Check for updates",
133
+ "checkingUpdates": "Checking…",
134
+ "notice": "Changes apply to new sessions; running sessions keep their current state.",
135
+ "retry": "Retry",
136
+ "profile": "{{profile}} · {{host}}"
137
+ },
138
+ "groups": {
139
+ "enabled": "Enabled",
140
+ "disabled": "Disabled",
141
+ "dependencies": "Plain dependencies"
142
+ },
143
+ "badges": {
144
+ "official": "Built in",
145
+ "protected": "Protected",
146
+ "client": "Web UI",
147
+ "platformUnsupported": "Not supported here",
148
+ "missing": "Missing",
149
+ "updateAvailable": "Update to {{version}}"
150
+ },
151
+ "bundle": {
152
+ "dependencyNote": "This is a plain dependency, not a DSH bundle; it does not become a profile layer.",
153
+ "clientNote": "Its UI only appears in DSH Web/Desktop.",
154
+ "platforms": "Supported platforms: {{platforms}}",
155
+ "remove": "Remove",
156
+ "confirmRemove": "Confirm removal",
157
+ "cancel": "Cancel",
158
+ "update": "Update to {{version}}",
159
+ "confirmUpdate": "Confirm update to {{version}}",
160
+ "platformsUnknown": "This bundle does not list support for the current platform."
161
+ },
162
+ "install": {
163
+ "title": "Install a DSH plugin",
164
+ "hint": "Only npm registry package names are accepted. The package is checked for dsh.bundle before installation.",
165
+ "placeholder": "Package name or name@version",
166
+ "check": "Check",
167
+ "checking": "Checking…",
168
+ "confirm": "Install",
169
+ "unknown": "Unknown package",
170
+ "trust": "This is third-party code. It runs inside every new DSH session. Install only packages you trust.",
171
+ "notBundle": "This package does not declare dsh.bundle, so it would not take effect in this profile."
172
+ },
173
+ "job": {
174
+ "installAction": "Installation",
175
+ "removeAction": "Removal",
176
+ "updateAction": "Update",
177
+ "checkAction": "Update check",
178
+ "running": "{{action}} in progress…",
179
+ "failed": "{{action}} failed",
180
+ "succeeded": "{{action}} finished",
181
+ "failedBadge": "Failed",
182
+ "doneBadge": "Done",
183
+ "updatesFound_one": "{{count}} update available.",
184
+ "updatesFound_other": "{{count}} updates available."
185
+ },
186
+ "status": {
187
+ "loadingProfile": "Reading the profile…"
188
+ },
189
+ "errors": {
190
+ "profile-unreadable": "Could not read the profile's package.json.",
191
+ "profile-invalid": "The profile's package.json is not valid JSON.",
192
+ "invalid-platform": "This bundle does not support the current platform.",
193
+ "lock-timeout": "Timed out waiting for the profile write lock.",
194
+ "invalid-name": "The bundle name is empty.",
195
+ "protected": "This bundle is protected.",
196
+ "not-installed": "This package is not installed.",
197
+ "not-a-bundle": "This package does not declare dsh.bundle.",
198
+ "invalid-spec": "Only npm registry package names are supported.",
199
+ "registry-unreadable": "Could not read the registry response.",
200
+ "registry-invalid": "The registry returned no usable package information.",
201
+ "already-installed": "This package is already installed. Enable it in the list instead.",
202
+ "not-removable": "Only packages in the profile dependencies can be removed.",
203
+ "not-in-dependencies": "This package is not a profile dependency.",
204
+ "invalid-version": "This is not a valid registry version.",
205
+ "check-failed": "Some bundles could not be checked.",
206
+ "disposed": "The plugin was unloaded.",
207
+ "busy": "Another management task is running.",
208
+ "job-missing": "The task is no longer available.",
209
+ "spawn-failed": "Could not start dsh.",
210
+ "command-failed": "The dsh command failed.",
211
+ "request-failed": "The request failed.",
212
+ "render": "This screen failed to render. Reopen it; if it happens again, check the daemon log."
121
213
  }
122
214
  }
123
215
  }
@@ -23,7 +23,8 @@
23
23
  "exitFullscreen": "退出全屏",
24
24
  "close": "关闭",
25
25
  "wrap": "换行",
26
- "noWrap": "不换行"
26
+ "noWrap": "不换行",
27
+ "renderFailed": "这一行渲染失败。"
27
28
  },
28
29
  "tool": {
29
30
  "command": "命令",
@@ -117,6 +118,96 @@
117
118
  "label": "命令块最小高度上限",
118
119
  "hint": "窗口很小时仍给命令块保留的高度(像素)。范围 60 ~ 360。"
119
120
  }
121
+ },
122
+ "renderFailed": "这个页面渲染失败。"
123
+ },
124
+ "plugins": {
125
+ "page": {
126
+ "title": "DSH 插件"
127
+ },
128
+ "header": {
129
+ "refresh": "刷新",
130
+ "refreshing": "刷新中…",
131
+ "checkUpdates": "检查更新",
132
+ "checkingUpdates": "检查中…",
133
+ "notice": "改动只影响新建会话;正在运行的会话保持原样。",
134
+ "retry": "重试",
135
+ "profile": "{{profile}} · {{host}}"
136
+ },
137
+ "groups": {
138
+ "enabled": "已启用",
139
+ "disabled": "未启用",
140
+ "dependencies": "普通依赖"
141
+ },
142
+ "badges": {
143
+ "official": "内置",
144
+ "protected": "受保护",
145
+ "client": "客户端界面",
146
+ "platformUnsupported": "当前平台不支持",
147
+ "missing": "缺失",
148
+ "updateAvailable": "可更新到 {{version}}"
149
+ },
150
+ "bundle": {
151
+ "dependencyNote": "普通依赖,不是 DSH bundle,不会成为 profile 层。",
152
+ "clientNote": "界面只在 DSH Web/Desktop 显示。",
153
+ "platforms": "支持的平台:{{platforms}}",
154
+ "remove": "卸载",
155
+ "confirmRemove": "确认卸载",
156
+ "cancel": "取消",
157
+ "update": "更新到 {{version}}",
158
+ "confirmUpdate": "确认更新到 {{version}}",
159
+ "platformsUnknown": "这个 bundle 没有声明支持当前平台。"
160
+ },
161
+ "install": {
162
+ "title": "安装 DSH 插件",
163
+ "hint": "只接受 npm registry 包名。安装前会检查它是否声明 dsh.bundle。",
164
+ "placeholder": "包名或包名@版本",
165
+ "check": "检查",
166
+ "checking": "检查中…",
167
+ "confirm": "确认安装",
168
+ "unknown": "未知包",
169
+ "trust": "这是第三方代码,会在每个新会话的 DSH 进程里运行。只安装你信任的包。",
170
+ "notBundle": "这个包没有声明 dsh.bundle,装进 profile 不会生效。"
171
+ },
172
+ "job": {
173
+ "installAction": "安装",
174
+ "removeAction": "卸载",
175
+ "updateAction": "更新",
176
+ "checkAction": "检查更新",
177
+ "running": "正在{{action}}…",
178
+ "failed": "{{action}}失败",
179
+ "succeeded": "{{action}}完成",
180
+ "failedBadge": "失败",
181
+ "doneBadge": "完成",
182
+ "updatesFound_other": "发现 {{count}} 个可更新项。"
183
+ },
184
+ "status": {
185
+ "loadingProfile": "正在读取 profile…"
186
+ },
187
+ "errors": {
188
+ "profile-unreadable": "读不到 profile 的 package.json。",
189
+ "profile-invalid": "profile 的 package.json 不是有效 JSON。",
190
+ "invalid-platform": "这个 bundle 不支持当前平台。",
191
+ "lock-timeout": "等待 profile 写锁超时。",
192
+ "invalid-name": "bundle 名称不能为空。",
193
+ "protected": "这个 bundle 受保护。",
194
+ "not-installed": "这个包没有安装。",
195
+ "not-a-bundle": "这个包没有声明 dsh.bundle。",
196
+ "invalid-spec": "只支持 npm registry 包名。",
197
+ "registry-unreadable": "无法解析 registry 返回的信息。",
198
+ "registry-invalid": "registry 没有返回有效的包信息。",
199
+ "already-installed": "这个包已经安装,请在列表里启用它。",
200
+ "not-removable": "只有 profile 依赖里的包可以卸载。",
201
+ "not-in-dependencies": "这个包不在 profile 依赖里。",
202
+ "invalid-version": "这不是有效的 registry 版本。",
203
+ "check-failed": "部分 bundle 检查失败。",
204
+ "disposed": "插件已卸载。",
205
+ "busy": "已有管理任务在运行。",
206
+ "job-missing": "任务不存在或已过期。",
207
+ "spawn-failed": "无法启动 dsh。",
208
+ "command-failed": "dsh 命令执行失败。",
209
+ "request-failed": "请求失败。",
210
+ "render": "这个页面渲染失败。重新打开试试;如果反复出现,请检查 daemon 日志。"
120
211
  }
121
212
  }
122
213
  }
@@ -1,4 +1,5 @@
1
- import { defineTranslations } from "@getpaseo/plugin/client";
1
+ import * as paseo from "@getpaseo/plugin/client";
2
+ import type { PluginTranslations } from "@getpaseo/plugin/client";
2
3
  import en from "./locales/en.json";
3
4
  import zhCN from "./locales/zh-CN.json";
4
5
 
@@ -9,8 +10,49 @@ import zhCN from "./locales/zh-CN.json";
9
10
  * falls back to English. Paseo resolves the app language per installation, so
10
11
  * the same bundle serves both catalogs and a language switch re-renders the
11
12
  * rows without reloading the plugin.
13
+ *
14
+ * `defineTranslations` is read off the module instead of imported by name: a
15
+ * client whose plugin runtime predates the i18n API still has to load this
16
+ * bundle. The fallback keeps `message()` usable as a plain English label,
17
+ * which such a host accepts where it would reject a `PluginMessage` object.
12
18
  */
13
- export const messages = defineTranslations({ resources: { en, "zh-CN": zhCN } });
19
+ type Catalog = typeof en;
20
+
21
+ const resources = { en, "zh-CN": zhCN } as const;
22
+
23
+ const define = (paseo as unknown as {
24
+ defineTranslations?: (input: { resources: unknown }) => PluginTranslations<Catalog>;
25
+ }).defineTranslations;
26
+
27
+ function english(key: string): string {
28
+ let node: unknown = en;
29
+ for (const part of key.split(".")) {
30
+ if (typeof node !== "object" || node === null) return key;
31
+ node = (node as Record<string, unknown>)[part];
32
+ }
33
+ return typeof node === "string" ? node : key;
34
+ }
35
+
36
+ function createMessages(): PluginTranslations<Catalog> {
37
+ if (typeof define === "function") {
38
+ try {
39
+ return define({ resources });
40
+ } catch (error) {
41
+ // A broken host runtime must not take the bundle down while it loads.
42
+ try {
43
+ console.error("[dsh-paseo] defineTranslations", error);
44
+ } catch {
45
+ // Ignore a console that is itself unavailable.
46
+ }
47
+ }
48
+ }
49
+ return {
50
+ resources,
51
+ message: (key: string) => english(key),
52
+ } as unknown as PluginTranslations<Catalog>;
53
+ }
54
+
55
+ export const messages = createMessages();
14
56
 
15
57
  /** Bare verb keys a tool row can resolve to; they carry no interpolation. */
16
58
  export type ToolVerbKey =
@@ -11,5 +11,8 @@ declare module "react-native" {
11
11
  export const Modal: any;
12
12
  export const Image: any;
13
13
  export const useWindowDimensions: () => { width: number; height: number };
14
+ export const TextInput: any;
15
+ export const Switch: any;
16
+ export const ActivityIndicator: any;
14
17
  export const Platform: { OS: "ios" | "android" | "web" | "windows" | "macos" };
15
18
  }
@@ -1,5 +1,7 @@
1
1
  import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
2
- import { useSettings, useTranslation } from "@getpaseo/plugin/client";
2
+ import { useSettings } from "@getpaseo/plugin/client";
3
+ import { translateForLabel, useTranslation } from "./i18n";
4
+ import { FailedRow, guardAsync, withPluginBoundary } from "./guard";
3
5
  import { useMemo, useState } from "react";
4
6
  import { Platform, Pressable, ScrollView, Text, View } from "react-native";
5
7
  import { TextInput } from "@getpaseo/plugin/client/react-native";
@@ -10,7 +12,7 @@ import {
10
12
  type TimelineStyleKey,
11
13
  type TimelineStyleValues,
12
14
  } from "../shared/settings";
13
- import { messages } from "./messages";
15
+ import { persistentLabel } from "./labels";
14
16
 
15
17
  /** Editor rows: the key order is shared, the wording comes from the catalogs. */
16
18
  const FIELDS = TIMELINE_STYLE_KEYS.map((key) => ({
@@ -21,7 +23,7 @@ const FIELDS = TIMELINE_STYLE_KEYS.map((key) => ({
21
23
 
22
24
  /** Numeric editor for the timeline row spacing and command drawer height. */
23
25
  export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
24
- const { t } = useTranslation(messages);
26
+ const { t } = useTranslation();
25
27
  const settings = useSettings(timelineStyleSettings);
26
28
  const [draft, setDraft] = useState<Partial<Record<TimelineStyleKey, string>>>({});
27
29
  const [notice, setNotice] = useState<string | null>(null);
@@ -119,7 +121,7 @@ export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
119
121
  accessibilityRole="button"
120
122
  accessibilityLabel={t("settings.save")}
121
123
  disabled={settings.status !== "ready" || settings.saving}
122
- onPress={() => void save()}
124
+ onPress={() => guardAsync("settings save", save)}
123
125
  style={styles.button}
124
126
  >
125
127
  <Text style={styles.buttonText}>{settings.saving ? t("settings.saving") : t("settings.save")}</Text>
@@ -128,7 +130,7 @@ export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
128
130
  accessibilityRole="button"
129
131
  accessibilityLabel={t("settings.reset")}
130
132
  disabled={settings.status !== "ready" || settings.saving}
131
- onPress={() => void reset()}
133
+ onPress={() => guardAsync("settings reset", reset)}
132
134
  style={[styles.button, styles.secondary]}
133
135
  >
134
136
  <Text style={styles.secondaryText}>{t("settings.reset")}</Text>
@@ -144,8 +146,12 @@ export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
144
146
  export function contributeTimelineSettings(client: PluginClientContext): () => void {
145
147
  return client.addSettingsScreen({
146
148
  id: "timeline-style",
147
- title: messages.message("settings.title"),
149
+ title: persistentLabel("settings.title"),
148
150
  icon: "SlidersHorizontal",
149
- Component: TimelineSettingsScreen,
151
+ Component: withPluginBoundary<PluginSurfaceProps>(
152
+ "timeline settings",
153
+ TimelineSettingsScreen,
154
+ (props) => <FailedRow theme={props.theme} message={translateForLabel("settings.renderFailed")} />,
155
+ ),
150
156
  });
151
157
  }
@@ -1,6 +1,6 @@
1
1
  import type { PluginClientContext, PluginTimelineItemProps } from "@getpaseo/plugin/client";
2
- import { useTranslation } from "@getpaseo/plugin/client";
3
- import { messages } from "./messages";
2
+ import { translateForLabel, useTranslation } from "./i18n";
3
+ import { FailedRow, guard, report, withPluginBoundary } from "./guard";
4
4
  import { Fragment, useLayoutEffect, useRef, useState } from "react";
5
5
  import { Pressable, Text, View } from "react-native";
6
6
  import { z } from "zod";
@@ -65,7 +65,7 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
65
65
  /** The lift the DOM currently carries; the next measurement discounts it. */
66
66
  const appliedLift = useRef(0);
67
67
  const data = item.data;
68
- const { t } = useTranslation(messages);
68
+ const { t } = useTranslation();
69
69
  const line = {
70
70
  context(): string | undefined {
71
71
  const ratio = contextRatio(data);
@@ -123,19 +123,23 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
123
123
  return;
124
124
  }
125
125
  const measure = () => {
126
- const found = measureFooterGeometry(rowRef.current, {
127
- appliedLift: appliedLift.current,
128
- gapEm: GAP_EM,
129
- fallbackFontSize: FOOTER_FONT_SIZE,
130
- });
131
- if (found === null) {
132
- // A hidden tab (zero-height row) says nothing about the layout: keep
133
- // the last margin so switching back does not un-tuck the row.
134
- if (rowIsLaidOut(rowRef.current)) setLift(0);
135
- return;
126
+ try {
127
+ const found = measureFooterGeometry(rowRef.current, {
128
+ appliedLift: appliedLift.current,
129
+ gapEm: GAP_EM,
130
+ fallbackFontSize: FOOTER_FONT_SIZE,
131
+ });
132
+ if (found === null) {
133
+ // A hidden tab (zero-height row) says nothing about the layout: keep
134
+ // the last margin so switching back does not un-tuck the row.
135
+ if (rowIsLaidOut(rowRef.current)) setLift(0);
136
+ return;
137
+ }
138
+ setLift(found.lift);
139
+ setFontSize(found.fontSize);
140
+ } catch (error) {
141
+ report("footer measurement", error);
136
142
  }
137
- setLift(found.lift);
138
- setFontSize(found.fontSize);
139
143
  };
140
144
  measure();
141
145
  // The footer is not necessarily in its final place when the row mounts: it
@@ -144,7 +148,7 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
144
148
  // watching the containers in case it moves again (a new turn pushing this
145
149
  // one down, a theme swap, a font load).
146
150
  const retries = [80, 240, 700, 1500].map((ms) => setTimeout(measure, ms));
147
- const stop = watchRow(rowRef.current, measure);
151
+ const stop = guard("footer watch", () => watchRow(rowRef.current, measure), undefined);
148
152
  return () => {
149
153
  for (const timer of retries) clearTimeout(timer);
150
154
  stop?.();
@@ -219,7 +223,11 @@ export function contributeStreamStats(client: PluginClientContext) {
219
223
  kind: "dsh-stream-stats",
220
224
  version: 1,
221
225
  schema: streamStatsSchema,
222
- Component: StreamStatsRow,
226
+ Component: withPluginBoundary<PluginTimelineItemProps<StreamStats>>(
227
+ "dsh-stream-stats",
228
+ StreamStatsRow,
229
+ (props) => <FailedRow theme={props.theme} message={translateForLabel("timeline.row.renderFailed")} />,
230
+ ),
223
231
  });
224
232
  return () => {};
225
233
  }