You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/plugin/pty/tools/read.ts
+58-28Lines changed: 58 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,16 @@ import { formatLine } from '../formatters.ts'
6
6
importtype{PTYSessionInfo}from'../types.ts'
7
7
importDESCRIPTIONfrom'./read.txt'
8
8
9
+
constNOTIFY_ON_EXIT_REMINDER=[
10
+
`<system_reminder>`,
11
+
`This session was started with \`notifyOnExit=true\`.`,
12
+
`Completion signal is the future \`<pty_exited>\` message, not repeated \`pty_read\` calls.`,
13
+
`If you only need to know whether the command finished, stop polling and wait for \`<pty_exited>\`.`,
14
+
`Do not use sleep plus \`pty_read\` loops to check completion.`,
15
+
`Use \`pty_read\` only when you need live output now, the user explicitly asks for logs, or the exit notification reports a non-zero status and you need to investigate.`,
constpaginationMessage=`(Buffer has more lines. Use offset=${result.offset+result.lines.length} to read beyond line ${result.offset+result.lines.length})`
130
157
constendMessage=`(End of buffer - total ${result.totalLines} lines)`
Copy file name to clipboardExpand all lines: src/plugin/pty/tools/read.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ Tips:
28
28
- To tail recent output, calculate offset as (totalLines - N) where N is how many recent lines you want
29
29
- Lines longer than 2000 characters are truncated
30
30
- Empty output may mean the process hasn't produced output yet
31
+
- If the session was started with `notifyOnExit=true`, do not use repeated `pty_read` calls only to detect completion; wait for the future `<pty_exited>` message instead
`Completion signal for this session is the future \`<pty_exited>\` message.`,
9
+
`If you only need to know whether the command finished, do not call \`pty_read\`; wait for \`<pty_exited>\`.`,
10
+
`Never use sleep plus \`pty_read\` loops to check completion for this session.`,
11
+
`Call \`pty_read\` before exit only if you need live output now, the user explicitly asks for logs, or the exit notification reports a non-zero status and you need to investigate.`,
Copy file name to clipboardExpand all lines: src/plugin/pty/tools/spawn.txt
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,11 @@ When `notifyOnExit` is true, you will receive a message when the process exits c
34
34
- Last line of output (truncated to 250 chars)
35
35
36
36
This is useful for long-running processes where you want to be notified when they complete
37
-
instead of polling with `pty_read`. If the process fails (non-zero exit code), the notification
38
-
will suggest using `pty_read` with the `pattern` parameter to search for errors.
37
+
instead of polling with `pty_read`.
38
+
- Completion signal is the future `<pty_exited>` message
39
+
- If you only need to know whether the command finished, do not call `pty_read`; wait for `<pty_exited>`
40
+
- Never use sleep plus `pty_read` loops to check completion
41
+
- Use `pty_read` before exit only if you need live output now, the user explicitly asks for logs, or the exit notification reports a non-zero status and you need to investigate
39
42
40
43
Examples:
41
44
- Start a dev server: command="npm", args=["run", "dev"], title="Dev Server"
0 commit comments