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
6 changes: 6 additions & 0 deletions packages/tui/src/feature-plugins/system/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function StatsPage(props: { context: Plugin.Context; onClose: () => void }) {
<box width="100%" height="100%" backgroundColor={theme.background.base}>
<scrollbox
flexGrow={1}
minHeight={0}
contentOptions={{
alignItems: "center",
justifyContent: "center",
Expand All @@ -175,6 +176,11 @@ function StatsPage(props: { context: Plugin.Context; onClose: () => void }) {
</Show>
</Show>
</scrollbox>
<box flexDirection="row" justifyContent="flex-end" paddingRight={2} paddingBottom={1} flexShrink={0}>
<text fg={theme.text.muted} selectable={false}>
esc back
</text>
</box>
</box>
)
}
Expand Down
10 changes: 9 additions & 1 deletion packages/tui/test/stats.view.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ test("stats shows only this year and returns after errors or success", async ()
await setup.waitForFrame((frame) => frame.includes("Usage statistics"))
setup.mockInput.pressKey("RETURN")
await setup.waitForFrame((frame) => frame.includes("Could not load stats"))
expect(setup.captureCharFrame()).toContain("esc back")
setup.mockInput.pressKey("ESCAPE")
await setup.waitForFrame((frame) => frame.includes("commands") && !frame.includes("Could not load stats"))
await setup.mockInput.typeText("/stats")
Expand All @@ -68,7 +69,7 @@ test("stats shows only this year and returns after errors or success", async ()
expect(setup.captureCharFrame()).not.toContain("all time")
expect(setup.captureCharFrame()).not.toContain("All projects")
expect(setup.captureCharFrame()).not.toContain("show this year")
expect(setup.captureCharFrame()).not.toContain("esc")
expect(setup.captureCharFrame()).toContain("esc back")
expect(
setup
.captureCharFrame()
Expand All @@ -84,6 +85,13 @@ test("stats shows only this year and returns after errors or success", async ()
expect(requests).toHaveLength(2)
expect(setup.captureCharFrame()).toContain("TOKENS")
expect(setup.captureCharFrame()).not.toContain("headline")
for (const [width, height] of [[40, 18], [120, 42]]) {
setup.resize(width, height)
await setup.waitForVisualIdle()
const rows = setup.captureCharFrame().split("\n")
expect(rows[height - 2]?.trim()).toBe("esc back")
expect(rows[height - 2]?.indexOf("esc back")).toBe(width - 10)
}
setup.mockInput.pressKey("ESCAPE")
await setup.waitForFrame((frame) => frame.includes("commands") && !frame.includes("opencode / stats"))
} finally {
Expand Down
Loading