Skip to content

Commit 3a8a553

Browse files
committed
feat: update terminal size synchronization and improve connection handling
1 parent 0f7147b commit 3a8a553

11 files changed

Lines changed: 92 additions & 28 deletions

File tree

Code.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@
631631
947BBCF82C12F5AA00FFD0C5 /* TreeSitterYAMLRunestone in Frameworks */ = {isa = PBXBuildFile; productRef = 947BBCF72C12F5AA00FFD0C5 /* TreeSitterYAMLRunestone */; };
632632
947BF349262453040015DAEB /* SearchManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 947BF348262453040015DAEB /* SearchManager.swift */; };
633633
94801F93266FB5E400B29D80 /* TerminalInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94801F92266FB5E400B29D80 /* TerminalInstance.swift */; };
634+
94801F95266FBC3500B29D80 /* ViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94801F94266FBC3500B29D80 /* ViewRepresentable.swift */; };
634635
94801F97266FB5E500B29D80 /* TerminalManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94801F96266FB5E500B29D80 /* TerminalManager.swift */; };
635636
94801F98266FB5E500B29D80 /* TerminalManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94801F96266FB5E500B29D80 /* TerminalManager.swift */; };
636-
94801F95266FBC3500B29D80 /* ViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94801F94266FBC3500B29D80 /* ViewRepresentable.swift */; };
637637
948488F92BE61684004D4A70 /* TerminalKeyboardToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948488F82BE61684004D4A70 /* TerminalKeyboardToolbar.swift */; };
638638
948488FA2BE61684004D4A70 /* TerminalKeyboardToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948488F82BE61684004D4A70 /* TerminalKeyboardToolbar.swift */; };
639639
9484BDD12B46FAEE003BCB8A /* injection.js in Resources */ = {isa = PBXBuildFile; fileRef = 9484BDD02B46FAEE003BCB8A /* injection.js */; };
@@ -1837,8 +1837,8 @@
18371837
947A9D8827D3C562007680C3 /* UIApplication+getSafeArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+getSafeArea.swift"; sourceTree = "<group>"; };
18381838
947BF348262453040015DAEB /* SearchManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchManager.swift; sourceTree = "<group>"; };
18391839
94801F92266FB5E400B29D80 /* TerminalInstance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalInstance.swift; sourceTree = "<group>"; };
1840-
94801F96266FB5E500B29D80 /* TerminalManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalManager.swift; sourceTree = "<group>"; };
18411840
94801F94266FBC3500B29D80 /* ViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewRepresentable.swift; sourceTree = "<group>"; };
1841+
94801F96266FB5E500B29D80 /* TerminalManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalManager.swift; sourceTree = "<group>"; };
18421842
948488F82BE61684004D4A70 /* TerminalKeyboardToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalKeyboardToolbar.swift; sourceTree = "<group>"; };
18431843
9484BDD02B46FAEE003BCB8A /* injection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = injection.js; sourceTree = "<group>"; };
18441844
948A5FE82A87B09500303C12 /* NSError+init.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSError+init.swift"; sourceTree = "<group>"; };
@@ -4057,7 +4057,7 @@
40574057
"@executable_path/Frameworks",
40584058
);
40594059
LIBRARY_SEARCH_PATHS = "$(inherited)";
4060-
MARKETING_VERSION = 1.12.0;
4060+
MARKETING_VERSION = 1.12.1;
40614061
OTHER_SWIFT_FLAGS = "-Xcc -Wno-incomplete-umbrella";
40624062
PRODUCT_BUNDLE_IDENTIFIER = "thebaselab.VS-Code";
40634063
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4105,7 +4105,7 @@
41054105
"@executable_path/Frameworks",
41064106
);
41074107
LIBRARY_SEARCH_PATHS = "$(inherited)";
4108-
MARKETING_VERSION = 1.12.0;
4108+
MARKETING_VERSION = 1.12.1;
41094109
OTHER_SWIFT_FLAGS = "-Xcc -Wno-incomplete-umbrella";
41104110
PRODUCT_BUNDLE_IDENTIFIER = "thebaselab.VS-Code";
41114111
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4342,7 +4342,7 @@
43424342
"@executable_path/Frameworks",
43434343
);
43444344
LIBRARY_SEARCH_PATHS = "$(inherited)";
4345-
MARKETING_VERSION = 1.12.0;
4345+
MARKETING_VERSION = 1.12.1;
43464346
OTHER_SWIFT_FLAGS = "-Xcc -Wno-incomplete-umbrella";
43474347
PRODUCT_BUNDLE_IDENTIFIER = "thebaselab.VS-Code";
43484348
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4389,7 +4389,7 @@
43894389
"@executable_path/Frameworks",
43904390
);
43914391
LIBRARY_SEARCH_PATHS = "$(inherited)";
4392-
MARKETING_VERSION = 1.12.0;
4392+
MARKETING_VERSION = 1.12.1;
43934393
OTHER_SWIFT_FLAGS = "-Xcc -Wno-incomplete-umbrella";
43944394
PRODUCT_BUNDLE_IDENTIFIER = "thebaselab.VS-Code";
43954395
PRODUCT_NAME = "$(TARGET_NAME)";

CodeApp/Containers/RemoteContainer.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,13 @@ struct RemoteContainer: View {
176176
continuation.resume(throwing: error)
177177
} else {
178178
DispatchQueue.main.async {
179-
App.loadFolder(url: hostUrl)
179+
App.notificationManager.showInformationMessage(
180+
"remote.connected")
181+
App.terminalManager.setTerminalServiceProviderForActiveTerminal(
182+
App.workSpaceStorage.terminalServiceProvider)
183+
if let newRootDirectory = URL(string: App.workSpaceStorage.currentDirectory.url) {
184+
App.loadFolder(url: newRootDirectory, resetEditorsAndTerminals: true)
185+
}
180186
}
181187
continuation.resume(returning: ())
182188
}

CodeApp/Localization/de.lproj/Localizable.strings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (Februar 2026)**
11+
##### **v1.12.1 (März 2026)**
1212
#### Start
1313
[Neue Datei](https://thebaselab.com/code/newfile)
1414
[Datei öffnen](https://thebaselab.com/code/openfile)
@@ -22,7 +22,10 @@
2222
";
2323

2424
"Changelog.message" =
25-
"### 1.12.0 (Feburary 2026)
25+
"### 1.12.1 (März 2026)
26+
- Behebt einen Fehler mit SSH-Verzeichnissen
27+
28+
### 1.12.0 (Feburary 2026)
2629
- Unterstützung für mehrere Terminals
2730
- Unterstützung für Terminal‑Modifikatortasten
2831
- Besonderer Dank an @ThalesMMS für den Beitrag

CodeApp/Localization/en.lproj/Localizable.strings

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (February 2026)**
11+
##### **v1.12.1 (March 2026)**
1212
#### Start
1313
[New file](https://thebaselab.com/code/newfile)
1414
[Open file](https://thebaselab.com/code/openfile)
@@ -23,6 +23,9 @@
2323

2424
"Changelog.message" =
2525
"
26+
### 1.12.1 (March 2026)
27+
- Fixes an SSH directory bug
28+
2629
### 1.12.0 (Feburary 2026)
2730
- Support multi-terminal
2831
- Support terminal key modifiers

CodeApp/Localization/ja.lproj/Localizable.strings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (2026 年 2 月)**
11+
##### **v1.12.1 (2026 年 3 月)**
1212
#### 開始
1313
[新しいファイル](https://thebaselab.com/code/newfile)
1414
[ファイルを開く](https://thebaselab.com/code/openfile)
@@ -22,7 +22,10 @@
2222
";
2323

2424
"Changelog.message" =
25-
"### 1.12.0 (Feburary 2026)
25+
"### 1.12.1 (2026 年 3 月)
26+
- SSH ディレクトリの不具合を修正
27+
28+
### 1.12.0 (Feburary 2026)
2629
- マルチターミナルに対応
2730
- ターミナルの修飾キーに対応
2831
- @ThalesMMS の貢献に特別感謝

CodeApp/Localization/ko.lproj/Localizable.strings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (2026년 2월)**
11+
##### **v1.12.1 (2026년 3월)**
1212
#### 시작
1313
[새 파일...](https://thebaselab.com/code/newfile)
1414
[파일 열기...](https://thebaselab.com/code/openfile)
@@ -22,7 +22,10 @@
2222
";
2323

2424
"Changelog.message" =
25-
"### 1.12.0 (Feburary 2026)
25+
"### 1.12.1 (2026년 3월)
26+
- SSH 디렉터리 버그 수정
27+
28+
### 1.12.0 (Feburary 2026)
2629
- 멀티 터미널 지원
2730
- 터미널 키 모디파이어 지원
2831
- 기여해 주신 @ThalesMMS님께 특별한 감사

CodeApp/Localization/ru.lproj/Localizable.strings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (Февраль 2026)**
11+
##### **v1.12.1 (Март 2026)**
1212
#### Начало
1313
[Новый файл](https://thebaselab.com/code/newfile)
1414
[Открыть файл](https://thebaselab.com/code/openfile)
@@ -22,7 +22,10 @@
2222
";
2323

2424
"Changelog.message" =
25-
"### 1.12.0 (Feburary 2026)
25+
"### 1.12.1 (Март 2026)
26+
- Исправлена ошибка с SSH-каталогами
27+
28+
### 1.12.0 (Feburary 2026)
2629
- Поддержка нескольких терминалов
2730
- Поддержка клавиш-модификаторов терминала
2831
- Особая благодарность @ThalesMMS за вклад

CodeApp/Localization/zh-Hans.lproj/Localizable.strings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"Welcome Message" =
1010
"# Code App
11-
##### **v1.12.0 (2026 年 2 月)**
11+
##### **v1.12.1 (2026 年 3 月)**
1212
#### 开始
1313
[新文件](https://thebaselab.com/code/newfile)
1414
[打开文件](https://thebaselab.com/code/openfile)
@@ -22,7 +22,10 @@
2222
";
2323

2424
"Changelog.message" =
25-
"### 1.12.0 (Feburary 2026)
25+
"### 1.12.1 (2026 年 3 月)
26+
- 修复了 SSH 目录错误
27+
28+
### 1.12.0 (Feburary 2026)
2629
- 支持多终端
2730
- 支持终端修饰键
2831
- 特别感谢 @ThalesMMS 的贡献

CodeApp/Managers/MainApp.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -983,23 +983,17 @@ class MainApp: ObservableObject {
983983
self.terminalManager.resetAndSetNewRootDirectory(url: url)
984984
}
985985

986+
self.workSpaceStorage.updateDirectory(
987+
name: url.lastPathComponent, url: url.absoluteString)
988+
986989
let url = url.standardizedFileURL
987990
if url.isFileURL {
988991
// Local urls
989992
ios_setDirectoryURL(url)
990-
if workSpaceStorage.remoteConnected && url.isFileURL {
993+
if workSpaceStorage.remoteConnected {
991994
workSpaceStorage.disconnect()
992995
}
993-
self.workSpaceStorage.updateDirectory(
994-
name: url.lastPathComponent, url: url.absoluteString)
995996
saveLocalURLToRecentFolders(url: url)
996-
} else {
997-
// Remote urls
998-
notificationManager.showInformationMessage(
999-
"remote.connected")
1000-
// Set terminal service provider for the active terminal
1001-
terminalManager.setTerminalServiceProviderForActiveTerminal(
1002-
workSpaceStorage.terminalServiceProvider)
1003997
}
1004998

1005999
loadRepository(url: url)

CodeApp/Managers/TerminalInstance.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TerminalInstance: NSObject, WKScriptMessageHandler, WKNavigationDelegate,
3737
didSet {
3838
if terminalServiceProvider != nil {
3939
self.startInteractive()
40+
self.syncTerminalSizeToServiceProvider()
4041
}
4142
if terminalServiceProvider == nil && oldValue != nil {
4243
self.stopInteractive()
@@ -77,6 +78,19 @@ class TerminalInstance: NSObject, WKScriptMessageHandler, WKNavigationDelegate,
7778
}
7879
}
7980

81+
private func syncTerminalSizeToServiceProvider() {
82+
guard isReady, let terminalServiceProvider else {
83+
return
84+
}
85+
86+
Task {
87+
guard let size = await getTerminalSize() else {
88+
return
89+
}
90+
terminalServiceProvider.setWindowsSize(cols: size.cols, rows: size.rows)
91+
}
92+
}
93+
8094
func setFontSize(size: Int) {
8195
executeScript("term.options.fontSize = \(size)")
8296
}
@@ -391,6 +405,7 @@ class TerminalInstance: NSObject, WKScriptMessageHandler, WKNavigationDelegate,
391405
}
392406
configureCustomOptions()
393407
isReady = true
408+
syncTerminalSizeToServiceProvider()
394409
NotificationCenter.default.post(name: .terminalDidInitialize, object: self)
395410
case "window.size.change":
396411
let cols = result["Cols"] as! Int
@@ -577,6 +592,29 @@ struct ModifierStates: Codable {
577592
var altGeneration: Int
578593
}
579594

595+
struct TerminalSize: Codable {
596+
var cols: Int
597+
var rows: Int
598+
}
599+
600+
// Terminal state methods
601+
602+
extension TerminalInstance {
603+
/// Asynchronously obtains the current terminal size from JavaScript.
604+
func getTerminalSize() async -> TerminalSize? {
605+
guard
606+
let dict = try? await webView.evaluateJavaScript("getTerminalSize()")
607+
as? [String: Any],
608+
let jsonData = try? JSONSerialization.data(withJSONObject: dict),
609+
let size = try? JSONDecoder().decode(TerminalSize.self, from: jsonData)
610+
else {
611+
return nil
612+
}
613+
614+
return size
615+
}
616+
}
617+
580618
// Keyboard toolbar methods
581619

582620
extension TerminalInstance {
@@ -625,6 +663,7 @@ extension TerminalInstance {
625663

626664
return states
627665
}
666+
628667
}
629668

630669
extension Notification.Name {

0 commit comments

Comments
 (0)