Commit Graph
4 Commits
Author SHA1 Message Date
TryWorld 5e89b7f83d sessions tests: every agent's resume line is asserted on Windows too, not skipped there (#1069)
Ten of resumeCommand's agents (cline, qoder, qoder-cn, droid, grok, omp,
opencode files/db/v2, pi, codex, claude) had their resume check wrapped in
runtime.GOOS != "windows", so on Windows nothing checked the
Set-Location -LiteralPath line resumeCommand builds there, its doubled
single quote included. Each now asserts its own platform's line.

This is the sessions half of TryWorld2026's #1069. Its internal/agent half
(aside refusals, the Codex stale skip) was already done on main by
9650cd50c and 688c062ed, and its TestCursor change by 6a8095421, so those
parts are left out.

Run (at origin/main 5b14ebf49 plus this): gofmt -l clean; go vet,
GOOS=linux go vet -tags nogui, GOOS=windows go vet on internal/sessions;
go test -tags nogui ./internal/sessions on macOS ok. On the Windows box
(Windows 11 x64, amd64 test binary, sandbox USERPROFILE/APPDATA/
LOCALAPPDATA/TEMP) the whole package passes. Broken by hand (Windows
branch of resumeCommand building the Unix "cd '...' &&" line): TestCline,
TestQoder, TestDroid, TestGrok, TestOmp, TestOpenCodeFiles, TestOpenCodeDB,
TestOpenCodeV2, TestPi and TestList go red on Windows, each naming the
line it got. Not run: go test ./... (test-only change in one package).
2026-10-13 08:15:14 +08:00
yetone 2086884bef sessions: a session goes by the name its agent shows for it — Codex's thread name (session_index.jsonl), the one a Claude Code session was renamed to (/rename), else the title the agent made — and by its first prompt only when it has none (TJHHHH on Discord) 2026-10-05 22:23:29 +08:00
yetone 71d2da1f42 catalog, usage, gateway, gui: a price can have a long-context tier and a 1-hour cache write, and the price boxes take decimals (PAMI on Discord)
OpenAI bills gpt-6-astra, gpt-6.1-sol and gpt-6-luna over 272K input at 2× input and cache and 1.5× output, for the whole request. A price now has tiers: `magpie model price <m> 10,50,1,12.5 --tier 272k 20,75,2,25` (--tier can repeat). A tier applies when input + cache reads + cache writes is over its size, so 272,000 is not over and 272,001 is. The built-in prices take tiers only where models.dev lists one (cost.tiers of type "context"), and it does list one for those three. The ledger, each request and OTLP are costed at the tier the call reached. Session and day totals sum many calls, so they stay at the base price.

Anthropic bills a cache write kept for an hour at 2× input and one kept for 5 minutes at 1.25×. Its usage reports which is which in cache_creation.ephemeral_5m/1h_input_tokens. The gateway (API and Claude subscription) and Claude Code's transcripts now keep that split. A price's fifth part is the 1-hour write. When it isn't given, it is 2× input: that is Anthropic's rule, and only Anthropic reports 1-hour writes. Claude list prices carry the 2× too. cache_write_tokens is still the total, and the usage CSV adds cache_write_5m_tokens and cache_write_1h_tokens at the end. The app shows the split on a request's Cache and on the usage tooltips. Old prices and old records, which have no 1-hour part, read as before. The sessions cache (18) and the call cache (calls-v8) are re-read once.

In the GUI, the price boxes were number inputs and dropped what they didn't parse ("0,25"). They are now decimal text boxes that take both "0.25" and "0,25". A model's price row has a 1-hour box (empty means 2× input) and a quiet Long-context price row. That row shows the list's tier greyed in, or sits behind a link when the list has none. A bad size is refused by name. en/zh/ja/de.

Tests:
- New: TestPriceTiers, TestCostSplit, TestPriceJSON, TestModelPriceTiers, TestModelPriceTierCmd, TestAnthropicCacheWriteSplit and TestClaudeCacheWriteSplit. The ledger CSV test expects the new columns.
- model-price-tiers.test.cjs is new; model-price-edit and provider-price-rate are updated. All of them fail against the old assets and pass in WebKit. Chromium couldn't be launched here.
- go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass.
2026-10-05 21:56:59 +08:00
yetone b84b203256 sessions: Droid's (Factory CLI) sessions are listed, with what they spent and droid --resume <id> (Discord, 谟竭: "magpie中会话功能中不显示droid 这个agent") — the Sessions view read no droid sessions at all. droid keeps each under ~/.factory/sessions (or $FACTORY_HOME_OVERRIDE/.factory), a folder per cwd (older ones in sessions/ itself): <id>.jsonl starts with a session_start (id, title, cwd/lastCwd, parent + forkedAtMessageId for a fork, callingSessionId for a subagent or /btw), then message events with an ISO timestamp and Anthropic-style content; <id>.settings.json holds the running tokenUsage (inputTokens without the cache, outputTokens with thinking) for its model. The title is the first typed prompt (tagged reminders skipped), else droid's; prompts, replies and tool calls count; a subagent's spend counts in the session that called it, a fork skips the lines it copied; custom:<id> models are priced as the model their customModels entry asks for (magpie's own custom:magpie/<ref> → <ref>), else the id without droid's -[x]-N tail. The total isn't split by turn, so it counts on the day of the last message. Format read from droid 0.231.0's own code. TestDroid fails on the old code (0 sessions) and passes; go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried against a real droid session (no Factory account on this machine). 2026-10-03 15:08:41 +08:00