Skip to content

loadConfiguredTui

loadConfiguredTui(commandLineConfigOverrides): Promise<boolean | undefined>

Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/config/loader.ts:821

CFG-37 — the layered value of the top-level tui config key, read BEFORE a session picks its surface. chat/code choose between the Ink TUI and the readline session in the app’s startSession dispatcher, and each surface then loads its own config via initConfig — so at the moment of the choice there is no resolved GthConfig to consult, and this is the seam that supplies the one key the choice needs.

Layering matches a run: the discovered PROJECT layer wins over the GLOBAL one, and a layer that does not set tui defers to the next rather than overriding it with undefined. A scalar needs no deep merge, so this reads the two layers and picks — it does not fork the merge engine.

QUIET and fail-soft for the layers it reads ITSELF: it does not validate them and does not exit on a malformed one, because the caller runs moments before initConfig, which validates every layer and reports the very same problem — warning twice about one file is worse than not warning here. A failed read resolves to undefined, i.e. “nobody set it”, and the surface auto-detects exactly as it does for a run with no config.

ONE EXCEPTION, and it is deliberate: a tui may be INHERITED through a GS2-41 profile extends chain, so this walks that chain via the SHARED resolveConfigExtends rather than forking it — and that traversal owns its own reporting. It validates each base layer (so a base’s own unknown-key warning can appear here as well as from initConfig) and hard-exits on a cycle, a missing base or a malformed base. What the user sees is unchanged — initConfig exits on the same chain with the same message a moment later — but it now happens EARLIER, at surface selection rather than at config load. Forking the walk to silence it would mean a second inheritance engine; ignoring extends would mean silently dropping an inherited tui.

The chain is walked for BOTH layers, each on the branch a run walks it on: the project layer always, the global layer only when NO project layer was discovered (see the note at that call). The global half is the branch --global always takes, where the global layer is the only layer and an inherited tui is therefore the whole answer rather than an underlay.

Ordering: this is DETECTION, so per the GS2-11 invariant above it must run before any initConfig in the process — as it does, alongside hasAnyConfig in startSession.

CommandLineConfigOverrides

Promise<boolean | undefined>