Skip to content

Commit e70a018

Browse files
zerone0xclaude
andcommitted
fix(perf): skip models.dev refresh when running as attach client
When using `opencode attach` to connect to an already running server, the client was still performing a models.dev refresh on every connection, causing ~1 second delay. The server already has models cached, so the attach client doesn't need to fetch them. This change detects attach mode by checking process.argv and skips the automatic refresh, reducing attach startup time from ~1.2s to <100ms. Fixes anomalyco#10781 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 213c0e1 commit e70a018

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/opencode/src/provider/models.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ export namespace ModelsDev {
122122
}
123123
}
124124

125-
if (!Flag.OPENCODE_DISABLE_MODELS_FETCH) {
125+
// Skip models.dev refresh when running as attach client.
126+
// The server already has models cached, so the client doesn't need to fetch them.
127+
const isAttachMode = process.argv.some((arg) => arg === "attach")
128+
129+
if (!Flag.OPENCODE_DISABLE_MODELS_FETCH && !isAttachMode) {
126130
ModelsDev.refresh()
127131
setInterval(
128132
async () => {

0 commit comments

Comments
 (0)