fix(trigger-watcher): discrete-Enter submit + chain triggers; prune stale sidebar cache - #33
Merged
Merged
Conversation
Two coupled changes:
1. chain field — a trigger may carry `chain: [{command, timeout_ms?}, ...]`
instead of a single `command`. Steps are injected sequentially, each
waiting for the prior turn to complete (busy then idle) before the next,
under a shared global deadline. Lets one trigger drive a /compact then a
resume prompt without racing on a shared idle tick.
2. discrete-Enter submit — write the command text and the Enter keypress as
SEPARATE PTY writes (SUBMIT_ENTER_DELAY_MS apart). A CR concatenated onto
the text in a single write is absorbed by Claude Code (kitty keyboard
protocol) as a literal newline and the command never submits; only a
discrete CR submits, mirroring how xterm sends each keypress. Fixes
free-text trigger commands landing in the composer unsubmitted while the
short menu-driven /compact path appeared to work.
Tests: 101 passing (node:test). Write-shape assertions updated for the
two-write submit; makeChainCtx starts a turn only on the discrete Enter.
Call populateCacheViaWorker() unconditionally in app.whenReady so deleted transcripts (sub-agent / workflow runs cleaned up between sessions) are evicted from session_cache on the next launch. The worker does a deleteCachedFolder + upsert per folder — a full prune — and runs in a Worker thread so startup is non-blocking. Concurrent callers (FTS-recreated path, first get-projects call) share the in-flight Promise via the existing guard, so no double scan occurs. Previously the prune only ran when isCachePopulated() was false (cold DB after migration) or when searchFtsRecreated was set, leaving ~457 stale rows visible in the sidebar across normal restarts.
JeanBaptisteRenard
force-pushed
the
fix/trigger-watcher-discrete-submit
branch
from
June 2, 2026 00:16
13185c8 to
528513e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two fixes to the trigger-watcher input-injection path and the sidebar session cache, bundled because they were built and live-verified together in one AppImage.
1. Discrete-Enter submit + chain triggers (
trigger-watcher.js)Bug: the watcher wrote
command + '\r'in a single PTY write. Under Claude Code's kitty keyboard protocol, a CR concatenated onto text is absorbed as a literal newline in the composer — it does not submit. Only a discrete Enter keypress (a separate write) submits. So harness-injected prompts appeared in the input box but were never sent; the user had to press Enter manually.Fix:
submitToPty(pty, command)writes the command, waits a short configurable delay, then writes\ras its own discrete write. Delay defaults to 50 ms, overridable viaSWITCHBOARD_SUBMIT_ENTER_DELAY_MS.Also lands the chain trigger feature: a trigger file may carry
chain: [{command, timeout_ms?}, ...]; steps run sequentially, waiting for the terminal to go busy→idle between steps (waitForTurnComplete). Enables multi-step harness sequences (e.g./compactthen a resume prompt) from one trigger.2. Prune stale cache rows on startup (
main.js)Sidebar listed workflow-spawned sessions whose transcripts no longer exist ("uuid introuvable" ghosts). Added a startup cache rebuild so deleted-file rows are pruned on launch, not only during full folder refreshes.
Testing
test/trigger-watcher.test.jsextended (+612): discrete-Enter assertions (writes split intocommandthen\r), chain sequencing, busy→idle gating.SWITCHBOARD_SUBMIT_ENTER_DELAY_MS=1in tests to keep them fast.npm run build:linux, deployed, and live-verified 2026-06-02: auto-submit of both/compactand a free-text resume prompt confirmed end-to-end (ACK-FIX-OK).Notes
submitToPtyis async; both the single-command and chain-step write sites nowawaitit.