Commit Graph

7 Commits

Author SHA1 Message Date
cg33
a82b01aa27 fix(opencode): eliminate TempDir cleanup race in TestAvailableModels under -cover (#1118) (#1254)
Root cause: AvailableModels() with a warm persistent cache calls
startPersistentModelRefresh(), which spawns a background goroutine that
writes the refreshed model list into the test's TempDir.  When the test
function returns, t.TempDir() runs RemoveAll before that goroutine
finishes its last write — manifesting as:

  TempDir RemoveAll cleanup: unlinkat /tmp/.../001: directory not empty

The race window is too small to hit reliably without -cover; coverage
instrumentation slows the goroutine enough to make it reproducible.

Fix (two-part):
1. Add refreshWg sync.WaitGroup to Agent and track every background
   refresh goroutine with Add(1)/Done() in startPersistentModelRefresh.
   This is a pure bookkeeping addition with zero production behaviour
   change.
2. In TestAvailableModels_PrefersPersistentCacheOverDiscoveredModels,
   register t.Cleanup(func() { a.refreshWg.Wait() }) immediately after
   creating the agent (before AvailableModels is called). Cleanup
   functions run LIFO: our Wait fires before t.TempDir's RemoveAll,
   guaranteeing the goroutine has finished writing before the directory
   is cleaned up.

Verified: go test -count=1 -cover ./agent/opencode/... run 10 times
consecutively — 10/10 PASS, 0 failures.

Co-authored-by: root <root@UYQQVGRAEKQKNQP>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 21:18:36 +08:00
Mr.QiuW
adeff4ef8d fix(opencode): handle signature writer errors 2026-04-09 01:18:10 +08:00
Mr.QiuW
1641c42269 feat(opencode): significantly speed up model switching 2026-04-09 01:11:19 +08:00
q107580018
bcb3b292c1 feat(opencode): implement SessionDeleter to enable /delete command (#452)
Add DeleteSession to the opencode agent by calling `opencode session delete <id>`
via the CLI, enabling single, batch, and range deletion from any connected platform.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 22:26:53 +08:00
Claude
fd9e347563 feat(opencode): dynamic model discovery via opencode models (#381)
AvailableModels now runs `<cmd> models` first and falls back to
provider-configured models and the built-in list only when the CLI
command fails or produces no output. Results are deduplicated and
sorted for stable /model output.

Co-authored-by: q107580018 <107580018@qq.com>
Made-with: Cursor
2026-03-31 19:44:42 +08:00
Claude
76e62c7be7 test: improve coverage across agents and platforms
- agent/claudecode: Add tests for Name, CLIBinaryName,
  CLIDisplayName, SetWorkDir, GetWorkDir, SetModel, SetSessionEnv,
  SetPlatformPrompt, stripXMLTags
- agent/opencode: Add tests for normalizeMode, Name, SetModel,
  GetMode, GetActiveProvider, ListProviders, SetActiveProvider
- agent/qoder: Add tests for normalizeMode, Name, CLIBinaryName,
  CLIDisplayName, SetWorkDir, SetModel
- platform/line: Add tests for Platform initialization, Name,
  credential validation, port/path configuration
- platform/qq: Add tests for Platform initialization, ws URL,
  token, allowFrom, shareSessionInChannel
- platform/qqbot: Add tests for Platform initialization,
  credential validation, intents, sandbox, markdown support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 00:22:40 +08:00
Deeka Wong
1123c83edb fix(core): share provider model lookup and stabilize tests (#210)
* fix(core): share provider model lookup and stabilize tests

* fix(tests): address PR review follow-ups

---------

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
2026-03-19 07:55:48 +08:00