@devries-cameron20 / t3code Mirror · read-only / commits / 9a35ab0afe
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 17:15 UTC

fix(mobile): iOS terminal font and theme changes no longer replay output (#36115)

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>

shivam committed Nov 13, 2026 at 19:57 UTC 9a35ab0afeae64ac7c3bf92d674ead365cf55e10
1 file changed +30 -8
apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift
+30 -8
@@ -285,7 +285,7 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte
285 didSet {
286 guard oldValue != fontSize else { return }
287 inputField.font = UIFont.monospacedSystemFont(ofSize: max(fontSize, 13), weight: .regular)
288 - resetSurface()
288 + applyConfigInPlace()
289 }
290 }
291
@@ -321,14 +321,14 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte
321 didSet {
322 guard oldValue != appearanceScheme else { return }
323 appearance = TerminalAppearanceScheme(value: appearanceScheme)
324 - resetSurface()
324 + applyConfigInPlace()
325 }
326 }
327
328 var themeConfig: String = "" {
329 didSet {
330 guard oldValue != themeConfig else { return }
331 - resetSurface()
331 + applyConfigInPlace()
332 }
333 }
334
@@ -663,7 +663,8 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte
663 surfaceCreationFailed = true
664 return
665 }
666 - loadThemeConfig(into: config)
666 + // Creation proceeds without the file, as before; font_size is also set on the surface config.
667 + _ = loadThemeConfig(into: config)
668 ghostty_config_finalize(config)
669 defer { ghostty_config_free(config) }
670
@@ -710,6 +711,27 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte
711 setNeedsLayout()
712 }
713
714 + // Font and theme change in place: a new surface would replay output and re-answer its queries.
715 + private func applyConfigInPlace() {
716 + guard let app, let surface else {
717 + resetSurface()
718 + return
719 + }
720 + guard let config = ghostty_config_new() else { return }
721 + defer { ghostty_config_free(config) }
722 + let loaded = loadThemeConfig(into: config)
723 + ghostty_config_finalize(config)
724 + ghostty_app_set_color_scheme(app, appearance.ghosttyColorScheme)
725 + ghostty_surface_set_color_scheme(surface, appearance.ghosttyColorScheme)
726 + tickApp()
727 + // Without the file, the config lacks font-size and would reset the surface to defaults.
728 + if loaded {
729 + ghostty_surface_update_config(surface, config)
730 + }
731 + resizeSurface()
732 + setNeedsLayout()
733 + }
734 +
735 private func destroySurface() {
736 // Unblock the io thread before ghostty_surface_free joins it.
737 tickApp()
@@ -933,16 +955,16 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte
955 terminalViewport.backgroundColor = backgroundColorValue
956 }
957
936 - private func loadThemeConfig(into config: ghostty_config_t) {
937 - guard let path = writeThemeConfigFile() else { return }
958 + private func loadThemeConfig(into config: ghostty_config_t) -> Bool {
959 + guard let path = writeThemeConfigFile() else { return false }
960 path.withCString { cString in
961 ghostty_config_load_file(config, cString)
962 }
963 + return true
964 }
965
966 private func writeThemeConfigFile() -> String? {
944 - guard !themeConfig.isEmpty else { return nil }
945 - let configContents = themeConfig
967 + let configContents = "\(themeConfig)\nfont-size = \(String(format: "%g", Double(fontSize)))\n"
968 let url = URL(fileURLWithPath: NSTemporaryDirectory())
969 .appendingPathComponent("t3-terminal-theme-\(appearance.rawValue).ghostty")
970