diff --git a/app/server/engine.js b/app/server/engine.js index 0cf3f7c..f7da323 100644 --- a/app/server/engine.js +++ b/app/server/engine.js @@ -433,16 +433,25 @@ function sessionContextContent(session) { ].join('\n'); } -function createSession(title) { +function createSession(title, preferModelId) { const id = genTaskId(); const dir = taskDirOf(id); fs.mkdirSync(dir, { recursive: true }); db.prepare( "INSERT INTO sessions (id, title, status, phase, model_id, created_at, updated_at) VALUES (?,?,'queued','planning',NULL,?,?)" ).run(id, title || '', now(), now()); - enqueue(id); - dispatchQueued(); - // 放在 dispatchQueued 之后:若能立即绑到空闲模型,上下文里就能带上模型显示名。 + // 指定了模型且它恰好空闲 → 直接绑定,跳过排队;否则回退到 FIFO 队列 + const prefer = preferModelId + ? db.prepare('SELECT * FROM model_pool WHERE id = ? AND is_busy = 0').get(preferModelId) + : null; + if (prefer) { + bindModel(getSession(id), prefer); + emitStatus(id); + } else { + enqueue(id); + dispatchQueued(); + } + // 放在绑定/派发之后:若能立即绑到空闲模型,上下文里就能带上模型显示名。 const session = getSession(id); saveMessage(id, { role: 'user', name: SESSION_CONTEXT_NAME, content: sessionContextContent(session) }); return session; diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 44e40a2..091ebfd 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -258,6 +258,12 @@ body { padding: 10px 12px; font-size: 15px; margin-bottom: 10px; outline: none; } .modal input:focus { border-color: #2a5299; } +.modal select { + width: 100%; border: 1px solid #dde; border-radius: 8px; + padding: 10px 12px; font-size: 15px; margin-bottom: 10px; outline: none; + background: #fff; color: #334; appearance: auto; +} +.modal select:focus { border-color: #2a5299; } .modal-close-btn { position: absolute; right: 10px; top: 10px; background: none; border: none; cursor: pointer; color: #99a; diff --git a/app/server/public/index.html b/app/server/public/index.html index a9099a1..dcf18a9 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -39,7 +39,7 @@