Skip to content

[Bug]: Terminal stays empty and does not open at folder path on first attempt #28

@matiaspalmac

Description

@matiaspalmac

Describe the bug

When opening the terminal (Ctrl+J) with a folder already open, the terminal renders blank — no prompt, no output — and the shell is never spawned at the folder path. Opening the same folder again (or any path change) makes it work.

Root cause is a race between the activePtyPath.current short-circuit in apps/desktop/src/components/Terminal.tsx and React's Strict Mode double-invocation of effects in dev:

  1. Mount: effect runs. activePtyPath.current = targetPath is set at the top of the effect, before any async work.
  2. Strict Mode synthetic unmount: cleanup runs, isCanceled = true.
  3. Inside the in-flight setupPty, the if (isCanceled) check fires right after await listen() — the function returns without calling spawn_pty.
  4. Strict Mode remount: effect runs again. activePtyPath.current is still the targetPath from step 1, so activePtyPath.current === targetPath is true and the effect early-returns before setupPty is even called.

Result: the PTY is never spawned on first open. Opening a different folder (or the same one again, if the state update creates a new ref) flips activePtyPath.current !== targetPath and unblocks the effect.

Debug trace confirming this (temporary logging inserted):

[TermDebug] setupPty start | targetPath= C:\Proyectos\... rootPath= C:\Proyectos\... terminalPath= null
[TermDebug] calling kill_pty
[TermDebug] registering pty-output listener
[TermDebug] listener ready
[TermDebug] cancelled before spawn, unlistening

No further setupPty start log follows — the remount effect is silently skipped by the activePtyPath check.

Steps to Reproduce

  1. pnpm desktop.
  2. File → Open Folder → pick any folder.
  3. Ctrl+J to open the bottom terminal panel.
  4. The panel is empty — no prompt, no cursor output.
  5. Reopen the same folder (or a different one) → terminal now works at the new path.

Trixty Version

v1.0.8 (main @ 50923f8)

OS

Windows

Fix yourself?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions