-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Issue Summary
When using TabbedTerminal or createTab() with initialCommand parameter on Windows, appending \n to the command causes the cursor to appear at the START of the command instead of executing it.
Reproduction Steps
- On Windows (PowerShell or CMD)
- Create a TabbedTerminal with
initialCommand = "cd C:\path; clear; echo test\n" - Observe: Command text appears in terminal, but cursor is at the START of the command line
- Expected: Command should execute automatically (like it does on Linux/macOS)
Actual Behavior on Windows
cd C:\path; clear; echo test
█ <-- cursor here (at start)
User must press Enter manually to execute the command.
Expected Behavior
cd C:\path; clear; echo test
C:\path> █ <-- cursor here (after execution)
Command should auto-execute, just like on Linux/macOS.
Root Cause Analysis
BossTerm on Windows appears to process the \n character before rendering the command text:
- Processes
\n→ moves to next line - Displays command text
- Stops (no execution)
On Linux/macOS, BossTerm processes it correctly:
- Displays command text
- Processes
\n→ executes command
Platform Details
- OS: Windows 10/11
- Shell: PowerShell 5.x / PowerShell 7.x / CMD
- BossTerm Version: 1.0.82
- Kotlin Version: 2.0.21
Code Example
val state = rememberTabbedTerminalState()
TabbedTerminal(
state = state,
initialCommand = "echo 'Hello World'\n", // Appends \n for auto-execution
workingDirectory = "C:\Users\username\project",
modifier = Modifier.fillMaxSize()
)Result on Windows: Text appears, cursor at start, needs manual Enter
Result on Linux/macOS: Text appears and executes automatically ✓
Workaround (Temporary)
Use sendInput() after terminal initialization instead of initialCommand:
val state = rememberTabbedTerminalState()
TabbedTerminal(
state = state,
initialCommand = null, // Don't use initialCommand
workingDirectory = workingDirectory,
modifier = Modifier.fillMaxSize()
)
LaunchedEffect(Unit) {
delay(150) // Wait for terminal init
val enterKey = if (isWindows) "\r" else "\n"
state.sendInput("$command$enterKey".toByteArray(Charsets.UTF_8))
}This works correctly on all platforms.
Suggested Fix
BossTerm should handle initialCommand with trailing \n consistently across all platforms:
- Display the command text first
- Then process the
\nto execute it
Or alternatively:
- Automatically append
\non Windows (like it does on Linux/macOS) - Document the platform difference if this behavior is intentional
Impact
This affects any application using BossTerm that wants to auto-execute commands on Windows, including:
- Workspace initialization commands
- Runner/task execution in terminal tabs
- Any automated terminal command execution
Context
Discovered while working on BossConsole's workspace and runner integration. We attempted to fix this by appending \n to initialCommand on Windows (commits 529ab6ca and 5ebc65b2), but this resulted in the cursor appearing at the start of the command line instead of executing the command.