Skip to content

macOS: reorganize SurfaceView related files - #13764

Open
bo2themax wants to merge 13 commits into
ghostty-org:mainfrom
bo2themax:push-f8d3335c
Open

macOS: reorganize SurfaceView related files#13764
bo2themax wants to merge 13 commits into
ghostty-org:mainfrom
bo2themax:push-f8d3335c

Conversation

@bo2themax

Copy link
Copy Markdown
Member

Ghostty.SurfaceView.swift is still a very large file, but we can split it gradually in the future.

AI Disclosure

Claude spliced my local branch to smaller commits and I judged in another session and skimmed myself.

@bo2themax
bo2themax requested a review from a team as a code owner August 12, 2026 17:45
@ghostty-bot ghostty-bot Bot added the os/macos label Aug 12, 2026
@bo2themax
bo2themax force-pushed the push-f8d3335c branch 3 times, most recently from 92e80ae to b522496 Compare August 14, 2026 07:07
bo2themax and others added 13 commits August 19, 2026 11:56
Pure file rename. The `_AppKit` suffix dated back to when this file had an
iOS counterpart; the surface view is AppKit-only now, so the name just
adds noise. Renaming to the `Ghostty.Type.swift` convention used by the
rest of the Ghostty sources.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
OSSurfaceView existed as a platform-neutral base class for the iOS port,
which never landed. Everything it declared was either overridden by
SurfaceView or only meaningful with a live `ghostty_surface_t`, so the
base class was an indirection with exactly one subclass:

- `surface` returned nil and was overridden to read `surfaceModel`.
- `focusDidChange`/`sizeDidChange` were empty placeholders, overridden.
- `endSearch` was overridden to move focus before calling `super`.
- `progressReport`/`searchState` were plain `@Published` properties that
  SurfaceView overrode only to attach `didSet` observers.

Move the state, the readonly notification observer, `highlight()`,
`setChildExitedMessage`, and the nested `SearchState` type into
SurfaceView and drop the `override`s. `id` is now assigned directly in
SurfaceView's init instead of being threaded through `super.init(id:)`.

No behavior change: the readonly observer is registered alongside the
other notification observers in the same init, and SurfaceView's `deinit`
already removed all observers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
SurfaceView.swift held the top-level SwiftUI view for a surface plus every
overlay it composes. Move SurfaceWrapper, and the SurfaceRepresentable it
wraps, into SurfaceWrapper.swift so the entry point is findable without
scrolling past ten overlay views.

SurfaceRepresentable is now `private`: SurfaceWrapper is its only user, so
file scope keeps it out of the way of the rest of the module.

Pure code motion otherwise.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
SurfaceConfiguration is a model type, not a view, and it was sitting in the
middle of SurfaceView.swift between two overlay views. Move it to
SurfaceConfiguration.swift alongside the rest of the surface sources.

It only needs AppKit, GhosttyKit and System, so the new file imports those
rather than SwiftUI.

Pure code motion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
moveFocus pokes at a SurfaceView's window to reset the first responder, so
it belongs with the view it manipulates rather than at the bottom of the
overlay views file.

Pure code motion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
…ion.swift

The SwiftUI environment and focused-value plumbing for surfaces was appended
to the bottom of SurfaceView.swift, outside the `extension Ghostty` block it
had nothing to do with. Move it to Ghostty/SwiftUI+Extension.swift.

Pure code motion; the keys and their definitions are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
The `@Entry` macro generates the key type, the default value and the
accessor, so the six hand-written key structs and their get/set pairs
collapse to one line each. Behavior is unchanged: every key keeps its type
and its `nil` default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Pure file rename. What's left in the file after moving SurfaceWrapper,
SurfaceConfiguration and the environment keys out is the set of views that
decorate a surface: the resize and search overlays, the key state
indicator, the bell border, the highlight, the readonly badge and its
popover, and the two error views.

"SurfaceView.swift" no longer describes that, and it was confusing next to
Ghostty.SurfaceView.swift. "Accessory" rather than "Overlay" because the
popover and the badge aren't overlays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Ghostty.SurfaceView.swift is 2714 lines after absorbing OSSurfaceView. Move
the self-contained extensions out into the SurfaceView+Feature.swift
convention already used by SurfaceView+Image.swift and
SurfaceView+Transferable.swift, starting with the SearchState model and the
two search navigation helpers.

This also pairs the file with the existing SurfaceView+SearchStateTests.swift.

Pure code motion; the only change is dropping the MARK header the file name
now carries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Pure code motion out of Ghostty.SurfaceView.swift; the only change is
dropping the MARK header the file name now carries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Pure code motion out of Ghostty.SurfaceView.swift; the only change is
dropping the MARK header the file name now carries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Pure code motion out of Ghostty.SurfaceView.swift; the only change is
dropping the MARK header the file name now carries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Pure code motion out of Ghostty.SurfaceView.swift; the only change is
dropping the MARK header the file name now carries. The documentation link
moves with the extension.

NSTextInputClient stays behind: it touches four private members
(markedText, keyTextAccumulator, leadSurrogate, committedPreeditTextAction)
shared with the key event path in the class body, so moving it would mean
widening those to internal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gsMAN9qTB7HivpTfkWF47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant