Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Commit da4b349

Browse files
committed
feat(grunt/tui): bare gruntcode auto-lands in session route (sidebar visible from first frame)
Refs hivemind anomalyco#229. The hivemind sidebar lives inside the session route — so bare `gruntcode` landing on the home/splash route HID the sidebar until the user submitted their first prompt. Nik's intent was 'open gruntcode tab and already be in that view, ready to type'. This effect auto-creates an empty session and navigates when: - No explicit --session / --continue / --fork - No --prompt (--prompt has its own auto-submit path on home) - Currently on home route - sync + model are ready (session.create requires agent + model) Escape hatch: OPENCODE_DISABLE_AUTO_SESSION=1 keeps legacy 'land on splash' behavior for users who prefer the home route.
1 parent 8e04da9 commit da4b349

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd/tui

‎packages/opencode/src/cli/cmd/tui/app.tsx‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,52 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
423423
}
424424
})
425425

426+
// grunt-it: bare `gruntcode` should land directly in the session view so the
427+
// hivemind sidebar is visible from the first frame, ready for input. Without this,
428+
// the user sees the splash/home route until they submit the first prompt — which
429+
// hides the sidebar (the sidebar lives inside the session route).
430+
//
431+
// We auto-create an empty session and navigate when ALL of these hold:
432+
// - No explicit --session / --continue / --fork (those have their own navigate paths)
433+
// - No --prompt (--prompt with no session would land in home + auto-submit; let it)
434+
// - Currently on home route (not already navigated elsewhere)
435+
// - sync + model are ready (session.create needs an agent + model)
436+
//
437+
// Set OPENCODE_DISABLE_AUTO_SESSION=1 to keep the legacy "land on splash" behavior.
438+
let autoCreated = false
439+
createEffect(() => {
440+
if (autoCreated) return
441+
if (process.env["OPENCODE_DISABLE_AUTO_SESSION"]) return
442+
if (args.sessionID || args.continue || args.fork || args.prompt) return
443+
if (route.data.type !== "home") return
444+
if (!sync.ready || !local.model.ready) return
445+
const agent = local.agent.current()
446+
const model = local.model.current()
447+
const variant = local.model.variant.current()
448+
if (!agent || !model) return
449+
autoCreated = true
450+
void sdk.client.session
451+
.create({
452+
agent: agent.name,
453+
model: {
454+
providerID: model.providerID,
455+
id: model.modelID,
456+
variant,
457+
},
458+
})
459+
.then((result) => {
460+
if (result.data?.id) {
461+
route.navigate({ type: "session", sessionID: result.data.id })
462+
} else {
463+
// Non-fatal: stay on home, user can submit manually + that path will create the session.
464+
autoCreated = false
465+
}
466+
})
467+
.catch(() => {
468+
autoCreated = false
469+
})
470+
})
471+
426472
// Handle --session with --fork: wait for sync to be fully complete before forking
427473
// (session list loads in non-blocking phase for --session, so we must wait for "complete"
428474
// to avoid a race where reconcile overwrites the newly forked session)

0 commit comments

Comments
 (0)