Terminal: drop files / paperclip; net core: fallback exit, re-test on network change, hide/unhide connections
- term.macOS: dropping files over an open terminal or the paperclip types their shell-escaped paths (bracketed paste when the program asks for it). - Traffic now goes through a fallback group "exit": the pick while it answers, "auto" when it doesn't. A pinned connection that dies no longer cuts the Mac off. - Faster checks (exit 30 s, auto 60 s, 3 failures trigger a re-test) and a re-test of every group 4 s after any network change (Wi-Fi switch, sleep, AmneziaVPN). - hide/unhide instead of deleting keys: Amnezia connections and VLESS nodes leave the list and "auto"; kept on disk, returned from "Убранные". - Core logs are owner-only (they can contain the subscription URL). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,48 @@ final class TerminalStore: NSObject, LocalProcessTerminalViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/// The terminal tab on screen right now, if any (drops and the paperclip go there).
|
||||
var activeTab: UUID? {
|
||||
let s = AppState.shared
|
||||
guard s.view == .terminal, s.mode == .expanded, let id = s.activeTabId,
|
||||
s.tabs.first(where: { $0.id == id })?.kind == .terminal else { return nil }
|
||||
return id
|
||||
}
|
||||
|
||||
/// Types the files' paths at the prompt, shell-escaped like Terminal.app does on a drop.
|
||||
/// Sent as a bracketed paste when the program asks for it (claude then attaches images).
|
||||
func insertPaths(_ urls: [URL], into id: UUID) {
|
||||
guard let v = views[id], !urls.isEmpty else { return }
|
||||
let text = urls.map { Self.shellEscaped($0.path) }.joined(separator: " ") + " "
|
||||
if v.getTerminal().bracketedPasteMode {
|
||||
v.send(txt: "\u{1b}[200~" + text + "\u{1b}[201~")
|
||||
} else {
|
||||
v.send(txt: text)
|
||||
}
|
||||
v.window?.makeFirstResponder(v)
|
||||
}
|
||||
|
||||
func choosePaths(for id: UUID) {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = true
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.prompt = "Вставить"
|
||||
panel.message = "Пути выбранных файлов появятся в терминале"
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
if panel.runModal() == .OK { insertPaths(panel.urls, into: id) }
|
||||
}
|
||||
|
||||
static func shellEscaped(_ path: String) -> String {
|
||||
let special = Set(" \t!\"#$&'()*,;<=>?[\\]^`{|}~")
|
||||
var out = ""
|
||||
for ch in path {
|
||||
if special.contains(ch) { out.append("\\") }
|
||||
out.append(ch)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
private func tabId(of source: TerminalView) -> UUID? {
|
||||
views.first(where: { $0.value === source })?.key
|
||||
}
|
||||
@@ -184,6 +226,19 @@ struct TerminalScreen: View {
|
||||
TerminalTabView(tabId: id)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Button { TerminalStore.shared.choosePaths(for: id) } label: {
|
||||
Image(systemName: "paperclip")
|
||||
.font(.system(size: 11, weight: .semibold))
|
||||
.foregroundColor(Color(hex: "#8E939C"))
|
||||
.frame(width: 24, height: 24)
|
||||
.background(Circle().fill(Color.white.opacity(0.08)))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Вставить путь к файлу (или перетащи файл в терминал)")
|
||||
.padding(.top, 8)
|
||||
.padding(.trailing, 14)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 4)
|
||||
|
||||
Reference in New Issue
Block a user