Skip to content
Merged
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
17 changes: 15 additions & 2 deletions packages/agent-chat/src/ComputerManagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ const copy = {
screen: "Open computer screen",
screenAt: "Open computer screen · {rate}/hr",
pause: "Pause",
pauseAt: "Pause · {rate}/hr",
pausing: "Pausing…",
pauseFailed: "The computer did not pause.",
resume: "Resume",
resumeAt: "Resume · {rate}/hr",
resuming: "Resuming…",
resumeFailed: "The computer did not resume.",
resumeConfirm: "Resume bills {rate} credits per hour. Unused prepaid is returned.",
Expand Down Expand Up @@ -80,9 +82,11 @@ const copy = {
screen: "打开电脑屏幕",
screenAt: "打开电脑屏幕 · {rate} 星币/小时",
pause: "暂停",
pauseAt: "暂停 · {rate} 星币/小时",
pausing: "正在暂停…",
pauseFailed: "没有停下来。",
resume: "恢复",
resumeAt: "恢复 · {rate} 星币/小时",
resuming: "正在恢复…",
resumeFailed: "没有恢复。",
resumeConfirm: "恢复按 {rate} 星币/小时计费。不用的预扣会退回。",
Expand Down Expand Up @@ -363,7 +367,12 @@ export function ComputerManagePanel({
void pauseThis(row.computer_id);
}}
>
{busy ? t.pausing : t.pause}
{busy
? t.pausing
: pauseAsksBeforeCharge(row.paused_credits_per_hour) &&
row.paused_credits_per_hour != null
? withRate(t.pauseAt, row.paused_credits_per_hour)
: t.pause}
</button>
) : row.has_disk ? (
<button
Expand All @@ -377,7 +386,11 @@ export function ComputerManagePanel({
})
}
>
{busy ? t.resuming : t.resume}
{busy
? t.resuming
: row.resume_credits_per_hour != null
? withRate(t.resumeAt, row.resume_credits_per_hour)
: t.resume}
</button>
) : null}
{computerStatusLine(row, t)}
Expand Down
5 changes: 5 additions & 0 deletions tests/computer-manage-cta.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ test("a running computer can be paused from the panel", () => {
"utf8",
);
assert.match(panel, /pause: "暂停"/);
assert.match(panel, /pauseAt: "暂停 · \{rate\} 星币\/小时"/);
assert.match(panel, /\/api\/computers\/\$\{encodeURIComponent\(computerId\)\}\/pause/);
assert.match(panel, /row\.status === "running"/);
assert.match(panel, /pauseAsksBeforeCharge\(row\.paused_credits_per_hour\) &&/);
assert.match(panel, /withRate\(t\.pauseAt, row\.paused_credits_per_hour\)/);
});

test("pause asks before a charged pause and skips a free one", () => {
Expand All @@ -119,8 +122,10 @@ test("an idle computer with a disk can be resumed from the panel", () => {
"utf8",
);
assert.match(panel, /resume: "恢复"/);
assert.match(panel, /resumeAt: "恢复 · \{rate\} 星币\/小时"/);
assert.match(panel, /\/api\/computers\/\$\{encodeURIComponent\(computerId\)\}\/resume/);
assert.match(panel, /row\.has_disk \? \(/);
assert.match(panel, /withRate\(t\.resumeAt, row\.resume_credits_per_hour\)/);
});

test("resuming asks on the panel before it starts billing", () => {
Expand Down
Loading