Skip to content

Reorder sessions with option+up/down and keep the dashboard open after background launches - #28

Closed
moritzWa wants to merge 66 commits into
xhluca:mainfrom
moritzWa:session-reorder-background-launch
Closed

moritzWa wants to merge 66 commits into
xhluca:mainfrom
moritzWa:session-reorder-background-launch

Conversation

@moritzWa

@moritzWa moritzWa commented Oct 1, 2026

Copy link
Copy Markdown

Stacked on #24 (composer-cd-word-jump), which brings #14 (pin-sessions) and the paste guard with it, plus #19 (directory-creation-order) merged in. Until those merge, the diff shows them too. This PR's own change is the last commit.

What

Reorder sessions. option+up and option+down move the selected session one place within its directory group, or within the Pinned group in either view. In status view an unpinned row gets a hint to switch views, since those groups are by state.

  • Directory groups sort by a per-session key that defaults to the start time from Keep directory view rows in creation order so replying does not move them #19. A move swaps the two rows' keys and saves them in a new order.rs record (session-order.json, same private-file and locking rules as pins), so moved rows keep their place and new sessions still arrive at the top. When keys tie, for example sessions without a start time, the group is first given distinct keys in its current order, so a move always shifts exactly one place.
  • Pinned rows swap their pin times instead, through a new PinnedSessions::set_pinned_at.
  • macOS Terminal with "Use Option as Meta key" sends Option+Up as ESC ESC [ A, which crossterm 0.27 reads as Esc followed by typed [A. A small MetaArrowReader in front of the paste classifier rejoins ESC [ A/B/C/D and ESC O A/B/C/D arriving in the same read into Alt+arrow, and replays anything else unchanged. That also fixes Option+Left/Right word jumps in the composer for that setting.

Launches stay on the dashboard. Starting a task with a harness that can launch in the background (Claude Code on the host, Codex and OpenCode with their supervisors, Cursor on Linux) no longer opens the new session once discovery lists it. The dashboard stays on the list with the new row selected; Enter/Right opens it. Harnesses that can only start in their own interface still take over the terminal. The open_when_visible plumbing is removed.

Tests

  • App: moves swap neighbours and keep newer sessions on top, tied keys move exactly one place, Pinned group reorders, status view explains where moving works.
  • Terminal: Option+arrows dispatch the move; ESC [ A, ESC O B become Alt+arrows while ESC [ x and ESC q replay unchanged.
  • order.rs round trip.
  • Real TTY: the Claude launch test now checks the dashboard stays put after launch and Enter attaches the native screen.
  • cargo test passes on macOS, cargo fmt --check is clean, and cargo +1.75.0 build --release --locked succeeds.

Moritz Wallawitsch and others added 30 commits September 28, 2026 18:56
The dashboard always painted a dark background. Auto mode now uses the terminal background first, then the system appearance, with an explicit dark or light override.

Co-authored-by: Cursor <cursoragent@cursor.com>
Without bracketed paste, every line break in a pasted clipboard arrived as Enter and launched a session. A large paste could start hundreds of coding-agent sessions at once. Enable bracketed paste, insert Event::Paste as text, and on legacy terminals treat an Enter in the middle of a queued input burst as a pasted line break.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The light background was a warm off-white that read as beige next to a
light editor. Switch the light palette to pure white with VS Code Light's
greys, blue accent, warning amber, and green.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cursor's CLI persists each chat under ~/.cursor/chats/<md5 cwd>/<id>/ with
meta.json (title, cwd, timestamps) and prompt_history.json. Read those to list
external Cursor sessions on macOS and Linux, not only OAV-launched ones.

Liveness: verify the PIDs Cursor records under
~/.local/share/cursor-agent/versions/*/.running/, then map each live process to
the store.db it holds open (/proc/<pid>/fd on Linux, lsof -F pn -p elsewhere).
A held chat is working if its store/meta changed in the last 20 s, otherwise
waiting at prompt; unheld chats are closed history bounded by --history-limit.

Rows are observe/native-open: Enter resumes via cursor-agent --resume, Inspect
shows the recorded prompts. The managed Linux source still owns the chats it
launched; the history source skips those IDs. Add --cursor-chats-dir.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
--theme auto resolved once at startup, so switching the desktop between light
and dark left the palette stuck until restart. Poll the OS appearance every two
seconds on a background thread and swap palettes when it changes. Only real
changes are reported: the startup choice (which may come from the terminal
background rather than the OS) stands until the user actually switches.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The return gesture stopped the provider process group with SIGTSTP and
SIGSTOP. A Cursor turn lives in that process, so leaving the screen aborted
the in-flight request and made a second agent impossible. Leave the process
on its private pseudo-terminal and drain the output until the row is opened
again.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…rows

ctrl+g opens a searchable list of sessions hidden with ctrl+x, newest hide
first, matching name, harness, or ID. Enter unhides the choice and selects
its row once discovery lists it again, so an old session can be brought back
without leaving the dashboard.

When the selected row disappears (hidden, deleted, or dropped by a refresh),
move the cursor to the row that followed it in the previous order, or the one
before it at the end of the list, instead of the first row of the first group.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
A chat kept running behind the dashboard showed "needs input" whenever
Cursor went more than 20 s without writing its store, which happens during
long thinking and tool calls. The drain now publishes the latest screen
text, and Cursor rows held by this dashboard use Cursor's own
"ctrl+c to stop" composer hint to tell working from waiting.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Cmd+P arrives as ctrl+p with this keyboard layout, and the super modifier
is accepted too. Pinned rows leave their status or directory group and stay
in a leading Pinned group, newest pin first, until toggled off.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Answer cursor-position and primary device attribute queries from the
detached screen, keep draining after unexpected poll or read errors, and
drop dead sessions outside the registry lock. Document that the provider
keeps running until Ctrl+X or dashboard exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An external chat whose store.db is open in a live cursor-agent now fails
Enter/Right with "chat is open in cursor-agent (pid N); close it there
first" instead of starting a second process on the same chat store. This
mirrors the existing refusal for active managed Cursor and Pi sessions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Skip a workspace or chat directory that vanishes or cannot be read
  mid-scan instead of failing the whole source for that refresh.
- Resolve the default chat store at discovery time and fall back to
  USERPROFILE when HOME is unset, so a missing home fails this source
  alone instead of startup.
- Read the managed registry's chat IDs once per discovery under a
  single lock. A registry read error now skips the listing for that
  refresh instead of failing open into a duplicate row.
- Inspect probes each workspace directory for the chat ID and reads one
  meta.json instead of rescanning every chat.
- Run lsof with -n -P so the probe never waits on DNS or port lookups.
- Gate the macOS-only lsof request type and timeout so Linux builds do
  not warn about unused items.
- Describe store.db as not parsed rather than encrypted, and document
  that running-state detection is macOS/Linux only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moritz Wallawitsch and others added 29 commits September 29, 2026 15:17
…atus

# Conflicts:
#	CHANGELOG.md
#	src/native_session.rs
Cursor hides the "ctrl+c to stop" hint whenever the composer holds text,
so a follow-up typed mid-turn flipped the row to "needs input" for the
rest of the turn, and so did a blank, login, or unrecognised screen. The
hint now counts only at the end of one of the bottom rows, waiting needs
the empty idle composer's placeholder, and anything else falls back to
the store timestamps.

The background screen also now comes with its child's pid and is used
only while that child is alive and is the process holding the chat, so a
crashed background agent's last screen cannot speak for a chat resumed
elsewhere. The detached-output test polls for the published screen
instead of sleeping a fixed time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A macOS session leader cannot finish exiting while its controlling terminal
still holds output nobody has read. The test stopped reading after the last
marker, so the child's final libtest lines left it stuck in exit and the
suite hung (about 3 in 20 runs once providers keep running in the background).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vider

Leaving the alternate screen restores the provider's last frame before the
bridge puts the terminal back in raw mode, so the screen check could pass
early. Text typed in that gap was echoed and its Enter arrived as a newline,
so the fixture never saved the turn and the live-preview check timed out.
Count the repaint bytes after Enter instead of reading the restored screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sions

# Conflicts:
#	CHANGELOG.md
#	docs/control-model.md
# Conflicts:
#	CHANGELOG.md
#	src/native_session.rs
…ions

# Conflicts:
#	CHANGELOG.md
#	docs/cli.md
Moving a row into or out of the Pinned group now selects and reveals it
there, so it no longer lands in a collapsed group or past the page. After
saving, the screen takes its pins from the registry, so a pin that fails to
save is taken back instead of looking persisted. Also formats the merged
module list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Off Linux a chat started from the harness list only appeared through the
history source, which needs --include-external, so the default dashboard
reported a backgrounded chat with no row. The controller now records each
chat it creates in a private cursor-owned.json, and the history source lists
recorded chats without external discovery. Opening such a row reattaches the
dashboard's own background terminal instead of refusing it as held by
another cursor-agent.

Also:
- Refuse Cursor prompts starting with '-', which cursor-agent would parse
  as options such as --force; its help documents no end-of-options marker.
- Share one model-catalog parser between host and managed Cursor, rendering
  away the colours FORCE_COLOR adds and skipping the Tip line.
- Refuse background Cursor launch off Linux instead of dropping the prompt.
- Report Cursor launch as unavailable on Linux without the supervisor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCode rows were always reported as completed. A session a live opencode
process runs is now working or needs input: the background screen decides
for frontends this dashboard holds (which also catches permission and
question panels), otherwise the newest message written since the holder
started. Subagent sessions are no longer separate rows.

Outside Linux, choosing OpenCode opens its interface with the task
submitted and records the created session as the dashboard's own.
- A session in the middle of a turn is credited to the opencode process in
  its directory before a session that process merely created, so a long
  tool call in a resumed session no longer reads as completed.
- A turn counts as current when any process that could be running it
  started before it, and an idle prompt on the dashboard's own screen yields
  to a database that shows work, so opening a session another process is
  running does not make it look idle.
- A background subagent keeps its parent working.
- OpenCode 1.18.34's --prompt only prefills the editor, so the launch task
  is pasted once the empty editor is on screen and then entered.
…essions

Shift/Ctrl/Alt+Enter and Ctrl+J add a line, pastes keep their lines, and a cursor moves through the draft. The ctrl+g picker also lists OpenCode sessions the dashboard does not show; Enter adopts one into the ownership registry so its row stays listed.
…ession-reorder-background-launch

# Conflicts:
#	CHANGELOG.md
#	src/app.rs
@xhluca xhluca closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants