paseo-dsh 0.2.20 → 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.
- package/OVERVIEW.md +4 -4
- package/OVERVIEW.zh-CN.md +15 -0
- package/README.md +6 -6
- package/client/dsh-plugins-page.tsx +960 -0
- package/client/guard.tsx +115 -0
- package/client/i18n.ts +100 -0
- package/client/labels.ts +23 -0
- package/client/locales/en.json +215 -0
- package/client/locales/zh-CN.json +213 -0
- package/client/messages.ts +85 -0
- package/client/react-native.d.ts +3 -0
- package/client/settings-screen.tsx +34 -21
- package/client/stream-stats.tsx +71 -48
- package/client/timeline.tsx +442 -123
- package/index.client.tsx +42 -4
- package/index.server.ts +30 -7
- package/package.json +8 -6
- package/paseo-plugin.json +8 -2
- package/server/bootstrap.ts +8 -2
- package/server/bridge-assets.ts +3 -2
- package/server/dsh-plugins-rpc.ts +45 -0
- package/server/dsh-plugins.ts +970 -0
- package/server/dsh-process.ts +61 -11
- package/server/provider.ts +25 -7
- package/server/session.ts +410 -48
- package/server/timeline.ts +69 -4
- package/shared/dsh-plugins-api.ts +175 -0
- package/shared/image-preview.ts +8 -1
- package/shared/settings.ts +14 -43
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as paseo from "@getpaseo/plugin/client";
|
|
2
|
+
import type { PluginTranslations } from "@getpaseo/plugin/client";
|
|
3
|
+
import en from "./locales/en.json";
|
|
4
|
+
import zhCN from "./locales/zh-CN.json";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Every user-visible string the plugin draws in the app.
|
|
8
|
+
*
|
|
9
|
+
* English is the source of truth for the key set; `zh-CN` may omit a key and
|
|
10
|
+
* falls back to English. Paseo resolves the app language per installation, so
|
|
11
|
+
* the same bundle serves both catalogs and a language switch re-renders the
|
|
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.
|
|
18
|
+
*/
|
|
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();
|
|
56
|
+
|
|
57
|
+
/** Bare verb keys a tool row can resolve to; they carry no interpolation. */
|
|
58
|
+
export type ToolVerbKey =
|
|
59
|
+
| "timeline.tool.command"
|
|
60
|
+
| "timeline.tool.image"
|
|
61
|
+
| "timeline.tool.read"
|
|
62
|
+
| "timeline.tool.write"
|
|
63
|
+
| "timeline.tool.edit"
|
|
64
|
+
| "timeline.tool.search"
|
|
65
|
+
| "timeline.tool.webSearch"
|
|
66
|
+
| "timeline.tool.fetch"
|
|
67
|
+
| "timeline.tool.browser"
|
|
68
|
+
| "timeline.tool.code"
|
|
69
|
+
| "timeline.tool.tasks"
|
|
70
|
+
| "timeline.tool.question";
|
|
71
|
+
|
|
72
|
+
export type BrowserVerbKey =
|
|
73
|
+
| "timeline.browser.open"
|
|
74
|
+
| "timeline.browser.click"
|
|
75
|
+
| "timeline.browser.type"
|
|
76
|
+
| "timeline.browser.snapshot"
|
|
77
|
+
| "timeline.browser.scroll"
|
|
78
|
+
| "timeline.browser.navigate"
|
|
79
|
+
| "timeline.browser.wait"
|
|
80
|
+
| "timeline.browser.close"
|
|
81
|
+
| "timeline.browser.run"
|
|
82
|
+
| "timeline.browser.find";
|
|
83
|
+
|
|
84
|
+
/** A resolve-on-render verb: a catalog key, or the provider's raw tool name. */
|
|
85
|
+
export type ToolVerb = ToolVerbKey | BrowserVerbKey | { readonly text: string };
|
package/client/react-native.d.ts
CHANGED
|
@@ -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,18 +1,29 @@
|
|
|
1
1
|
import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
2
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";
|
|
6
8
|
import {
|
|
7
9
|
TIMELINE_STYLE_DEFAULTS,
|
|
8
|
-
|
|
10
|
+
TIMELINE_STYLE_KEYS,
|
|
9
11
|
timelineStyleSettings,
|
|
10
12
|
type TimelineStyleKey,
|
|
11
13
|
type TimelineStyleValues,
|
|
12
14
|
} from "../shared/settings";
|
|
15
|
+
import { persistentLabel } from "./labels";
|
|
16
|
+
|
|
17
|
+
/** Editor rows: the key order is shared, the wording comes from the catalogs. */
|
|
18
|
+
const FIELDS = TIMELINE_STYLE_KEYS.map((key) => ({
|
|
19
|
+
key,
|
|
20
|
+
label: `settings.field.${key}.label` as const,
|
|
21
|
+
hint: `settings.field.${key}.hint` as const,
|
|
22
|
+
}));
|
|
13
23
|
|
|
14
24
|
/** Numeric editor for the timeline row spacing and command drawer height. */
|
|
15
25
|
export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
|
|
26
|
+
const { t } = useTranslation();
|
|
16
27
|
const settings = useSettings(timelineStyleSettings);
|
|
17
28
|
const [draft, setDraft] = useState<Partial<Record<TimelineStyleKey, string>>>({});
|
|
18
29
|
const [notice, setNotice] = useState<string | null>(null);
|
|
@@ -67,64 +78,62 @@ export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
|
|
|
67
78
|
const save = async () => {
|
|
68
79
|
if (settings.status !== "ready") return;
|
|
69
80
|
const next: TimelineStyleValues = { ...current };
|
|
70
|
-
for (const field of
|
|
81
|
+
for (const field of FIELDS) {
|
|
71
82
|
const value = Number.parseFloat(textOf(field.key));
|
|
72
83
|
if (!Number.isFinite(value)) {
|
|
73
|
-
setNotice(
|
|
84
|
+
setNotice(t("settings.invalidNumber", { label: t(field.label) }));
|
|
74
85
|
return;
|
|
75
86
|
}
|
|
76
87
|
next[field.key] = value;
|
|
77
88
|
}
|
|
78
89
|
const saved = await settings.save(next, settings.revision);
|
|
79
|
-
setNotice(saved ? "
|
|
90
|
+
setNotice(saved ? t("settings.saved") : (settings.saveError ?? t("settings.saveFailed")));
|
|
80
91
|
if (saved) setDraft({});
|
|
81
92
|
};
|
|
82
93
|
|
|
83
94
|
const reset = async () => {
|
|
84
95
|
const saved = await settings.reset();
|
|
85
|
-
setNotice(saved ? "
|
|
96
|
+
setNotice(saved ? t("settings.resetDone") : (settings.saveError ?? t("settings.resetFailed")));
|
|
86
97
|
if (saved) setDraft({});
|
|
87
98
|
};
|
|
88
99
|
|
|
89
100
|
return (
|
|
90
101
|
<ScrollView style={styles.screen} contentContainerStyle={styles.content}>
|
|
91
|
-
<Text style={styles.title}
|
|
92
|
-
<Text style={styles.intro}>
|
|
93
|
-
|
|
94
|
-
</Text>
|
|
95
|
-
{TIMELINE_STYLE_FIELDS.map((field) => (
|
|
102
|
+
<Text style={styles.title}>{t("settings.title")}</Text>
|
|
103
|
+
<Text style={styles.intro}>{t("settings.intro")}</Text>
|
|
104
|
+
{FIELDS.map((field) => (
|
|
96
105
|
<View key={field.key} style={styles.field}>
|
|
97
|
-
<Text style={styles.label}>{field.label}</Text>
|
|
106
|
+
<Text style={styles.label}>{t(field.label)}</Text>
|
|
98
107
|
<TextInput
|
|
99
108
|
value={textOf(field.key)}
|
|
100
109
|
onChangeText={(value: string) => edit(field.key, value)}
|
|
101
110
|
keyboardType={field.key === "toolRowMarginY" ? (Platform.OS === "web" ? "default" : "numbers-and-punctuation") : "numeric"}
|
|
102
111
|
autoCapitalize="none"
|
|
103
112
|
autoCorrect={false}
|
|
104
|
-
accessibilityLabel={field.label}
|
|
113
|
+
accessibilityLabel={t(field.label)}
|
|
105
114
|
style={styles.input}
|
|
106
115
|
/>
|
|
107
|
-
<Text style={styles.hint}>{field.hint}</Text>
|
|
116
|
+
<Text style={styles.hint}>{t(field.hint)}</Text>
|
|
108
117
|
</View>
|
|
109
118
|
))}
|
|
110
119
|
<View style={styles.actions}>
|
|
111
120
|
<Pressable
|
|
112
121
|
accessibilityRole="button"
|
|
113
|
-
accessibilityLabel="
|
|
122
|
+
accessibilityLabel={t("settings.save")}
|
|
114
123
|
disabled={settings.status !== "ready" || settings.saving}
|
|
115
|
-
onPress={() =>
|
|
124
|
+
onPress={() => guardAsync("settings save", save)}
|
|
116
125
|
style={styles.button}
|
|
117
126
|
>
|
|
118
|
-
<Text style={styles.buttonText}>{settings.saving ? "
|
|
127
|
+
<Text style={styles.buttonText}>{settings.saving ? t("settings.saving") : t("settings.save")}</Text>
|
|
119
128
|
</Pressable>
|
|
120
129
|
<Pressable
|
|
121
130
|
accessibilityRole="button"
|
|
122
|
-
accessibilityLabel="
|
|
131
|
+
accessibilityLabel={t("settings.reset")}
|
|
123
132
|
disabled={settings.status !== "ready" || settings.saving}
|
|
124
|
-
onPress={() =>
|
|
133
|
+
onPress={() => guardAsync("settings reset", reset)}
|
|
125
134
|
style={[styles.button, styles.secondary]}
|
|
126
135
|
>
|
|
127
|
-
<Text style={styles.secondaryText}
|
|
136
|
+
<Text style={styles.secondaryText}>{t("settings.reset")}</Text>
|
|
128
137
|
</Pressable>
|
|
129
138
|
</View>
|
|
130
139
|
{settings.status === "error" ? <Text style={styles.notice}>{settings.error}</Text> : null}
|
|
@@ -137,8 +146,12 @@ export function TimelineSettingsScreen({ theme, layout }: PluginSurfaceProps) {
|
|
|
137
146
|
export function contributeTimelineSettings(client: PluginClientContext): () => void {
|
|
138
147
|
return client.addSettingsScreen({
|
|
139
148
|
id: "timeline-style",
|
|
140
|
-
title: "
|
|
149
|
+
title: persistentLabel("settings.title"),
|
|
141
150
|
icon: "SlidersHorizontal",
|
|
142
|
-
Component:
|
|
151
|
+
Component: withPluginBoundary<PluginSurfaceProps>(
|
|
152
|
+
"timeline settings",
|
|
153
|
+
TimelineSettingsScreen,
|
|
154
|
+
(props) => <FailedRow theme={props.theme} message={translateForLabel("settings.renderFailed")} />,
|
|
155
|
+
),
|
|
143
156
|
});
|
|
144
157
|
}
|
package/client/stream-stats.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PluginClientContext, PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
|
+
import { translateForLabel, useTranslation } from "./i18n";
|
|
3
|
+
import { FailedRow, guard, report, withPluginBoundary } from "./guard";
|
|
2
4
|
import { Fragment, useLayoutEffect, useRef, useState } from "react";
|
|
3
5
|
import { Pressable, Text, View } from "react-native";
|
|
4
6
|
import { z } from "zod";
|
|
@@ -54,34 +56,6 @@ function contextRatio(data: StreamStats): number | undefined {
|
|
|
54
56
|
return Math.max(0, Math.min(1, data.contextUsed / data.contextMax));
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
function contextLine(data: StreamStats): string | undefined {
|
|
58
|
-
const ratio = contextRatio(data);
|
|
59
|
-
if (ratio === undefined) return undefined;
|
|
60
|
-
const filled = Math.round(ratio * 10);
|
|
61
|
-
const bar = `${"█".repeat(filled)}${"░".repeat(10 - filled)}`;
|
|
62
|
-
return `上下文 ${formatNumber(data.contextUsed ?? 0)} / ${formatNumber(data.contextMax ?? 0)} ${bar} ${Math.round(ratio * 100)}%`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function tokensLine(data: StreamStats): string | undefined {
|
|
66
|
-
const parts: string[] = [];
|
|
67
|
-
if (data.inputTokens !== undefined) parts.push(`输入 ${formatNumber(data.inputTokens)}`);
|
|
68
|
-
if (data.cachedInputTokens !== undefined) parts.push(`缓存 ${formatNumber(data.cachedInputTokens)}`);
|
|
69
|
-
if (data.outputTokens !== undefined) parts.push(`输出 ${formatNumber(data.outputTokens)}`);
|
|
70
|
-
return parts.length === 0 ? undefined : `Tokens ${parts.join(" · ")}`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function routeLine(data: StreamStats): string | undefined {
|
|
74
|
-
if (data.provider === undefined && data.model === undefined) return undefined;
|
|
75
|
-
const route = [data.provider, data.model].filter((part) => part !== undefined).join(" / ");
|
|
76
|
-
return `路由 ${route}${data.thinkingOption === undefined ? "" : ` · 思考 ${data.thinkingOption}`}`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function toolsLine(data: StreamStats): string | undefined {
|
|
80
|
-
if (data.toolCalls === undefined || data.toolCalls <= 0) return undefined;
|
|
81
|
-
const duration = data.toolMs === undefined ? "" : ` · ${formatLatency(data.toolMs)}`;
|
|
82
|
-
return `工具 ${data.toolCalls} 次${duration}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
59
|
/** One compact line under an answer; tap to expand the full picture. */
|
|
86
60
|
function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamStats>) {
|
|
87
61
|
const [open, setOpen] = useState(false);
|
|
@@ -91,6 +65,47 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
|
|
|
91
65
|
/** The lift the DOM currently carries; the next measurement discounts it. */
|
|
92
66
|
const appliedLift = useRef(0);
|
|
93
67
|
const data = item.data;
|
|
68
|
+
const { t } = useTranslation();
|
|
69
|
+
const line = {
|
|
70
|
+
context(): string | undefined {
|
|
71
|
+
const ratio = contextRatio(data);
|
|
72
|
+
if (ratio === undefined) return undefined;
|
|
73
|
+
const filled = Math.round(ratio * 10);
|
|
74
|
+
const bar = `${"█".repeat(filled)}${"░".repeat(10 - filled)}`;
|
|
75
|
+
return t("streamStats.contextLine", {
|
|
76
|
+
used: formatNumber(data.contextUsed ?? 0),
|
|
77
|
+
max: formatNumber(data.contextMax ?? 0),
|
|
78
|
+
bar,
|
|
79
|
+
percent: Math.round(ratio * 100),
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
tokens(): string | undefined {
|
|
83
|
+
const parts: string[] = [];
|
|
84
|
+
if (data.inputTokens !== undefined) {
|
|
85
|
+
parts.push(t("streamStats.tokenInput", { tokens: formatNumber(data.inputTokens) }));
|
|
86
|
+
}
|
|
87
|
+
if (data.cachedInputTokens !== undefined) {
|
|
88
|
+
parts.push(t("streamStats.tokenCached", { tokens: formatNumber(data.cachedInputTokens) }));
|
|
89
|
+
}
|
|
90
|
+
if (data.outputTokens !== undefined) {
|
|
91
|
+
parts.push(t("streamStats.tokenOutput", { tokens: formatNumber(data.outputTokens) }));
|
|
92
|
+
}
|
|
93
|
+
return parts.length === 0 ? undefined : t("streamStats.tokensLine", { parts: parts.join(" · ") });
|
|
94
|
+
},
|
|
95
|
+
route(): string | undefined {
|
|
96
|
+
if (data.provider === undefined && data.model === undefined) return undefined;
|
|
97
|
+
const route = [data.provider, data.model].filter((part) => part !== undefined).join(" / ");
|
|
98
|
+
return data.thinkingOption === undefined
|
|
99
|
+
? t("streamStats.routeLine", { route })
|
|
100
|
+
: t("streamStats.routeWithThinking", { route, option: data.thinkingOption });
|
|
101
|
+
},
|
|
102
|
+
tools(): string | undefined {
|
|
103
|
+
if (data.toolCalls === undefined || data.toolCalls <= 0) return undefined;
|
|
104
|
+
const calls = t("streamStats.tools", { count: data.toolCalls });
|
|
105
|
+
const duration = data.toolMs === undefined ? "" : ` · ${formatLatency(data.toolMs)}`;
|
|
106
|
+
return t("streamStats.toolsLine", { calls, duration });
|
|
107
|
+
},
|
|
108
|
+
};
|
|
94
109
|
|
|
95
110
|
// The ref must describe the margin the DOM actually carries, not the one a
|
|
96
111
|
// pending render is about to apply.
|
|
@@ -108,19 +123,23 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
|
|
|
108
123
|
return;
|
|
109
124
|
}
|
|
110
125
|
const measure = () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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);
|
|
121
142
|
}
|
|
122
|
-
setLift(found.lift);
|
|
123
|
-
setFontSize(found.fontSize);
|
|
124
143
|
};
|
|
125
144
|
measure();
|
|
126
145
|
// The footer is not necessarily in its final place when the row mounts: it
|
|
@@ -129,7 +148,7 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
|
|
|
129
148
|
// watching the containers in case it moves again (a new turn pushing this
|
|
130
149
|
// one down, a theme swap, a font load).
|
|
131
150
|
const retries = [80, 240, 700, 1500].map((ms) => setTimeout(measure, ms));
|
|
132
|
-
const stop = watchRow(rowRef.current, measure);
|
|
151
|
+
const stop = guard("footer watch", () => watchRow(rowRef.current, measure), undefined);
|
|
133
152
|
return () => {
|
|
134
153
|
for (const timer of retries) clearTimeout(timer);
|
|
135
154
|
stop?.();
|
|
@@ -149,23 +168,23 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
|
|
|
149
168
|
const ratio = contextRatio(data);
|
|
150
169
|
const segments: Array<{ text: string; color: string }> = [];
|
|
151
170
|
if (data.turns !== undefined && data.steps !== undefined) {
|
|
152
|
-
segments.push({ text:
|
|
171
|
+
segments.push({ text: t("streamStats.turnsSteps", { turns: data.turns, steps: data.steps }), color: muted });
|
|
153
172
|
}
|
|
154
173
|
if (data.firstTokenMs !== undefined) {
|
|
155
|
-
segments.push({ text:
|
|
174
|
+
segments.push({ text: t("streamStats.firstToken", { latency: formatLatency(data.firstTokenMs) }), color: muted });
|
|
156
175
|
}
|
|
157
176
|
if (data.tokensPerSecond !== undefined) {
|
|
158
177
|
segments.push({ text: `${Math.round(data.tokensPerSecond)} tok/s`, color: muted });
|
|
159
178
|
}
|
|
160
179
|
if (ratio !== undefined) {
|
|
161
|
-
segments.push({ text:
|
|
180
|
+
segments.push({ text: t("streamStats.contextPercent", { percent: Math.round(ratio * 100) }), color: muted });
|
|
162
181
|
}
|
|
163
182
|
if (data.cacheHit !== undefined) {
|
|
164
|
-
segments.push({ text:
|
|
183
|
+
segments.push({ text: t("streamStats.cacheHit", { percent: Math.round(data.cacheHit * 100) }), color: muted });
|
|
165
184
|
}
|
|
166
185
|
if (segments.length === 0) return null;
|
|
167
186
|
|
|
168
|
-
const details = [
|
|
187
|
+
const details = [line.context(), line.tokens(), line.route(), line.tools()].filter(
|
|
169
188
|
(line): line is string => line !== undefined,
|
|
170
189
|
);
|
|
171
190
|
|
|
@@ -173,7 +192,7 @@ function StreamStatsRow({ item, theme, layout }: PluginTimelineItemProps<StreamS
|
|
|
173
192
|
<Pressable
|
|
174
193
|
ref={rowRef}
|
|
175
194
|
accessibilityRole="button"
|
|
176
|
-
accessibilityLabel={open ? "
|
|
195
|
+
accessibilityLabel={open ? t("streamStats.collapse") : t("streamStats.expand")}
|
|
177
196
|
onPress={() => setOpen((value) => !value)}
|
|
178
197
|
style={{ alignSelf: "flex-start", marginTop: lift, marginBottom: 0, paddingLeft: inset }}
|
|
179
198
|
>
|
|
@@ -204,7 +223,11 @@ export function contributeStreamStats(client: PluginClientContext) {
|
|
|
204
223
|
kind: "dsh-stream-stats",
|
|
205
224
|
version: 1,
|
|
206
225
|
schema: streamStatsSchema,
|
|
207
|
-
Component:
|
|
226
|
+
Component: withPluginBoundary<PluginTimelineItemProps<StreamStats>>(
|
|
227
|
+
"dsh-stream-stats",
|
|
228
|
+
StreamStatsRow,
|
|
229
|
+
(props) => <FailedRow theme={props.theme} message={translateForLabel("timeline.row.renderFailed")} />,
|
|
230
|
+
),
|
|
208
231
|
});
|
|
209
232
|
return () => {};
|
|
210
233
|
}
|