Repository navigation
feat: fallback session titles from the first prompt - #31
Conversation
Adds a keyboard row above the agent/context grid that switches to the other project in one tap. Target: the project the last switch moved away from (settings.swapProject), falling back to the most recently active other project. The press is allowed while the session is busy: it detaches the running session instead of blocking. i18n for all locales and PRODUCT.md updated.
The project list can return entries without a name (cached session directories), which made the swap confirmation show the full worktree path.
The bottom keyboard now shows a single model button carrying the active thinking-effort variant; the separate variant button is gone. Tapping it opens the model list as before, and picking a model still opens the variant picker after the confirmation. Picking the already-active model now re-opens the variant picker with the current variant marked instead of silently resetting it to default; when the model offers no variant choice, a toast explains it. Also updated tests and PRODUCT.md.
The provider browser callback handler was defined twice with identical bodies; the second definition silently won at runtime. Keep a single copy.
- saved sessions: bottom-keyboard "Sessions" button with a menu to bookmark the current session (per project), open a bookmarked one, or drop it; bookmarks live in settings.json - prompt queue: the per-message menu now works while the session is busy, a dispatch skipped by a busy re-mark is retried instead of stranding the queue, and abort / project switch report the prompts they discard; the queued-button icon becomes an hourglass - project swap: lands on the target project's most recent session and releases the detached session's local busy and run state
… project swap - adopt the session variant when present; otherwise keep the effective variant (same model) or resolve the model's configured default - resolve the effective variant centrally (getStoredModel/getCurrentVariant share resolveVariant), also for the prompt - drop the synthetic Default row from the variant picker; a lone real variant is still offered when it is not the active one - tests: session adoption, resolution regressions (real config), variant menu (mocked and real-catalog chains)
- let the ⭐ button and the saved-menu callbacks through the busy guard - bookmarking/dropping entries are local; opening another session detaches the active run (same semantics as the project swap) - tests: busy-guard matrix with real modules and handler integration
- strip trailing commas (string-aware) before JSON.parse; warn once when the config cannot be loaded - keeps config-based variant defaults (reasoningEffort) working with real-world opencode.jsonc files - tests: mixed JSONC fixture, invalid-config warn-once, adversarial string/URL cases
|
|
↪️ En respuesta a tu comentario de TOCTOU (issuecomment-5921527924): Resuelto en |
Por qué
Todas las sesiones creadas desde Telegram aparecían como
New session - <ISO>. El servidor de OpenCode asigna ese título por defecto y su agentetitlesolo lo sustituye una vez, tras el primer mensaje; si esa llamada falla, el error se ignora y no se reintenta (issues upstream #30662, #31042, #13710; caso documentado con modelos del proveedoropencode/opencode-go). El bot no puede arreglar el upstream, así que añade un fallback propio.Qué incluye
1. Fallback en el bot. Cuando el bot crea una sesión y al terminar el primer turno el título sigue siendo el default del servidor, el bot lo actualiza con el contenido del primer mensaje del usuario (primera línea, saneada, máx. 64 chars).
Cubre las 3 vías de creación de sesión del bot:
src/bot/handlers/prompt.ts— auto-creación al primer mensaje sin sesión activa.src/bot/commands/new-command.ts—/new+ primer mensaje.src/bot/callbacks/command-catalog-callback-handler.ts— comandos del catálogo.Helpers puros en
src/app/utils/session-title.ts(isDefaultSessionTitle,deriveTitleFromPromptcon corte en palabra y sin partir pares surrogate) y estado en memoria ensrc/app/services/session-title-fallback-service.ts. El intento se dispara al quedar idle la sesión (event-subscription-service.ts), de modo que si OpenCode sí generó un título propio, el suyo se conserva.2. Script de backfill
scripts/backfill-session-titles.ts(dry-run por defecto) para renombrar sesiones ya existentes que siguen con el título default usando su primer mensaje de usuario.Decisión: no pisar títulos propios
Verificación
tests/app/utils/session-title.test.ts,tests/app/services/session-title-fallback-service.test.ts,tests/bot/services/session-title-fallback-idle.test.ts,tests/scripts/backfill-session-titles.test.ts; adaptadostests/bot/handlers/prompt.test.ts,tests/bot/commands/new.test.ts,tests/bot/commands/commands.test.ts.bun run check→ EXIT=0 (2015 pass / 3 skip / 0 fail, 179 ficheros), eslint limpio.bun run scripts/backfill-session-titles.ts --dry-runreal contra el servidor local (6 GET, 0 PATCH; títulos derivados recalculados 5/5 coincidentes);--applyvalidado contra servidor falso (solo PATCH a default, errores por sesión continúan).--applyno se ha ejecutado en real.fetch; regex contra 5 títulos default reales del servidor: 5/5 match; regresión de surrogate cubierta por test.Notas
feat/session-select-last-response(stack feat: quick project swap from the bottom keyboard #27→feat: unify model and thinking-effort controls into one keyboard button #28→feat: saved sessions, plus queue and swap reliability fixes #29→feat: send the recap and repost the last assistant message when opening a session #30). CI (.github/workflows/ci.yml) solo corre con basemain, por lo que aquí no habrá checks; la gate local esbun run check.