@koinzhang/paseo-plugin-activity 0.5.0 → 0.7.0
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/CHANGELOG.md +78 -1
- package/README.md +15 -8
- package/client/activity-heatmap.tsx +126 -93
- package/client/agent-creations.tsx +216 -0
- package/client/attention-pill.tsx +16 -5
- package/client/attention-popover.tsx +19 -23
- package/client/color-mix.test.ts +27 -0
- package/client/color-mix.ts +38 -0
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +168 -0
- package/client/fit-text.test.ts +41 -0
- package/client/fit-text.ts +33 -0
- package/client/formatted-time.tsx +4 -4
- package/client/global-surface.tsx +316 -275
- package/client/header-button.ts +136 -0
- package/client/hourly-activity-timeline.tsx +425 -0
- package/client/measured-width.ts +72 -0
- package/client/panel-visibility.test.ts +25 -0
- package/client/panel-visibility.ts +45 -0
- package/client/panel.tsx +83 -108
- package/client/provider-dropdown.tsx +131 -0
- package/client/provider-filter.test.ts +17 -13
- package/client/provider-filter.ts +5 -7
- package/client/range.test.ts +44 -0
- package/client/range.ts +14 -0
- package/client/rank-color.test.ts +108 -14
- package/client/rank-color.ts +261 -48
- package/client/ranking-bars.tsx +291 -0
- package/client/ui.tsx +339 -0
- package/client/usage-popover.tsx +62 -134
- package/client/usage-stats.tsx +137 -8
- package/client/use-agent-turn-end.ts +2 -1
- package/client/use-app-language.ts +17 -0
- package/client/web.ts +73 -18
- package/client/workspace/agent-row.tsx +18 -25
- package/client/workspace/agents-section.tsx +23 -20
- package/client/workspace/constants.ts +6 -6
- package/client/workspace/display-menu.tsx +5 -4
- package/client/workspace/filters.test.ts +1 -1
- package/client/workspace/filters.ts +4 -2
- package/client/workspace/panel.tsx +176 -104
- package/client/workspace/rank-section.tsx +157 -44
- package/client/workspace/terminals-section.tsx +13 -9
- package/index.client.tsx +40 -20
- package/index.server.ts +63 -31
- package/package.json +2 -2
- package/paseo-plugin.json +2 -1
- package/server/agents.ts +20 -2
- package/server/background-sync.test.ts +43 -0
- package/server/background-sync.ts +43 -4
- package/server/handlers-query.test.ts +252 -1
- package/server/handlers.ts +174 -13
- package/server/ingest.test.ts +8 -0
- package/server/messages.test.ts +96 -1
- package/server/prompt-dedupe.ts +52 -0
- package/server/rpc-cache.test.ts +74 -0
- package/server/rpc-cache.ts +48 -0
- package/server/store.test.ts +122 -0
- package/server/store.ts +313 -19
- package/server/ttl-cache.ts +3 -0
- package/shared/activity.test.ts +159 -6
- package/shared/activity.ts +140 -5
- package/shared/classify.test.ts +1 -0
- package/shared/classify.ts +4 -1
- package/shared/explorer-agent-display.test.ts +61 -0
- package/shared/explorer-agent-display.ts +21 -2
- package/shared/format.test.ts +28 -3
- package/shared/format.ts +25 -2
- package/shared/i18n.test.ts +34 -0
- package/shared/i18n.ts +363 -0
- package/shared/insights.test.ts +162 -80
- package/shared/insights.ts +136 -61
- package/shared/usage.test.ts +330 -0
- package/shared/usage.ts +471 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { fitFontSize } from "./fit-text.ts";
|
|
4
|
+
|
|
5
|
+
const options = { base: 18, min: 12 };
|
|
6
|
+
const measured = (size: number, width: number) => ({ size, width });
|
|
7
|
+
|
|
8
|
+
describe("fitFontSize (051)", () => {
|
|
9
|
+
it("keeps the base size when the text fits", () => {
|
|
10
|
+
assert.equal(fitFontSize(measured(18, 80), 100, options), 18);
|
|
11
|
+
assert.equal(fitFontSize(measured(18, 100), 100, options), 18);
|
|
12
|
+
assert.equal(fitFontSize(measured(12, 60), 120, options), 18);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("scales the size down by the measured overflow", () => {
|
|
16
|
+
// 138px at 18px in a 120px tile → 15.5px (1% headroom).
|
|
17
|
+
assert.equal(fitFontSize(measured(18, 138), 120, options), 15.5);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("is independent of the size the text is currently rendered at", () => {
|
|
21
|
+
// The same physical width measured at 15.5px resolves to the same size.
|
|
22
|
+
const shrunk = fitFontSize(measured(15.5, 138 * (15.5 / 18)), 120, options);
|
|
23
|
+
assert.equal(shrunk, 15.5);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("grows back to base once the tile widens", () => {
|
|
27
|
+
assert.equal(fitFontSize(measured(15.5, 118.8), 160, options), 18);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("clamps to min and ignores unusable measurements", () => {
|
|
31
|
+
assert.equal(fitFontSize(measured(18, 400), 60, options), 12);
|
|
32
|
+
assert.equal(fitFontSize(measured(18, 0), 120, options), 18);
|
|
33
|
+
assert.equal(fitFontSize(measured(0, 120), 120, options), 18);
|
|
34
|
+
assert.equal(fitFontSize(measured(18, 138), 0, options), 18);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("derives a min floor from the base size when none is given", () => {
|
|
38
|
+
assert.equal(fitFontSize(measured(18, 400), 40, { base: 18 }), 12);
|
|
39
|
+
assert.equal(fitFontSize(measured(12, 400), 40, { base: 12 }), 8);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-line text sizing (051).
|
|
3
|
+
*
|
|
4
|
+
* KPI tiles are ~130px wide at 18px values ("Cursor · 61%"), so values used to
|
|
5
|
+
* wrap onto two lines and push the labels out of line. The text is measured
|
|
6
|
+
* once at a known size, and the size that fits `available` is derived from that
|
|
7
|
+
* measurement alone: width scales linearly with font size, so the target does
|
|
8
|
+
* not depend on the size currently rendered — measure, fit, converge, and grow
|
|
9
|
+
* back to `base` when the tile widens.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type TextMeasurement = {
|
|
13
|
+
/** Font size the text was measured at. */
|
|
14
|
+
size: number;
|
|
15
|
+
/** Rendered width of the text at `size`. */
|
|
16
|
+
width: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Font size that fits `available`, clamped to `[min, base]`. */
|
|
20
|
+
export function fitFontSize(
|
|
21
|
+
measured: TextMeasurement,
|
|
22
|
+
available: number,
|
|
23
|
+
options: { base: number; min?: number },
|
|
24
|
+
): number {
|
|
25
|
+
const { base } = options;
|
|
26
|
+
const min = options.min ?? Math.max(8, base - 6);
|
|
27
|
+
if (!(measured.width > 0) || !(measured.size > 0) || !(available > 0)) return base;
|
|
28
|
+
const exact = (measured.size * available) / measured.width;
|
|
29
|
+
if (exact >= base) return base;
|
|
30
|
+
// 1% headroom on the shrink so sub-pixel rounding cannot trip the ellipsis.
|
|
31
|
+
const target = Math.min(base, Math.max(min, Math.round(exact * 0.99 * 10) / 10));
|
|
32
|
+
return target;
|
|
33
|
+
}
|
|
@@ -10,14 +10,14 @@ import { useAppLanguage } from "./use-app-language.ts";
|
|
|
10
10
|
export function FormattedTime({
|
|
11
11
|
iso,
|
|
12
12
|
style,
|
|
13
|
-
|
|
13
|
+
format,
|
|
14
14
|
}: {
|
|
15
15
|
iso: string | null | undefined;
|
|
16
16
|
style?: TextStyle;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** Wraps the stamp in localized copy, e.g. `messages.common.lastUsed`. */
|
|
18
|
+
format?: (stamp: string) => string;
|
|
19
19
|
}): ReactNode {
|
|
20
20
|
const locale = useAppLanguage();
|
|
21
21
|
const stamp = formatActivityTime(iso, locale);
|
|
22
|
-
return <Text style={style}>{
|
|
22
|
+
return <Text style={style}>{format ? format(stamp) : stamp}</Text>;
|
|
23
23
|
}
|