appintents: expose PID and TTY on TerminalEntity#11354
appintents: expose PID and TTY on TerminalEntity#11354ocean6954 wants to merge 1 commit intoghostty-org:mainfrom
Conversation
| } | ||
|
|
||
| // Returns the PID of the child process, or nil if not available. | ||
| var childPID: Int32? { |
There was a problem hiding this comment.
These should live on the Ghostty.Surface model instead of here, its been a long transition to move over there.
| } | ||
|
|
||
| /// Returns the PID of the child process, or -1 if not available. | ||
| pub fn childPid(self: *Surface) i32 { |
There was a problem hiding this comment.
We should use native Zig optionals here, not sentinel integral values.
| } | ||
|
|
||
| /// Returns the TTY device name (e.g. "/dev/ttys003"), or null if not available. | ||
| pub fn ttyName(self: *Surface) ?[*:0]const u8 { |
| @@ -586,6 +586,7 @@ const Subprocess = struct { | |||
| screen_size: renderer.ScreenSize, | |||
| pty: ?Pty = null, | |||
| process: ?Process = null, | |||
| tty_name: ?[*:0]const u8 = null, | |||
There was a problem hiding this comment.
Store as a zig type, not this.
|
Hi @ocean6954, just checking in — are you still working on this? I have a use case for this feature (switching to Claude Code sessions by PID in a terminal switcher app). Let me know if there's anything I can help with! |
|
Hi @grimmerk Sorry for the late reply! I had already pushed the fixes but wasn't sure how to re-request a review — I just did that now. Thanks for your interest in this feature! |
|
also looking for this! |
|
@ocean6954 Did you want to rebase this on top of the core changes from #11639 ? |
| void ghostty_surface_update_config(ghostty_surface_t, ghostty_config_t); | ||
| bool ghostty_surface_needs_confirm_quit(ghostty_surface_t); | ||
| bool ghostty_surface_process_exited(ghostty_surface_t); | ||
| int32_t ghostty_surface_child_pid(ghostty_surface_t); |
There was a problem hiding this comment.
What do you think about returning a pid_t? That is the POSIX type for an integer representing a process ID.
Only using 32 bits is restrictive, while pid_t is kind of opaque in that each platform can define it differently. You never know if Ghostty will exist on platforms supporting larger that 32 bit process IDs. I would assume that there are equivalent types in Swift and Zig.
There was a problem hiding this comment.
The core API returns a u64. I chose that specifically over a pid_t to avoid any sort of platform dependence (Zig seems to be going hard against POSIX in the upcoming 0.16 release).
There was a problem hiding this comment.
0 should work as a signal that the PID was unavailable, at least on any system I'm aware of that's not a valid PID.
There was a problem hiding this comment.
Good point, updated to use u64 with 0 as the sentinel value.
1c0f3b0 to
b299953
Compare
|
Rebased on top of #11639 and refactored to use getProcessInfo(). Squashed into a single commit. |
Expose the foreground process PID and slave TTY name on TerminalEntity via the getProcessInfo() API added in ghostty-org#11639. This allows Shortcuts/Siri to query process information for a given terminal session. Closes ghostty-org#10756 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b299953 to
e7e6e06
Compare
|
This has been superseded by #11922 right? |
This is a re-submission of #10983. Vouched in #11287.
Add child process PID and TTY device name as queryable properties on
TerminalEntity for App Intents. This enables external applications and
Shortcuts to identify and filter terminals by their PID or TTY device.
Closes #10756
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com