Commit Graph

3 Commits (5b4d598217c53bd3b347eaa845159db8bcd173b9)

Author SHA1 Message Date
Claude Opus 4.7 23871ac0e0
feat(macos): inline _os_log_impl on debug builds for Xcode jump to source
Add a per-scope logging wrapper (src/log.zig) that, on Darwin debug
builds, calls Apple's `_os_log_impl` inline from each log site. Because
the call is inlined, DWARF (DW_TAG_inlined_subroutine) attributes the
`_os_log_impl` PC back to the user's Zig file:line — so Xcode's Jump
to Source lands on the actual log statement instead of on a shared C
wrapper.
Release builds skip the SPI path and continue to deliver via the
public `os_log_with_type` macro through pkg/macos/os/zig_macos.c, so
shipped binaries depend only on public os_log API. The trade-off is
that release builds attribute log sites to the C wrapper.
- src/log.zig exposes `scoped(.x).{info,debug,warn,err}`. Pass-through
  to std.log.scoped plus an inline emitDarwin path gated on
  `isDarwin and mode == .Debug`.
- Scoped logger declarations outside src/apprt/gtk migrated from
  std.log.scoped to the wrapper. GTK is Linux-only and the wrapper
  is a Darwin-debug feature, so the apprt was left on std.log.scoped.
  Call-site signatures unchanged.
- logFn's macOS branch is gated on non-Debug: Debug has no
  double-delivery, Release still feeds os_log for direct std.log.*
  callers.
dladdr recovers the containing image's Mach-O header at runtime;
`__dso_handle` is a Zig placeholder symbol and
`_dyld_get_image_header(0)` returns the wrong image when this code
lives in a dylib (e.g. ghostty.debug.dylib under Xcode debug builds).
2026-05-31 16:35:24 +02:00
Jon Parise ac69942cdc cli: rework +ssh-cache internals and user interface
This change primarily focused on a revised +ssh-cache user interface,
but it also reworks a bunch of the internals.

The primary CLI improvement is support for positional arguments and a
consistent list output format that includes both the ISO-formatted
timestamp and relative age.

    ghostty +ssh-cache                           # List all cached destinations
    ghostty +ssh-cache user@example.com          # Show that destination
    ghostty +ssh-cache example.com               # Show all users on that host
    ghostty +ssh-cache --add=user@example.com    # Manually add a destination
    ghostty +ssh-cache --remove=user@example.com # Remove a destination
    ghostty +ssh-cache --prune=30d               # Remove entries older than 30 days
    ghostty +ssh-cache --clear                   # Clear entire cache

Notable, we now support a --prune operation that replaces the previous
--expire-days flag that was never actually hooked up to anything (!!).
--prune also supports a wider range of Duration-based values.

We're also much more consistent with error codes: 0=success, 1=failure,
2=usage.

While working on those changes, I also reworked the cache internals,
particularly the code around timestamp handling and errors. For example,
I dropped the explicit error sets because they were growing unwieldy,
and in practice we only matched on a subset of those errors.

Lastly, overall test coverage should be much improved, especially around
the time- and allocation-related operations.
2026-05-25 16:00:21 -04:00
Jon Parise 484d6ec66b cli: add an ssh-wrapping +ssh action
Add a drop-in `ssh` wrapper that sets up the remote environment for
Ghostty. Anything not consumed as one of our own flags is forwarded to
the real, wrapped `ssh` binary. It can be used directly (`ghostty +ssh
user@host`), aliased (`alias ssh='ghostty +ssh --'`), or invoked through
Ghostty's shell integration.

Before exec'ing ssh, `+ssh`:

- Forwards Ghostty environment to the remote (`--forward-env`): sets
  TERM=xterm-256color and requests SendEnv forwarding of COLORTERM,
  TERM_PROGRAM, and TERM_PROGRAM_VERSION.
- Installs Ghostty's terminfo on the remote (`--terminfo`), informed by
  our existing `ssh-cache` system and using our internal xterm-ghostty
  terminfo representation.

A third flag, `--cache`, controls cache use; `--cache=false` bypasses
both read and write, which is useful for scripting and for debugging
install failures without polluting the cache.

For shell integration, this replaces the per-shell logic (which made up
roughly a third of our shell integration scripts) with a simple wrapper
function that translates GHOSTTY_SHELL_FEATURES into a `ghostty +ssh`
command line. This commit only migrates the bash integration; the other
shells will follow separately.
2026-05-04 20:21:45 -04:00