Repository navigation
Conversation
A send made while Stata ran a command, or in the 50 ms before --more-- was recognized, was written straight to the pseudo-terminal: it could answer the pager, and the pane started the 30-second do-file cleanup when the terminal buffered the line, so a busy Stata could find its do-file gone. Sends now wait for a command prompt, so on_sent(true) means Stata is reading the line.
…ing partial line whole - on_sent now follows the do_async reply, so a helper that replies bridge_gone deletes the do-file at once instead of after a delay that assumed Stata had it. - A partial line flushed after 300 ms and then extended across polls (A, B, then C and a newline) showed AC: the next read subtracted the whole buffered line rather than what was on screen.
They still used sendText, which a pane that is still connecting drops.
The sends stayed pending and a later answer dispatched them from the disposed queue. Disposing now deletes their files, reports a count of 0, ends the wait for the answer, and stops any dispatch in progress.
…re-- Perch delivers sends as typed input, so the console read them as keys: at --more-- the first character answered the pager. Sessions Sight starts now carry a sight.sendChannel annotation, and sends to them are wrapped in an APC escape sequence that tty.js decodes and enters through send_line, at a prompt. tty.js also deletes the do-file once Stata has read the line (the extension used to time cleanup from queueing). Sessions without the annotation (started by an older Sight) still get keys.
…eady At the first prompt, on_ready ran before the held send was entered, so a send made from it went first. tty.js also deletes the files of sends it hasn't entered when it exits.
A held send too long to enter was answered false but left in the input and stopped the sends behind it until another prompt. Clear it, keep its note, and enter the next held send at once.
A held send could still be entered, and reported sent, if Stata showed a prompt while the backend shut down, after the pane had dropped its do-file. Shutting down now drops held sends and refuses new ones.
The COM helper calls DoCommandAsync before it writes its reply, so a helper that ends after taking the request may have started the command. Report such a line sent, which keeps its do-file for the usual cleanup delay; a request never written, or refused, is still reported dropped.
The Automation backend keeps each line until Stata is free and reports it sent only when DoCommandAsync returns, so holding sends for prompt text as well could stall them: a partial line Stata wrote later erased the backend's own prompt, and a send made after that never went although Stata was idle. Backends now say whether they wait for Stata themselves; only the PTY backend's sends wait for a prompt. Pin that a PTY send held after text that isn't a known prompt shows its note, goes after Enter brings a prompt, and is dropped by Ctrl+C.
The send channel's own decoder ran before the key decoder, so a send frame inside pasted text was run as a send, a bare Esc waited twice (Esc, a pause, then a key read as Alt+key), a frame cut short swallowed later input and Ctrl+C, and how the input was split decided whether a frame was a send or keys. The key decoder, which already tracks bracketed paste and the Esc wait, now reads frames itself (for the terminal console only): any control character or stray ESC abandons a frame and is read as usual, an oversize frame is read to its end and dropped whole, and one that stops arriving is dropped after a second. The channel can't be authenticated, so the console deletes only the extension's own temp do-files (its name pattern, directly in the directory given with --send-dir, a regular file) and ignores a send naming anything else. The --run line is entered as a send, apart from what the user typed while Stata started.
A file a console took with its line was guarded by a global held set: cleanup scheduled while a file was held skipped it for good. A Perch send never released its entry (the set grew for the life of the extension host), a queued Perch send of unknown outcome was never deleted, and a file held by a console that died stayed behind. A ready pane's send could also be scheduled for deletion twice. Now a terminal that takes a file says so (type_send returns true), and then neither the queue nor the send command cleans it up. A Perch session keeps the files handed to its console, forgets each once the console deletes it, and deletes the rest when the session ends; a send whose delivery Perch can't confirm is deleted when the session ends or after an hour. The extension passes the console its temp directory (--send-dir).
A key landing inside a send (an arrow, Ctrl+C) abandoned it, and the rest of its JSON was then read as typed text, ready for the next Enter to submit. The decoder now drops the rest of an abandoned send up to its end, the next Enter, or the one-second wait.
…d directory A session's console deletes only files in the directory it started with; a later window with another temp directory would have had every send ignored. Record the directory on the session and fall back to typed sends for files elsewhere. Keep a send of unknown outcome for a day rather than an hour, since Stata jobs often run longer.
Live runs against Stata 18 on Windows: a line sent while Stata runs a command typed into its own window is taken at once and queued, so its do-file can be deleted first; --more-- shows and is answered only in Stata's window; and sends waiting for Stata show no note.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Owner
Author
|
Note 🤖 Claude Opus 5.5 responding on behalf of jbearak Closing: Perch is archived and Sight no longer integrates with it (#449). |
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.
Parked from #426. Not ready to merge.
This branch sends editor code to a Perch console as an escape-sequence message (
ESC _ sight-send;{json} ESC \) that the console's tty.js decodes, so a send can never answer Stata's--more--prompt, and tty.js deletes each do-file after Stata reads its line. It also contains everything now in #426, plus a first fix round.Two independent reviews found problems that are still open at this head (
296a9dca):EACCES) drops ownership of a file that still exists.SIGHT_TEST_SENT_FILE_DELAY_MSshortens the file lifetime in production with no test-mode guard./is accepted and the line still runs; two spellings of the same directory fall back to typed keys.sight_console_test_…, which the real tty.js rejects, so they pass even if the console would ignore every send. The positive path tests use a literal/tmpand would fail on Windows.waits_for_stata) run an editor send ahead of a line typed while Stata was busy, and are superseded by Hold console sends for a recognized prompt, keep Windows do-files while Stata may have them, and send CD commands through the pane queue #426.The channel has no authentication: any program that can type into the session can send a line.
Proof: fake Perch and a fake Stata on a real PTY only. Never run with Perch installed.