Skip to content

Status panel disappears after /fg command — missing suspend/restore lifecycle #224

Description

@xinhuagu

Bug Description

The status panel (bottom bar showing jobs, tokens, session info) disappears after using the /fg command to bring a background task to the foreground. Once gone, it never comes back for the rest of the session.

Root Cause

The /fg command handler (handleFgCommand) is missing suspendStatusPanel() / restoreStatusPanel() calls that the normal submitTask → setForeground path correctly includes.

Normal path (✅ correct) — TerminalRepl.java:896-916

suspendStatusPanel();           // line 896
taskManager.setForeground(...);
waitForForeground(out, reader);
renderTaskCompletion(out, result);
taskManager.clearForeground();
restoreStatusPanel();           // line 916

/fg path (❌ missing) — TerminalRepl.java:2800-2811

// No suspendStatusPanel() call
taskManager.setForeground(target.taskId());
waitForForeground(out, reader);
renderTaskCompletion(out, target);
taskManager.clearForeground();
// No restoreStatusPanel() call

Why it causes the panel to vanish

  1. Without suspendStatusPanel(), the foreground task writes directly to the terminal, conflicting with JLine's scroll region managed by the Status widget
  2. Without restoreStatusPanel(), JLine's Status widget remains in a broken state after the task completes
  3. renderStatusFrame has a guard if (taskManager.hasForegroundTask()) return; (line 1558) — correct during fg task, but after clearForeground the widget is already corrupted

Suggested Fix

// In handleFgCommand, add suspend/restore around the foreground block:
suspendStatusPanel();                    // ← add
taskManager.setForeground(target.taskId());
waitForForeground(out, reader);
renderTaskCompletion(out, target);
taskManager.clearForeground();
activeForegroundSink = null;
restoreStatusPanel();                    // ← add

Steps to Reproduce

  1. Start a task (e.g. ask a question)
  2. Press Ctrl+Z to background it
  3. Run /fg to bring it back to foreground
  4. After task completes, observe the status panel is gone

Expected Behavior

Status panel should reappear after the /fg task completes, same as normal task flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions