PyModel/pythinker-code / .agents/skills/opentui
opentui
VerifiedBuild terminal UIs with OpenTUI. Covers core, components, audio, keymaps, React, Solid, plugins, testing, standalone executables, QR encoding, SSH, and Three.js WebGPU.
docs/core-concepts/console.mdx
View on GitHub---
title: Console overlay
description: Built-in debugging console for TUI applications
order: 7
---
# Console overlay
OpenTUI includes a built-in console overlay that captures all `console.log`, `console.info`, `console.warn`, `console.error`, and `console.debug` calls. You can position the console at any edge of the terminal. It supports scrolling and focus management.
## Basic usage
```typescript
import { createCliRenderer, ConsolePosition } from "@opentui/core"
const renderer = await createCliRenderer({
consoleOptions: {
position: ConsolePosition.BOTTOM,
sizePercent: 30,
},
})
// These appear in the overlay instead of stdout
console.log("This appears in the overlay")
console.error("Errors are color-coded red")
console.warn("Warnings appear in yellow")
```
## Console vs stdout
`consoleMode` controls only the overlay surface. To disable global `console.*` capture, set `OTUI_USE_CONSOLE=false`.
`externalOutputMode` controls writes through the renderer's configured `stdout.write`. `stderr` is separate.
## Configuration options
```typescript
const renderer = await createCliRenderer({
consoleOptions: {
position: ConsolePosition.BOTTOM, // Position on screen
sizePercent: 30, // Size as percentage of terminal
colorInfo: "#00FFFF", // Color for console.info
colorWarn: "#FFFF00", // Color for console.warn
colorError: "#FF0000", // Color for console.error
startInDebugMode: false, // Show file/line info in logs
},
})
```
## Console positions
```typescript
import { ConsolePosition } from "@opentui/core"
ConsolePosition.TOP // Dock at top
ConsolePosition.BOTTOM // Dock at bottom
ConsolePosition.LEFT // Dock at left
ConsolePosition.RIGHT // Dock at right
```
## Toggling the console
Toggle the console overlay in code:
```typescript
// Toggle visibility and focus
renderer.console.toggle()
// When open but not focused, toggle() focuses the console
// When focused, toggle() closes the console
```
## Console shortcuts
When the console is focused:
| Key | Action |
| ---------- | -------------------------- |
| Arrow keys | Scroll through log history |
| `+` | Increase console size |
| `-` | Decrease console size |
## Keybinding for toggle
Add a keyboard shortcut to toggle the console:
```typescript
renderer.keyInput.on("keypress", (key) => {
// Toggle with backtick key
if (key.name === "`") {
renderer.console.toggle()
}
// Or with a modifier
if (key.ctrl && key.name === "l") {
renderer.console.toggle()
}
})
```
## Why use the console?
Terminal UI applications capture stdout for rendering. Regular `console.log` calls would interfere with your interface. The console overlay solves this problem:
- Captures all console output without disrupting the UI
- Displays logs in a dedicated overlay area
- Color-codes different log levels for easy identification
- Lets you scroll through history for debugging
## Environment variables
Control console behavior with environment variables:
```bash
# Disable console capture entirely
OTUI_USE_CONSOLE=false bun app.ts
# Start with console visible
SHOW_CONSOLE=true bun app.ts
# Dump captured output on exit
OTUI_DUMP_CAPTURES=true bun app.ts
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |