diff --git a/desktop/internal/core/remote.go b/desktop/internal/core/remote.go index 2b63233b1..04011af8a 100644 --- a/desktop/internal/core/remote.go +++ b/desktop/internal/core/remote.go @@ -56,10 +56,41 @@ type SavedRemoteConnection struct { Name string `json:"name"` // Connection is how to reach the host. Connection SSHConnection `json:"connection"` + // Color is the entry's accent color; empty for none. + Color RemoteConnectionColor `json:"color,omitempty"` + // Group is the group the entry is listed under; empty for none. + Group string `json:"group,omitempty"` // RecentFolders are the host folders opened over the entry, the latest first. RecentFolders []string `json:"recentFolders,omitempty"` } +// RemoteConnectionColor is an accent color Core accepts for a saved connection. The client picks +// the shade for its light and dark themes. +type RemoteConnectionColor string + +// The accent colors Core accepts. +const ( + RemoteConnectionRed RemoteConnectionColor = "red" + RemoteConnectionOrange RemoteConnectionColor = "orange" + RemoteConnectionYellow RemoteConnectionColor = "yellow" + RemoteConnectionGreen RemoteConnectionColor = "green" + RemoteConnectionBlue RemoteConnectionColor = "blue" + RemoteConnectionPurple RemoteConnectionColor = "purple" +) + +// RemoteConnectionColors are the accent colors, in the order the connection window offers them. +var RemoteConnectionColors = []RemoteConnectionColor{ + RemoteConnectionRed, RemoteConnectionOrange, RemoteConnectionYellow, + RemoteConnectionGreen, RemoteConnectionBlue, RemoteConnectionPurple, +} + +// RemoteConnectionSection is one heading of the connection list: the entries of Group, or of no +// group when Group is nil, in the order Core lists them. +type RemoteConnectionSection struct { + Group *string `json:"group"` + IDs []string `json:"ids"` +} + // RemoteConnectionsStorage says where the host keeps the document: RelativePath inside the // platform preference directory, at most MaximumBytes long. type RemoteConnectionsStorage struct { @@ -69,15 +100,20 @@ type RemoteConnectionsStorage struct { // RemoteConnectionsState is the document as Core reads it. type RemoteConnectionsState struct { - Connections []SavedRemoteConnection `json:"connections"` - Storage RemoteConnectionsStorage `json:"storage"` + Connections []SavedRemoteConnection `json:"connections"` + // Sections are the headings the window lists the entries under, ungrouped last. + Sections []RemoteConnectionSection `json:"sections"` + Storage RemoteConnectionsStorage `json:"storage"` } -// RemoteConnectionSave adds a connection, or replaces the entry ID when ID is set. +// RemoteConnectionSave adds a connection, or replaces the entry ID when ID is set. An empty +// Color or Group saves the entry without one, so a save carries the entry's current values. type RemoteConnectionSave struct { - ID string `json:"id,omitempty"` - Name string `json:"name"` - Connection SSHConnection `json:"connection"` + ID string `json:"id,omitempty"` + Name string `json:"name"` + Connection SSHConnection `json:"connection"` + Color RemoteConnectionColor `json:"color,omitempty"` + Group string `json:"group,omitempty"` } // RemoteConnectionID names an entry to remove. @@ -101,10 +137,11 @@ type RemoteConnectionEdit struct { // RemoteConnectionsPublication is the outcome of an edit. Document is the text to publish, nil // when the edit changed nothing; ID names the entry a save wrote. type RemoteConnectionsPublication struct { - Changed bool `json:"changed"` - Document *string `json:"document"` - Connections []SavedRemoteConnection `json:"connections"` - ID string `json:"id"` + Changed bool `json:"changed"` + Document *string `json:"document"` + Connections []SavedRemoteConnection `json:"connections"` + Sections []RemoteConnectionSection `json:"sections"` + ID string `json:"id"` } // RemoteConnections reads the saved connections from document, the text of the source or nil diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index aa8473915..e734bdfc8 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1579,16 +1579,28 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.choose": "Choose File…", "desktop.remote.chooseFailed": "Cannot open the file picker: {reason}", "desktop.remote.close": "Close", + "desktop.remote.color": "Color", + "desktop.remote.color.blue": "Blue", + "desktop.remote.color.green": "Green", + "desktop.remote.color.none": "No Color", + "desktop.remote.color.orange": "Orange", + "desktop.remote.color.purple": "Purple", + "desktop.remote.color.red": "Red", + "desktop.remote.color.yellow": "Yellow", + "desktop.remote.colorHelp": "Marks the connection in the list, for example to tell production from test hosts. Kept on this computer only.", "desktop.remote.conflict": "The saved connections changed elsewhere and were read again. Save once more.", "desktop.remote.damaged": "The saved connections in {path} cannot be read. Repair or remove the file before saving.", "desktop.remote.delete": "Delete", "desktop.remote.deleteConfirm": "Delete “{name}”?", "desktop.remote.deleteFailed": "Cannot delete the connection: {reason}", "desktop.remote.diagnostics": "OpenSSH Output", + "desktop.remote.edit": "Edit", "desktop.remote.empty": "No saved connections yet. Fill in the form and save it.", "desktop.remote.error.duplicate": "Another saved connection already uses this.", "desktop.remote.error.fieldTooLong": "Too long: at most 1024 bytes.", "desktop.remote.error.full": "At most 128 connections can be saved. Delete one first.", + "desktop.remote.error.groupInvalid": "A group name cannot contain line breaks, tabs or other control characters.", + "desktop.remote.error.groupTooLong": "Too long: at most 64 characters.", "desktop.remote.error.hostInvalid": "Enter only a host name, an IP address or an SSH alias; put the user and the port in their own fields.", "desktop.remote.error.invalid": "This value is not accepted.", "desktop.remote.error.keepAliveInvalid": "Enter 1 to 3600 seconds.", @@ -1601,9 +1613,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.error.timeoutInvalid": "Enter 1 to 600 seconds.", "desktop.remote.error.unknown": "This connection no longer exists.", "desktop.remote.error.userInvalid": "This user name has characters SSH does not accept.", + "desktop.remote.group": "Group", + "desktop.remote.group.new": "New Group…", + "desktop.remote.group.none": "No Group", + "desktop.remote.groupHelp": "The list shows connections under their group. Group names that differ only in case are the same group.", + "desktop.remote.groupPlaceholder": "Group name", "desktop.remote.host": "Host", "desktop.remote.hostHelp": "A host name, an IP address, or a Host alias from ~/.ssh/config. OpenSSH applies its configuration as usual: a field left empty here does not override it.", "desktop.remote.hostPlaceholder": "build.example.com or an SSH config alias", + "desktop.remote.hostSection": "Host", "desktop.remote.identityFile": "Private Key", "desktop.remote.identityFileHelp": "Only the path is saved and handed to OpenSSH; Lithe never reads the key.", "desktop.remote.identityFilePlaceholder": "~/.ssh/id_ed25519", @@ -1638,6 +1656,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.saveFailed": "Cannot save the connection: {reason}", "desktop.remote.saved": "Saved Connections", "desktop.remote.saving": "Saving…", + "desktop.remote.settings": "Connection Settings", "desktop.remote.stop": "Stop", "desktop.remote.storageHelp": "Kept on this computer in {path}. Passwords and the contents of private keys are never saved.", "desktop.remote.test": "Test Connection", @@ -1646,8 +1665,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.timeoutPlaceholder": "Auto (15)", "desktop.remote.title": "Remote Development", "desktop.remote.unavailable": "There is no preference folder to keep connections in.", + "desktop.remote.ungrouped": "Ungrouped", + "desktop.remote.untested": "Test the connection to see the host's system, CPUs, memory and disk.", "desktop.remote.user": "User", "desktop.remote.userPlaceholder": "Auto (SSH config, otherwise your local user name)", + "desktop.remote.via": "via {jump}", "desktop.remoteAuth.failed": "Cannot pass the answer to SSH: {reason}", "desktop.remoteAuth.refused": "SSH did not take the answer: it may be at most 8192 bytes and may not contain a line break. The question was cancelled.", "desktop.remoteAuth.secretHint": "The answer goes only to this SSH connection. Lithe does not keep it.", @@ -4990,16 +5012,28 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.choose": "选择文件…", "desktop.remote.chooseFailed": "无法打开文件选择器:{reason}", "desktop.remote.close": "关闭", + "desktop.remote.color": "颜色", + "desktop.remote.color.blue": "蓝色", + "desktop.remote.color.green": "绿色", + "desktop.remote.color.none": "无颜色", + "desktop.remote.color.orange": "橙色", + "desktop.remote.color.purple": "紫色", + "desktop.remote.color.red": "红色", + "desktop.remote.color.yellow": "黄色", + "desktop.remote.colorHelp": "在列表中标记这个连接,例如区分生产和测试主机。只保存在本机。", "desktop.remote.conflict": "已保存的连接在别处被修改过,已重新读取,请再保存一次。", "desktop.remote.damaged": "无法读取 {path} 里保存的连接。修复或删除这个文件之前不能保存。", "desktop.remote.delete": "删除", "desktop.remote.deleteConfirm": "删除“{name}”?", "desktop.remote.deleteFailed": "无法删除连接:{reason}", "desktop.remote.diagnostics": "OpenSSH 输出", + "desktop.remote.edit": "编辑", "desktop.remote.empty": "还没有保存的连接。填写右侧表单后保存。", "desktop.remote.error.duplicate": "另一个已保存的连接已在使用这个值。", "desktop.remote.error.fieldTooLong": "太长:最多 1024 字节。", "desktop.remote.error.full": "最多保存 128 个连接,请先删除一个。", + "desktop.remote.error.groupInvalid": "分组名不能包含换行、制表符等控制字符。", + "desktop.remote.error.groupTooLong": "太长:最多 64 个字符。", "desktop.remote.error.hostInvalid": "只填主机名、IP 地址或 SSH 别名;用户名和端口请填到各自的字段。", "desktop.remote.error.invalid": "这个值不被接受。", "desktop.remote.error.keepAliveInvalid": "请填 1 到 3600 秒。", @@ -5012,9 +5046,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.error.timeoutInvalid": "请填 1 到 600 秒。", "desktop.remote.error.unknown": "这个连接已不存在。", "desktop.remote.error.userInvalid": "用户名含有 SSH 不接受的字符。", + "desktop.remote.group": "分组", + "desktop.remote.group.new": "新建分组…", + "desktop.remote.group.none": "不分组", + "desktop.remote.groupHelp": "左侧列表按分组列出连接。只差大小写的分组名视为同一个分组。", + "desktop.remote.groupPlaceholder": "分组名称", "desktop.remote.host": "主机", "desktop.remote.hostHelp": "主机名、IP 地址或 ~/.ssh/config 里的 Host 别名。OpenSSH 照常读取它的配置;这里留空的字段不会覆盖配置里的值。", "desktop.remote.hostPlaceholder": "build.example.com 或 SSH 配置里的别名", + "desktop.remote.hostSection": "主机信息", "desktop.remote.identityFile": "私钥", "desktop.remote.identityFileHelp": "只保存路径并交给 OpenSSH;Lithe 不读取私钥内容。", "desktop.remote.identityFilePlaceholder": "~/.ssh/id_ed25519", @@ -5049,6 +5089,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.saveFailed": "无法保存连接:{reason}", "desktop.remote.saved": "已保存的连接", "desktop.remote.saving": "正在保存…", + "desktop.remote.settings": "连接设置", "desktop.remote.stop": "停止", "desktop.remote.storageHelp": "保存在本机的 {path}。不会保存密码和私钥内容。", "desktop.remote.test": "测试连接", @@ -5057,8 +5098,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.timeoutPlaceholder": "自动(15)", "desktop.remote.title": "远程开发", "desktop.remote.unavailable": "没有可以保存连接的偏好设置目录。", + "desktop.remote.ungrouped": "未分组", + "desktop.remote.untested": "测试连接后,这里会显示主机的系统、CPU、内存和磁盘。", "desktop.remote.user": "用户名", "desktop.remote.userPlaceholder": "自动(SSH 配置,否则本机用户名)", + "desktop.remote.via": "经 {jump}", "desktop.remoteAuth.failed": "无法把回答交给 SSH:{reason}", "desktop.remoteAuth.refused": "SSH 没有接受这个回答:回答最多 8192 字节,且不能包含换行。这个问题已取消。", "desktop.remoteAuth.secretHint": "回答只交给这次 SSH 连接,Lithe 不会保存。", diff --git a/desktop/internal/remoteconn/remoteconn.go b/desktop/internal/remoteconn/remoteconn.go index 22199d7e0..635752257 100644 --- a/desktop/internal/remoteconn/remoteconn.go +++ b/desktop/internal/remoteconn/remoteconn.go @@ -38,8 +38,10 @@ var ( type Source struct { // Connections are the saved entries in their stored order. Connections []core.SavedRemoteConnection - root string - file configfile.Snapshot + // Sections are the headings Core lists the entries under, in display order. + Sections []core.RemoteConnectionSection + root string + file configfile.Snapshot } // Path is the file the list is kept in, for display. @@ -76,6 +78,7 @@ func Read(ctx context.Context, kernel Kernel, root string) (Source, error) { return Source{}, err } source.Connections = state.Connections + source.Sections = state.Sections return source, nil } diff --git a/desktop/internal/workbench/remote.go b/desktop/internal/workbench/remote.go index 1a80575f7..9b95600eb 100644 --- a/desktop/internal/workbench/remote.go +++ b/desktop/internal/workbench/remote.go @@ -3,6 +3,7 @@ package workbench import ( "context" "errors" + "slices" "strconv" "strings" "time" @@ -15,8 +16,10 @@ import ( ) // The Remote Development window keeps the SSH connections the user saved (remoteconn) and tests -// one: the saved list on the left, the selected connection's form on the right. It belongs to the -// window, not to a project, so it opens on the welcome screen as over a project. +// one: the saved list on the left, under the groups Core sections it into, and on the right the +// selected connection's overview, or its form once Edit was clicked (a new connection always shows +// its form). It belongs to the window, not to a project, so it opens on the welcome screen as over +// a project. // // Nothing secret passes through it: a password or a key's passphrase is asked by OpenSSH through // Core's AskPass helper while a test runs, answered in the authentication dialog and never kept; @@ -42,11 +45,19 @@ type remoteState struct { loading bool loaded bool source remoteconn.Source + // rows are the list's rows for source, and groups the groups it names in their order; both + // change only with source (setSource). + rows []remoteListRow + groups []string // readErr is why the list could not be read; nothing can be saved until it can. readErr string list ui.ListState // selected is the id of the saved connection the form edits, "" for a new one. selected string + // editing says whether the selected connection shows its form rather than its overview. + editing bool + // previous is the connection selected before New, shown again when New is cancelled. + previous string form remoteForm saving bool // confirmDelete is the footer's question whether to delete the selected connection. @@ -54,6 +65,12 @@ type remoteState struct { // probe is the running test, nil when none runs; result is the last one's outcome. probe *remoteProbe result *remoteProbeOutcome + // probed is what the last test of each connection found, by the connection as Core stores + // it, so that a saved connection's overview shows its host again after the form was saved + // or the window reopened. It lives in memory while the app runs, outlives the window and + // holds no secret; an edited connection is a new key, so a stale result is never shown for + // it. + probed map[core.SSHConnection]*remoteProbeOutcome // err is the last failure that names no field of the form; fieldErr names one. err string fieldErr remoteFieldRefusal @@ -62,8 +79,28 @@ type remoteState struct { // remoteForm is what the user types for one connection. type remoteForm struct { name, host, port, user, identityFile, proxyJump, timeout, keepAlive ui.Field - authentication string - advanced ui.CollapsibleState + // color marks the connection in the list, "" for none. + color core.RemoteConnectionColor + // group is the group chosen: "" for none, one of the list's groups, or remoteNewGroup for + // the one typed in newGroup. + group string + newGroup ui.Field + authentication string + advanced ui.CollapsibleState +} + +// remoteNewGroup is the group choice that names a new group in the field beside it. No group can +// have this name, since Core refuses control characters in one. +const remoteNewGroup = "\x00new" + +// remoteListRow is a row of the saved list: a section's heading, or a saved connection. +type remoteListRow struct { + // heading is set on a section's heading, which names group ("" for the connections without + // one) and the number of connections in the section. + heading bool + group string + count int + entry *core.SavedRemoteConnection } // remoteProbe is a test in progress, cancelled by Stop or by closing the window. @@ -98,7 +135,7 @@ func (a *App) openRemote(surface actionSurface) { return } r.generation++ - *r = remoteState{open: true, generation: r.generation} + *r = remoteState{open: true, generation: r.generation, probed: r.probed} r.form.clear() a.performed("remote.connections.open", surface) a.loadRemote(remoteLoadSelectFirst, "") @@ -139,7 +176,8 @@ func (a *App) loadRemote(how remoteLoad, id string) { // log-exempt: 用户取消:窗口关闭后不再应用读取结果。 return } - r.loading, r.loaded, r.source, r.readErr = false, true, source, "" + r.loading, r.loaded, r.readErr = false, true, "" + r.setSource(source) if err != nil { a.operationFailed("remote_connections_read", documentLogError(err)) r.readErr = remoteReadFailure(a.language(), source, err) @@ -171,6 +209,43 @@ func remoteReadFailure(language i18n.Language, source remoteconn.Source, err err return i18n.SharedFormat(language, "desktop.remote.readFailed", map[string]string{"reason": err.Error()}) } +// setSource takes the list as read, with its rows: the connections under the sections Core lists +// them in, each section headed by its group once any connection has one. +func (r *remoteState) setSource(source remoteconn.Source) { + r.source, r.rows, r.groups = source, nil, nil + byID := make(map[string]*core.SavedRemoteConnection, len(source.Connections)) + for index := range source.Connections { + byID[source.Connections[index].ID] = &source.Connections[index] + } + headed := slices.ContainsFunc(source.Sections, func(section core.RemoteConnectionSection) bool { return section.Group != nil }) + for _, section := range source.Sections { + if section.Group != nil { + r.groups = append(r.groups, *section.Group) + } + if headed { + heading := remoteListRow{heading: true, count: len(section.IDs)} + if section.Group != nil { + heading.group = *section.Group + } + r.rows = append(r.rows, heading) + } + for _, id := range section.IDs { + if entry := byID[id]; entry != nil { + r.rows = append(r.rows, remoteListRow{entry: entry}) + } + } + } + // Only a saved connection shows a past test, so the others' results go, which bounds probed + // by the list. + for connection := range r.probed { + if !slices.ContainsFunc(source.Connections, func(entry core.SavedRemoteConnection) bool { + return remoteStored(entry.Connection) == connection + }) { + delete(r.probed, connection) + } + } +} + // entry is the saved connection id, nil when the list has none of that id. func (r *remoteState) entry(id string) *core.SavedRemoteConnection { if id == "" { @@ -184,17 +259,20 @@ func (r *remoteState) entry(id string) *core.SavedRemoteConnection { return nil } -// selectFirst selects the first saved connection, or starts a new one when there is none. +// selectFirst selects the first connection of the list, or starts a new one when there is none. func (r *remoteState) selectFirst() { - if len(r.source.Connections) == 0 { - r.selectNew() - return + for _, row := range r.rows { + if row.entry != nil { + r.selectEntry(row.entry.ID) + return + } } - r.selectEntry(r.source.Connections[0].ID) + r.selectNew() } -// selectEntry shows the saved connection id in the form, dropping what was typed, the last test -// and its errors; a test still running for the previous form is stopped. +// selectEntry shows the overview of the saved connection id, with the form filled from it, +// dropping what was typed, the last test and its errors; a test still running for the previous +// form is stopped. func (r *remoteState) selectEntry(id string) { entry := r.entry(id) if entry == nil { @@ -202,7 +280,7 @@ func (r *remoteState) selectEntry(id string) { return } r.resetEditing() - r.selected = id + r.selected, r.editing = id, false r.form.fill(*entry) r.syncListSelection() } @@ -210,11 +288,58 @@ func (r *remoteState) selectEntry(id string) { // selectNew starts a new connection with an empty form. func (r *remoteState) selectNew() { r.resetEditing() - r.selected = "" + r.selected, r.editing = "", true r.form.clear() r.syncListSelection() } +// editingForm says whether the window shows the form: for a new connection, or for a saved one +// once Edit was clicked. +func (r *remoteState) editingForm() bool { + return r.editing || r.entry(r.selected) == nil +} + +// newRemote starts a new connection; Cancel goes back to the one selected before. +func (a *App) newRemote() { + r := &a.remote + a.performed("remote.connection.new", surfaceButton) + if r.selected != "" { + r.previous = r.selected + } + r.selectNew() +} + +// editSelectedRemote shows the form of the selected connection instead of its overview. +func (a *App) editSelectedRemote() { + r := &a.remote + if r.editingForm() { + return + } + a.performed("remote.connection.edit", surfaceButton) + r.editing, r.confirmDelete = true, false +} + +// cancelRemoteEdit drops what was typed: a saved connection shows its overview again, and a new +// one gives way to the connection selected before it. +func (a *App) cancelRemoteEdit() { + r := &a.remote + a.performed("remote.connection.edit.cancel", surfaceButton) + switch { + case r.entry(r.selected) != nil: + r.selectEntry(r.selected) + case r.entry(r.previous) != nil: + r.selectEntry(r.previous) + default: + r.selectFirst() + } +} + +// probedOutcome is what the last test of connection found while the app runs, nil when it was +// not tested. +func (r *remoteState) probedOutcome(connection core.SSHConnection) *remoteProbeOutcome { + return r.probed[remoteStored(connection)] +} + // resetEditing drops the last test, its errors and the delete question. func (r *remoteState) resetEditing() { r.stopProbe() @@ -223,13 +348,7 @@ func (r *remoteState) resetEditing() { // syncListSelection selects the row of the edited connection, none for a new one. func (r *remoteState) syncListSelection() { - at := -1 - for index, entry := range r.source.Connections { - if entry.ID == r.selected { - at = index - break - } - } + at := r.rowOf(r.selected) if r.list.Selected() != at { r.list.Select(at) if at >= 0 { @@ -238,6 +357,14 @@ func (r *remoteState) syncListSelection() { } } +// rowOf is the list row of the saved connection id, -1 when the list has none. +func (r *remoteState) rowOf(id string) int { + if id == "" { + return -1 + } + return slices.IndexFunc(r.rows, func(row remoteListRow) bool { return row.entry != nil && row.entry.ID == id }) +} + // stopProbe cancels a running test; its result is dropped when it returns. func (r *remoteState) stopProbe() { if r.probe != nil { @@ -253,6 +380,7 @@ func (f *remoteForm) clear() { field.SetText("") } f.authentication = core.RemoteAuthenticationAuto + f.color, f.group = "", "" f.advanced.Open = false } @@ -260,6 +388,8 @@ func (f *remoteForm) clear() { func (f *remoteForm) fill(entry core.SavedRemoteConnection) { connection := entry.Connection f.name.SetText(entry.Name) + f.color, f.group = entry.Color, entry.Group + f.newGroup.SetText("") f.host.SetText(connection.Host) f.port.SetText(optionalNumber(uint64(connection.Port))) f.user.SetText(connection.User) @@ -276,7 +406,16 @@ func (f *remoteForm) fill(entry core.SavedRemoteConnection) { // fields are the form's text fields. func (f *remoteForm) fields() []*ui.Field { - return []*ui.Field{&f.name, &f.host, &f.port, &f.user, &f.identityFile, &f.proxyJump, &f.timeout, &f.keepAlive} + return []*ui.Field{&f.name, &f.host, &f.port, &f.user, &f.identityFile, &f.proxyJump, &f.timeout, &f.keepAlive, &f.newGroup} +} + +// groupName is the group the form saves, as chosen or typed: Core trims it, a blank one is no +// group, and one that differs from a group of the list only in case is that group. +func (f *remoteForm) groupName() string { + if f.group == remoteNewGroup { + return f.newGroup.Text() + } + return f.group } // optionalNumber is value as the form shows it: empty for an unset 0. @@ -350,14 +489,20 @@ func (r *remoteState) dirty() bool { if refused != nil { return true } - saved := entry.Connection - if saved.Authentication == "" { - saved.Authentication = core.RemoteAuthenticationAuto - } - trim := func(text string) string { return strings.TrimSpace(text) } + return r.form.saveName() != entry.Name || remoteStored(connection) != remoteStored(entry.Connection) || + r.form.color != entry.Color || strings.TrimSpace(r.form.groupName()) != entry.Group +} + +// remoteStored is connection as Core stores it: its text trimmed and automatic authentication +// named. +func remoteStored(connection core.SSHConnection) core.SSHConnection { + trim := strings.TrimSpace connection.Host, connection.User = trim(connection.Host), trim(connection.User) connection.IdentityFile, connection.ProxyJump = trim(connection.IdentityFile), trim(connection.ProxyJump) - return r.form.saveName() != entry.Name || connection != saved + if connection.Authentication == "" { + connection.Authentication = core.RemoteAuthenticationAuto + } + return connection } // editable says whether the list can take an edit now. @@ -380,7 +525,13 @@ func (a *App) saveRemote() { return } a.performed("remote.connection.save", surfaceButton) - edit := core.RemoteConnectionEdit{Save: &core.RemoteConnectionSave{ID: r.selected, Name: r.form.saveName(), Connection: connection}} + edit := core.RemoteConnectionEdit{Save: &core.RemoteConnectionSave{ + ID: r.selected, + Name: r.form.saveName(), + Connection: connection, + Color: r.form.color, + Group: r.form.groupName(), + }} a.editRemote("remote_connection_save", edit) } @@ -448,7 +599,8 @@ func (a *App) editRemote(site string, edit core.RemoteConnectionEdit) { } return } - r.source, r.loaded = after, true + r.loaded = true + r.setSource(after) if edit.Remove != nil { r.selectFirst() return @@ -536,6 +688,14 @@ func (a *App) testRemote() { a.operationFailed("remote_probe", errors.New("remote probe: "+string(result.Status))) } r.result = &remoteProbeOutcome{result: result, err: err} + if err == nil { + // What the host is outlives the form; an error that kept the test from + // running says nothing about the host and is only shown. + if r.probed == nil { + r.probed = map[core.SSHConnection]*remoteProbeOutcome{} + } + r.probed[remoteStored(connection)] = r.result + } } }) } @@ -553,7 +713,7 @@ func (a *App) stopRemoteTest() { // remoteFormField says whether the form shows field, Core's name of a connection's field. func remoteFormField(field string) bool { switch field { - case "name", "host", "port", "user", "authentication", "identityFile", "proxyJump", "connectTimeoutSeconds", "keepAliveSeconds": + case "name", "host", "port", "user", "authentication", "identityFile", "proxyJump", "connectTimeoutSeconds", "keepAliveSeconds", "group": return true } return false @@ -565,8 +725,11 @@ func remoteRefusalText(language i18n.Language, refusal remoteFieldRefusal) strin case "required": return i18n.Shared(language, "desktop.remote.error.required") case "tooLong": - if refusal.field == "name" { + switch refusal.field { + case "name": return i18n.Shared(language, "desktop.remote.error.nameTooLong") + case "group": + return i18n.Shared(language, "desktop.remote.error.groupTooLong") } return i18n.Shared(language, "desktop.remote.error.fieldTooLong") case "duplicate": @@ -592,6 +755,8 @@ func remoteRefusalText(language i18n.Language, refusal remoteFieldRefusal) strin return i18n.Shared(language, "desktop.remote.error.timeoutInvalid") case "keepAliveSeconds": return i18n.Shared(language, "desktop.remote.error.keepAliveInvalid") + case "group": + return i18n.Shared(language, "desktop.remote.error.groupInvalid") case "name", "identityFile": return i18n.Shared(language, "desktop.remote.error.textInvalid") } diff --git a/desktop/internal/workbench/remote_connections_visual_test.go b/desktop/internal/workbench/remote_connections_visual_test.go index 986881dae..383a75e56 100644 --- a/desktop/internal/workbench/remote_connections_visual_test.go +++ b/desktop/internal/workbench/remote_connections_visual_test.go @@ -3,7 +3,6 @@ package workbench import ( - "context" "os" "path/filepath" "testing" @@ -14,20 +13,9 @@ import ( "github.com/vivaui/viva/headless" ) -// remoteVisualKernel reports a fixed probe outcome instead of starting OpenSSH; everything else -// is the real Core. -type remoteVisualKernel struct { - *core.Client - result core.RemoteProbeResult -} - -func (k *remoteVisualKernel) RemoteProbe(context.Context, core.SSHConnection) (core.RemoteProbeResult, error) { - return k.result, nil -} - -// TestVisualRemoteConnections captures the Remote Development window: two saved connections -// with the tested one's host report, a host Core refused under its field, and OpenSSH's password -// question over the window. +// TestVisualRemoteConnections captures the Remote Development window: saved connections under +// their groups with the tested one's overview, its form, a new connection whose host Core refused +// under its field, and OpenSSH's password question over the window. func TestVisualRemoteConnections(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -57,7 +45,7 @@ func TestVisualRemoteConnections(t *testing.T) { t.Fatal(err) } var session *headless.Session - kernel := &remoteVisualKernel{Client: core.NewClient(), result: probed} + kernel := &remoteProbeKernel{Client: core.NewClient(), result: probed} h := newHarnessWithDriver(t, Options{Kernel: kernel, Store: prefs, Languages: []string{look.language}}, func(config app.Config) (*app.Driver, func(), error) { config.Width, config.Height = 1200, 760 var err error @@ -80,32 +68,59 @@ func TestVisualRemoteConnections(t *testing.T) { h.settleChain() r := &h.app.remote - save := func(name, host, port, user, authentication, identityFile string) { + type saved struct { + name, host, port, user, authentication, identityFile, proxyJump, group string + color core.RemoteConnectionColor + } + save := func(entry saved) { t.Helper() r.selectNew() - r.form.name.SetText(name) - r.form.host.SetText(host) - r.form.port.SetText(port) - r.form.user.SetText(user) - r.form.authentication = authentication - r.form.identityFile.SetText(identityFile) + r.form.name.SetText(entry.name) + r.form.host.SetText(entry.host) + r.form.port.SetText(entry.port) + r.form.user.SetText(entry.user) + r.form.authentication = entry.authentication + r.form.identityFile.SetText(entry.identityFile) + r.form.proxyJump.SetText(entry.proxyJump) + r.form.color = entry.color + r.form.group = remoteNewGroup + r.form.newGroup.SetText(entry.group) h.app.saveRemote() h.settleChain() if r.err != "" || r.fieldErr.field != "" { - t.Fatalf("saving %s: %q %+v", name, r.err, r.fieldErr) + t.Fatalf("saving %s: %q %+v", entry.name, r.err, r.fieldErr) + } + } + save(saved{name: "Build box", host: "build.example", port: "2222", user: "dev", authentication: core.RemoteAuthenticationPrivateKey, + identityFile: "/home/me/.ssh/id_ed25519", proxyJump: "bastion.example", group: "Production", color: core.RemoteConnectionRed}) + save(saved{name: "API gateway", host: "api.example", user: "deploy", authentication: core.RemoteAuthenticationAgent, + group: "Production", color: core.RemoteConnectionOrange}) + save(saved{name: "Lab ARM", host: "lab-arm.internal", user: "dev", authentication: core.RemoteAuthenticationAgent, + group: "Lab", color: core.RemoteConnectionGreen}) + save(saved{name: "Scratch VM", host: "10.0.4.17", authentication: core.RemoteAuthenticationAuto}) + buildBox := "" + for _, entry := range r.source.Connections { + if entry.Name == "Build box" { + buildBox = entry.ID } } - save("Lab ARM", "lab-arm.internal", "", "dev", core.RemoteAuthenticationAgent, "") - save("Build box", "build.example", "2222", "dev", core.RemoteAuthenticationPrivateKey, "/home/me/.ssh/id_ed25519") + r.selectEntry(buildBox) h.app.testRemote() h.settleChain() if r.result == nil { t.Fatal("the test did not report") } - shot("tested") + shot("overview") - r.selectNew() + h.app.editSelectedRemote() + r.form.advanced.Open = true + shot("edit") + + h.app.newRemote() r.form.host.SetText("dev@build.example") + r.form.color = core.RemoteConnectionPurple + r.form.group = remoteNewGroup + r.form.newGroup.SetText("Experiments") h.app.saveRemote() h.settleChain() if r.fieldErr.field != "host" { @@ -113,11 +128,7 @@ func TestVisualRemoteConnections(t *testing.T) { } shot("refused") - for _, entry := range r.source.Connections { - if entry.Name == "Build box" { - r.selectEntry(entry.ID) - } - } + r.selectEntry(buildBox) done := make(chan struct{}) h.app.gitAuth.queue = append(h.app.gitAuth.queue, core.GitAuthChallenge{ RequestID: "visual", Prompt: "dev@build.example's password: ", Secret: true, Attempt: 1, Remote: true, Done: done, diff --git a/desktop/internal/workbench/remote_test.go b/desktop/internal/workbench/remote_test.go index 593398050..8ef9e2ac2 100644 --- a/desktop/internal/workbench/remote_test.go +++ b/desktop/internal/workbench/remote_test.go @@ -43,11 +43,28 @@ func (h *harness) pressTest() { } } +// remoteProbeKernel reports a fixed probe outcome instead of starting OpenSSH; everything else +// is the real Core. +type remoteProbeKernel struct { + *core.Client + result core.RemoteProbeResult +} + +func (k *remoteProbeKernel) RemoteProbe(context.Context, core.SSHConnection) (core.RemoteProbeResult, error) { + return k.result, nil +} + // remoteHarness is an English window with the Remote Development window open and its saved list // read, through the real Core. func remoteHarness(t *testing.T) (*harness, *treeRecordingLog) { t.Helper() - h := newHarnessWithLanguages(t, &testKernel{Client: core.NewClient()}, []string{"en-US"}) + return remoteHarnessWith(t, &testKernel{Client: core.NewClient()}) +} + +// remoteHarnessWith is remoteHarness through kernel. +func remoteHarnessWith(t *testing.T, kernel Kernel) (*harness, *treeRecordingLog) { + t.Helper() + h := newHarnessWithLanguages(t, kernel, []string{"en-US"}) logger := &treeRecordingLog{} h.app.logSink = logger h.app.openRemote(surfaceMenu) @@ -123,9 +140,9 @@ func rejected(logger *treeRecordingLog, operation, reason string) bool { }) } -// A connection typed into the window is saved to the preference directory under the host's name, -// edited in place and deleted after the footer's question; only the operations are logged, never -// the host or the user. +// A connection typed into the window is saved to the preference directory under the host's name +// and shown in its overview, edited in place from the overview's Edit and deleted after the +// footer's question; only the operations are logged, never the host or the user. func TestRemoteConnectionsSaveEditAndDelete(t *testing.T) { h, logger := remoteHarness(t) lang := h.app.language() @@ -151,7 +168,14 @@ func TestRemoteConnectionsSaveEditAndDelete(t *testing.T) { if r.selected == "" || r.selected != entries[0].ID || !h.shows("dev@build.example") || r.dirty() { t.Fatalf("selected = %q, dirty = %v: the saved connection is not the one the form edits", r.selected, r.dirty()) } + if r.editingForm() || !h.shows(i18n.Shared(lang, "desktop.remote.settings")) || !h.showsWrapped(i18n.Shared(lang, "desktop.remote.untested")) { + t.Fatal("a saved connection does not show its overview") + } + h.clickLabeled(i18n.Shared(lang, "desktop.remote.edit")) + if !r.editingForm() || r.selected != entries[0].ID { + t.Fatal("Edit does not show the saved connection's form") + } r.form.name.SetText("Build box") r.form.port.SetText("2222") h.redraw() @@ -161,6 +185,9 @@ func TestRemoteConnectionsSaveEditAndDelete(t *testing.T) { if len(entries) != 1 || entries[0].Name != "Build box" || entries[0].Connection.Port != 2222 || !h.shows("Build box") { t.Fatalf("edited %+v, want the one connection renamed with its port", entries) } + if r.editingForm() || !h.shows("dev@build.example:2222") { + t.Fatal("saving the edit does not go back to the overview") + } h.clickLabeled(i18n.Shared(lang, "desktop.remote.delete")) h.settle() @@ -175,7 +202,7 @@ func TestRemoteConnectionsSaveEditAndDelete(t *testing.T) { if got := savedRemoteConnections(t, h); len(got) != 0 || r.selected != "" || !h.showsWrapped(i18n.Shared(lang, "desktop.remote.empty")) { t.Fatalf("after deleting: saved %v, selected %q", got, r.selected) } - want := []string{"remote.connections.open", "remote.connection.save", "remote.connection.save", "remote.connection.remove"} + want := []string{"remote.connections.open", "remote.connection.save", "remote.connection.edit", "remote.connection.save", "remote.connection.remove"} if got := remoteActions(logger); !slices.Equal(got, want) { t.Fatalf("performed %q, want %q", got, want) } @@ -205,10 +232,176 @@ func TestRemoteSavedConnectionIsTheSelectedRow(t *testing.T) { h.redraw() h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) h.redraw() - at := slices.IndexFunc(r.source.Connections, func(entry core.SavedRemoteConnection) bool { return entry.ID == r.selected }) - if r.selected == "" || at < 0 || r.list.Selected() != at { - t.Fatalf("after saving %d: list row %d, want %d, the connection the form edits", len(r.source.Connections), r.list.Selected(), at) + at := r.list.Selected() + if r.selected == "" || at < 0 || at >= len(r.rows) || r.rows[at].entry == nil || r.rows[at].entry.ID != r.selected { + t.Fatalf("after saving %d: list row %d, want the row of %q, the connection the form edits", len(r.source.Connections), at, r.selected) + } + } +} + +// A connection's color and group are kept with it in Core's list, a new group named in the field +// beside the choice; the list heads its sections with their groups once any connection has one, +// the connections without one last. +func TestRemoteConnectionsColorAndGroup(t *testing.T) { + h, logger := remoteHarness(t) + lang := h.app.language() + r := &h.app.remote + r.form.host.SetText("lab-arm.internal") + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.color.green")) + if r.form.color != core.RemoteConnectionGreen { + t.Fatalf("color = %q after clicking Green", r.form.color) + } + r.form.group = remoteNewGroup + h.redraw() + if got := h.focusedName(); got != i18n.Shared(lang, "desktop.remote.groupPlaceholder") { + t.Fatalf("focused %q, want the new group's name", got) + } + h.typeText("Lab") + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + entries := savedRemoteConnections(t, h) + if len(entries) != 1 || entries[0].Color != core.RemoteConnectionGreen || entries[0].Group != "Lab" { + t.Fatalf("saved %+v, want the green connection in Lab", entries) + } + if len(r.rows) != 2 || !r.rows[0].heading || r.rows[0].group != "Lab" || r.rows[0].count != 1 || !slices.Equal(r.groups, []string{"Lab"}) { + t.Fatalf("rows %+v, groups %q: want Lab's heading over its connection", r.rows, r.groups) + } + + h.clickLabeled(i18n.Shared(lang, "desktop.remote.new")) + if r.form.color != "" || r.form.group != "" { + t.Fatalf("a new connection starts with color %q, group %q", r.form.color, r.form.group) + } + r.form.host.SetText("build.example") + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + headings := func() (groups []string) { + for _, row := range r.rows { + if row.heading { + groups = append(groups, remoteGroupHeading(lang, row.group)) + } + } + return groups + } + if got := headings(); !slices.Equal(got, []string{"Lab", i18n.Shared(lang, "desktop.remote.ungrouped")}) || !h.shows(i18n.Shared(lang, "desktop.remote.ungrouped")) { + t.Fatalf("headings %q, want Lab, then the connections without a group", got) + } + + // An existing group is a choice of its own; choosing it moves the connection under it. + h.clickLabeled(i18n.Shared(lang, "desktop.remote.edit")) + r.form.group = "Lab" + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + if got := headings(); !slices.Equal(got, []string{"Lab"}) || r.rows[0].count != 2 { + t.Fatalf("headings %q, rows %+v, want both connections under Lab", got, r.rows) + } + if event := loggedAny(t, logger, "lab-arm.internal", "build.example"); event != "" { + t.Fatalf("logged the connection: %s", event) + } +} + +// Cancel drops what was typed: an edited connection shows its overview as saved, and a new one +// gives way to the connection selected before New. +func TestRemoteCancelGoesBackToTheSavedConnection(t *testing.T) { + h, logger := remoteHarness(t) + lang := h.app.language() + r := &h.app.remote + for index, host := range []string{"lab-arm.internal", "build.example"} { + if index > 0 { + h.clickLabeled(i18n.Shared(lang, "desktop.remote.new")) } + r.form.host.SetText(host) + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + } + build := r.selected + if entry := r.entry(build); entry == nil || entry.Name != "build.example" || r.editingForm() { + t.Fatalf("selected %q, want the overview of the second connection", build) + } + + h.clickLabeled(i18n.Shared(lang, "desktop.remote.edit")) + r.form.name.SetText("Renamed") + h.redraw() + if !r.dirty() { + t.Fatal("a renamed connection is not dirty") + } + h.clickLabeled(i18n.Shared(lang, "desktop.remote.cancel")) + if r.editingForm() || r.selected != build || r.form.name.Text() != "build.example" || h.shows("Renamed") { + t.Fatalf("after Cancel: editing = %v, selected = %q, name = %q", r.editingForm(), r.selected, r.form.name.Text()) + } + + h.clickLabeled(i18n.Shared(lang, "desktop.remote.new")) + if !r.editingForm() || r.selected != "" { + t.Fatal("New does not show an empty form") + } + h.clickLabeled(i18n.Shared(lang, "desktop.remote.cancel")) + if r.editingForm() || r.selected != build { + t.Fatalf("after cancelling New: selected %q, want %q", r.selected, build) + } + if got := savedRemoteConnections(t, h); len(got) != 2 || got[1].Name != "build.example" { + t.Fatalf("saved %+v, want both connections as saved", got) + } + want := []string{ + "remote.connections.open", "remote.connection.save", "remote.connection.new", "remote.connection.save", + "remote.connection.edit", "remote.connection.edit.cancel", "remote.connection.new", "remote.connection.edit.cancel", + } + if got := remoteActions(logger); !slices.Equal(got, want) { + t.Fatalf("performed %q, want %q", got, want) + } +} + +// What a test found about the host shows in the overview of the connection it tested, after the +// connection is saved and again after the window is opened anew; a connection never tested says +// how to find out. +func TestRemoteOverviewShowsTheTestedHost(t *testing.T) { + const gib = uint64(1) << 30 + kernel := &remoteProbeKernel{Client: core.NewClient(), result: core.RemoteProbeResult{ + Status: core.RemoteProbeConnected, + Host: &core.RemoteProbedHost{ + System: "Linux", Machine: "x86_64", HomeDirectory: "/home/dev", + Details: core.RemoteHostDetails{HostName: "build-01", CPUCount: 16, MemoryBytes: 64 * gib}, + }, + }} + h, _ := remoteHarnessWith(t, kernel) + lang := h.app.language() + r := &h.app.remote + r.form.host.SetText("build.example") + r.form.user.SetText(" dev ") + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.test")) + h.await("the test to finish", func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if !h.shows("build-01") { + t.Fatal("the form does not show what the test found") + } + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + shown := func() bool { + return !r.editingForm() && h.shows("build-01") && h.shows(i18n.Shared(lang, "desktop.remote.probe.cpu")) && + !h.showsWrapped(i18n.Shared(lang, "desktop.remote.untested")) + } + if !shown() { + t.Fatal("the saved connection's overview does not show the host the test found") + } + + h.app.closeRemote() + h.app.openRemote(surfaceMenu) + h.settle() + h.settle() + if !shown() { + t.Fatal("the overview forgot the tested host when the window opened again") + } + + h.clickLabeled(i18n.Shared(lang, "desktop.remote.new")) + r.form.host.SetText("lab-arm.internal") + h.redraw() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.save")) + h.settle() + if h.shows("build-01") || !h.showsWrapped(i18n.Shared(lang, "desktop.remote.untested")) { + t.Fatal("a connection never tested shows another one's host") } } diff --git a/desktop/internal/workbench/remote_view.go b/desktop/internal/workbench/remote_view.go index 304fa33aa..a20dbdcc2 100644 --- a/desktop/internal/workbench/remote_view.go +++ b/desktop/internal/workbench/remote_view.go @@ -12,21 +12,31 @@ import ( "github.com/vivaui/viva/ui" ) -// This file draws the Remote Development window of remote.go. +// This file draws the Remote Development window of remote.go: the saved list on the left, and +// beside it the selected connection's overview or the form. const ( - // remoteWindowWidth and remoteWindowHeight size the window: the list beside a form whose - // labels and fields stay on one line each. - remoteWindowWidth = 820 - remoteWindowHeight = 580 + // remoteWindowWidth and remoteWindowHeight size the window: the list beside a form of two or + // three fields a line. + remoteWindowWidth = 980 + remoteWindowHeight = 660 // remoteListWidth is the width of the saved list. - remoteListWidth = 240 - // remoteLabelWidth is the width of the form's label column. - remoteLabelWidth = 132 - // remoteRowHeight is the height of a saved connection's row: its name over its address. - remoteRowHeight = 44 + remoteListWidth = 264 + // remoteRowHeight is the height of a saved connection's row: its name over its address; + // remoteHeadingHeight is the height of a group's heading. + remoteRowHeight = 44 + remoteHeadingHeight = 26 + // remoteSettingWidth is the width of the names in the overview's settings and host details. + remoteSettingWidth = 150 + // remotePortWidth is the width of the port beside the host. + remotePortWidth = 210 + // remoteSwatchSize is the size of a color choice. + remoteSwatchSize = 22 ) +// remoteColorChoices are the form's color choices in their order: none, then Core's colors. +var remoteColorChoices = append([]core.RemoteConnectionColor{""}, core.RemoteConnectionColors...) + // remoteView declares the window while it is open. Escape, the scrim and the close button end it // like Close. func (a *App) remoteView(c ui.C) { @@ -51,64 +61,56 @@ func (a *App) remoteView(c ui.C) { } } -// remoteList declares the saved connections, under a header with the button that starts a new one. +// remoteList declares the saved connections under their groups, below a header with the button +// that starts a new one. func (a *App) remoteList(c ui.C) { r := &a.remote language := a.language() k := c.Part("list") title := i18n.Shared(language, "desktop.remote.saved") ui.Column(k).Width(remoteListWidth).FillHeight().Shrink(0).Children(func() { - ui.Row(k.Part("header")).FillWidth().Height(panelHeaderHeight).Shrink(0).Items(ui.Center).Gap(4).PadSides(0, 6, 0, 10).Children(func() { + ui.Row(k.Part("header")).FillWidth().Height(panelHeaderHeight).Shrink(0).Items(ui.Center).Gap(4).PadSides(0, 6, 0, 12).Children(func() { ui.Text(k, title).FontSize(a.theme.Metrics.FontSizeS).Weight(gfx.WeightSemibold).Color(a.colors.Subtle).Ellipsis().Shrink(1).MinWidth(0) if path := r.source.Path(); path != "" { a.remoteHelp(k.Part("storage"), i18n.SharedFormat(language, "desktop.remote.storageHelp", map[string]string{"path": path})) } ui.Spacer(k) if a.gitIconButton(k.Part("new"), i18n.Shared(language, "desktop.remote.new"), icons.Plus, false, r.saving) { - c.After(func() { - a.performed("remote.connection.new", surfaceButton) - r.selectNew() - }) + c.After(a.newRemote) } }) ui.Row(k).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) - connections := r.source.Connections - if len(connections) == 0 { + rows := r.rows + if len(rows) == 0 { text := i18n.Shared(language, "desktop.remote.empty") if r.loading { text = i18n.Shared(language, "native.loading") } - ui.Row(k.Part("empty")).FillWidth().Pad(10).Children(func() { + ui.Row(k.Part("empty")).FillWidth().Pad(12).Children(func() { ui.Paragraph(k, text, 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) }) return } r.list.Label = func(row int) string { - if row < 0 || row >= len(r.source.Connections) { + if row < 0 || row >= len(r.rows) { return "" } - return r.source.Connections[row].Name + if r.rows[row].heading { + return remoteGroupHeading(language, r.rows[row].group) + } + return r.rows[row].entry.Name } - ui.List(k.Part("rows"), &r.list, len(connections), func(row ui.ListRow) { - entry := connections[row.Index] - rc := row.C - row.Element.Height(remoteRowHeight).PadX(10).Gap(8).Items(ui.Center).Hover(ui.Look{}.Background(a.colors.Hover)) - // The row of the edited connection is highlighted, also in the frame a save added it, - // before the list's own selection can reach it. - if entry.ID == r.selected { - row.Element.Background(a.colors.Selection) + r.list.Header = func(row int) bool { return row >= 0 && row < len(r.rows) && r.rows[row].heading } + ui.List(k.Part("rows"), &r.list, len(rows), func(row ui.ListRow) { + if item := rows[row.Index]; item.heading { + a.remoteHeadingRow(row, language, item) + } else { + a.remoteEntryRow(row, *item.entry) } - row.Element.Children(func() { - ui.Icon(rc, icons.Server).Size(16, 16).Shrink(0).Color(a.colors.Subtle) - ui.Column(rc).Grow(1).Shrink(1).MinWidth(0).Gap(2).Children(func() { - ui.Text(rc, entry.Name).Weight(gfx.WeightSemibold).Ellipsis() - ui.Text(rc, remoteAddress(entry.Connection)).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Ellipsis() - }) - }) }).Scrollbars().FillWidth().Grow(1).Shrink(1).MinHeight(0).Label(title) if r.list.Changed() { - if at := r.list.Selected(); at >= 0 && at < len(connections) && connections[at].ID != r.selected { - id := connections[at].ID + if at := r.list.Selected(); at >= 0 && at < len(rows) && rows[at].entry != nil && rows[at].entry.ID != r.selected { + id := rows[at].entry.ID c.After(func() { a.performed("remote.connection.select", surfaceButton) r.selectEntry(id) @@ -122,6 +124,87 @@ func (a *App) remoteList(c ui.C) { }) } +// remoteGroupHeading is the heading of group in the list, "" being the connections without one. +func remoteGroupHeading(language i18n.Language, group string) string { + if group == "" { + return i18n.Shared(language, "desktop.remote.ungrouped") + } + return group +} + +// remoteHeadingRow declares a group's heading with the number of its connections. It stays at the +// top while its connections scroll under it, so it has the window's background. +func (a *App) remoteHeadingRow(row ui.ListRow, language i18n.Language, heading remoteListRow) { + rc := row.C + row.Element.Height(remoteHeadingHeight).PadSides(0, 12, 0, 12).Gap(6).Items(ui.Center).Background(a.theme.Popover).Children(func() { + ui.Text(rc, remoteGroupHeading(language, heading.group)).FontSize(a.theme.Metrics.FontSizeS).Weight(gfx.WeightSemibold). + Color(a.colors.Subtle).Ellipsis().Shrink(1).MinWidth(0) + ui.Text(rc, strconv.Itoa(heading.count)).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Shrink(0) + }) +} + +// remoteEntryRow declares a saved connection's row: its color's bar, its name and its address. +func (a *App) remoteEntryRow(row ui.ListRow, entry core.SavedRemoteConnection) { + r := &a.remote + rc := row.C + row.Element.Height(remoteRowHeight).PadSides(0, 10, 0, 4).Gap(8).Items(ui.Center).Hover(ui.Look{}.Background(a.colors.Hover)) + // The row of the edited connection is highlighted, also in the frame a save added it, + // before the list's own selection can reach it. + if entry.ID == r.selected { + row.Element.Background(a.colors.Selection) + } + row.Element.Children(func() { + bar := ui.Row(rc).Width(3).Height(remoteRowHeight - 16).Shrink(0).Radius(1.5) + if color, ok := remoteColor(a.colors.Dark, entry.Color); ok { + bar.Background(color) + } + ui.Icon(rc, icons.Server).Size(16, 16).Shrink(0).Color(a.colors.Subtle) + ui.Column(rc).Grow(1).Shrink(1).MinWidth(0).Gap(2).Children(func() { + ui.Text(rc, entry.Name).Weight(gfx.WeightSemibold).Ellipsis() + ui.Text(rc, remoteAddress(entry.Connection)).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Ellipsis() + }) + }) +} + +// remoteColor is the color a connection is marked with in the light or dark look, false for none. +// The pairs are the ones the repository marks use, readable on either background. +func remoteColor(dark bool, color core.RemoteConnectionColor) (gfx.Color, bool) { + switch color { + case core.RemoteConnectionRed: + return pick(dark, 0xE06C75, 0xC2353F), true + case core.RemoteConnectionOrange: + return pick(dark, 0xE5A04B, 0xC06A12), true + case core.RemoteConnectionYellow: + return pick(dark, 0xE5C07B, 0xB08800), true + case core.RemoteConnectionGreen: + return pick(dark, 0x5FAD65, 0x369650), true + case core.RemoteConnectionBlue: + return pick(dark, 0x4DA3E8, 0x1F6FD1), true + case core.RemoteConnectionPurple: + return pick(dark, 0xB589EC, 0x834DF0), true + } + return gfx.Color{}, false +} + +// remoteColorName names color, one of remoteColorChoices. +func remoteColorName(language i18n.Language, color core.RemoteConnectionColor) string { + switch color { + case core.RemoteConnectionRed: + return i18n.Shared(language, "desktop.remote.color.red") + case core.RemoteConnectionOrange: + return i18n.Shared(language, "desktop.remote.color.orange") + case core.RemoteConnectionYellow: + return i18n.Shared(language, "desktop.remote.color.yellow") + case core.RemoteConnectionGreen: + return i18n.Shared(language, "desktop.remote.color.green") + case core.RemoteConnectionBlue: + return i18n.Shared(language, "desktop.remote.color.blue") + case core.RemoteConnectionPurple: + return i18n.Shared(language, "desktop.remote.color.purple") + } + return i18n.Shared(language, "desktop.remote.color.none") +} + // remoteAddress is a connection as OpenSSH would address it: [user@]host[:port]. func remoteAddress(connection core.SSHConnection) string { address := connection.Host @@ -139,72 +222,276 @@ func remoteAddress(connection core.SSHConnection) string { return address } -// remoteDetail declares the form of the edited connection, then what the last test found. +// remoteDetail declares the selected connection's overview, or the form with what the last test +// found under it. func (a *App) remoteDetail(c ui.C) { r := &a.remote language := a.language() k := c.Part("detail") ui.Scroll(k).Scrollbars().Grow(1).FillHeight().MinWidth(0).Children(func() { - ui.Column(k.Part("form")).FillWidth().Pad(16).Gap(10).Children(func() { + ui.Column(k.Part("content")).FillWidth().PadSides(18, 22, 18, 22).Gap(14).Children(func() { if r.readErr != "" { a.remoteNotice(k.Part("read"), icons.CircleAlert, a.theme.Danger, r.readErr) } - a.remoteFields(k) + if entry := r.entry(r.selected); entry != nil && !r.editingForm() { + a.remoteOverview(k.Part("overview"), language, *entry) + } else { + a.remoteFields(k.Part("form")) + } if r.err != "" { ui.Paragraph(k.Part("error"), r.err, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) } - a.remoteResult(k.Part("result"), language) + if r.editingForm() { + a.remoteFormResult(k.Part("result"), language) + } + }) + }) +} + +// remoteOverview declares a saved connection: its mark, name, group and address with Edit, what +// the last test found about the host, and its settings. +func (a *App) remoteOverview(c ui.C, language i18n.Language, entry core.SavedRemoteConnection) { + r := &a.remote + connection := entry.Connection + ui.Row(c.Part("header")).FillWidth().Gap(12).Items(ui.Center).Children(func() { + mark := ui.Row(c.Part("mark")).Size(40, 40).Shrink(0).Radius(8).Center() + markIcon := a.colors.Subtle + if color, ok := remoteColor(a.colors.Dark, entry.Color); ok { + mark.Background(color) + markIcon = gfx.RGB24(0xFFFFFF) + } else { + mark.Background(a.colors.Hover) + } + mark.Children(func() { + ui.Icon(c, icons.Server).Size(20, 20).Color(markIcon) }) + ui.Column(c.Part("title")).Grow(1).Shrink(1).MinWidth(0).Gap(4).Children(func() { + ui.Row(c.Part("name")).FillWidth().Gap(8).Items(ui.Center).Children(func() { + ui.Text(c, entry.Name).FontSize(16).Weight(gfx.WeightSemibold).Ellipsis().Shrink(1).MinWidth(0) + if entry.Group != "" { + ui.Badge(c, entry.Group).Shrink(0) + } + }) + ui.Row(c.Part("address")).FillWidth().Gap(8).Items(ui.Center).Children(func() { + ui.Text(c, remoteAddress(connection)).Mono().FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Ellipsis().Shrink(1).MinWidth(0) + if jump := strings.TrimSpace(connection.ProxyJump); jump != "" { + ui.Text(c, i18n.SharedFormat(language, "desktop.remote.via", map[string]string{"jump": jump})).FontSize(a.theme.Metrics.FontSizeS). + Color(a.colors.Subtle).Ellipsis().Shrink(1).MinWidth(0) + } + }) + }) + if ui.Button(c.Part("edit"), i18n.Shared(language, "desktop.remote.edit")).Icon(icons.Pencil).Outline().Disabled(r.saving).Clicked() { + c.After(a.editSelectedRemote) + } + }) + ui.Row(c.Part("header-line")).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) + + a.remoteSectionHeading(c.Part("host-heading"), i18n.Shared(language, "desktop.remote.hostSection")) + outcome := r.result + if outcome == nil { + outcome = r.probedOutcome(connection) + } + switch { + case r.probe != nil: + a.remoteNotice(c.Part("testing"), icons.LoaderCircle, a.colors.Subtle, i18n.Shared(language, "desktop.remote.testing")) + case outcome == nil: + ui.Paragraph(c.Part("untested"), i18n.Shared(language, "desktop.remote.untested"), 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) + default: + a.remoteOutcome(c.Part("outcome"), language, outcome) + } + + a.remoteSectionHeading(c.Part("settings-heading"), i18n.Shared(language, "desktop.remote.settings")) + a.remoteSettings(c.Part("settings"), language, connection) +} + +// remoteSectionHeading declares the heading of a part of the overview. +func (a *App) remoteSectionHeading(c ui.C, title string) { + ui.Text(c, title).FontSize(a.theme.Metrics.FontSizeS).Weight(gfx.WeightSemibold).PadTop(4) +} + +// remoteSettings declares a saved connection's settings, one a line. A setting left to OpenSSH +// says what it falls back to, as the form's placeholder does. +func (a *App) remoteSettings(c ui.C, language i18n.Language, connection core.SSHConnection) { + type setting struct { + label, value string + // fallback says the value is what an unset setting falls back to. + fallback bool + } + set := func(label, value string) setting { return setting{label: label, value: value} } + // optional is a setting that falls back to unset when value is "". + optional := func(label, value, unset string) setting { + if value == "" { + return setting{label: label, value: unset, fallback: true} + } + return set(label, value) + } + settings := []setting{ + set(i18n.Shared(language, "desktop.remote.host"), connection.Host), + optional(i18n.Shared(language, "desktop.remote.port"), optionalNumber(uint64(connection.Port)), i18n.Shared(language, "desktop.remote.portPlaceholder")), + optional(i18n.Shared(language, "desktop.remote.user"), connection.User, i18n.Shared(language, "desktop.remote.userPlaceholder")), + set(i18n.Shared(language, "desktop.remote.authentication"), remoteAuthenticationLabel(language, connection.Authentication)), + } + if connection.Authentication == core.RemoteAuthenticationPrivateKey { + settings = append(settings, set(i18n.Shared(language, "desktop.remote.identityFile"), connection.IdentityFile)) + } + settings = append(settings, + optional(i18n.Shared(language, "desktop.remote.proxyJump"), connection.ProxyJump, i18n.Shared(language, "desktop.remote.proxyJumpPlaceholder")), + optional(i18n.Shared(language, "desktop.remote.timeout"), optionalNumber(uint64(connection.ConnectTimeoutSeconds)), + i18n.Shared(language, "desktop.remote.timeoutPlaceholder")), + optional(i18n.Shared(language, "desktop.remote.keepAlive"), optionalNumber(uint64(connection.KeepAliveSeconds)), + i18n.Shared(language, "desktop.remote.keepAlivePlaceholder")), + ) + ui.Column(c).FillWidth().Border(1, a.colors.Line).Radius(6).Children(func() { + for index, entry := range settings { + k := c.KeyInt(index) + if index > 0 { + ui.Row(k.Part("line")).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) + } + ui.Row(k).FillWidth().MinHeight(32).PadX(12).Gap(12).Items(ui.Center).Children(func() { + ui.Text(k, entry.label).Color(a.colors.Subtle).Width(remoteSettingWidth).Shrink(0).Ellipsis() + value := ui.Text(k, entry.value).Ellipsis().Grow(1).Shrink(1).MinWidth(0) + if entry.fallback { + value.Color(a.colors.Subtle) + } + }) + } }) } -// remoteFields declares the connection's fields, each a row of its label and control, with the -// reason a refused one was refused under it. +// remoteFields declares the form: two or three fields a line, each under its label, with the +// advanced options folded below. func (a *App) remoteFields(c ui.C) { r := &a.remote f := &r.form language := a.language() disabled := r.saving - text := func(key, label, placeholder, help string, field *ui.Field) { - a.remoteRow(c.Part(key), key, label, help, func(k ui.C) { - ui.TextField(k, field, label, placeholder).Grow(1).MinWidth(0).Disabled(disabled) - }) + text := func(k ui.C, label, placeholder string, field *ui.Field) { + ui.TextField(k, field, label, placeholder).FillWidth().MinWidth(0).Disabled(disabled) } - text("name", i18n.Shared(language, "desktop.remote.name"), i18n.Shared(language, "desktop.remote.namePlaceholder"), "", &f.name) - text("host", i18n.Shared(language, "desktop.remote.host"), i18n.Shared(language, "desktop.remote.hostPlaceholder"), i18n.Shared(language, "desktop.remote.hostHelp"), &f.host) - text("port", i18n.Shared(language, "desktop.remote.port"), i18n.Shared(language, "desktop.remote.portPlaceholder"), "", &f.port) - text("user", i18n.Shared(language, "desktop.remote.user"), i18n.Shared(language, "desktop.remote.userPlaceholder"), "", &f.user) - authLabel := i18n.Shared(language, "desktop.remote.authentication") - a.remoteRow(c.Part("authentication"), "authentication", authLabel, i18n.Shared(language, "desktop.remote.authenticationHelp"), func(k ui.C) { - ui.Select(k, &f.authentication, remoteAuthentications, func(way string) string { - return remoteAuthenticationLabel(language, way) - }).Label(authLabel).Grow(1).MinWidth(0).Disabled(disabled) - }) - if f.authentication == core.RemoteAuthenticationPrivateKey { - label := i18n.Shared(language, "desktop.remote.identityFile") - a.remoteRow(c.Part("identityFile"), "identityFile", label, i18n.Shared(language, "desktop.remote.identityFileHelp"), func(k ui.C) { - box := ui.TextField(k, &f.identityFile, label, i18n.Shared(language, "desktop.remote.identityFilePlaceholder")).Grow(1).MinWidth(0).Disabled(disabled). - Action(icons.FolderOpen, i18n.Shared(language, "desktop.remote.choose")) - if box.ActionClicked() { - c.After(a.chooseRemoteIdentity) + line := func(key string, cells func(ui.C)) { + k := c.Part(key) + ui.Row(k).FillWidth().Gap(14).Items(ui.Start).Children(func() { cells(k) }) + } + ui.Column(c).FillWidth().Gap(14).Children(func() { + line("line-name", func(k ui.C) { + label := i18n.Shared(language, "desktop.remote.name") + a.remoteCell(k.Part("name"), "name", label, "", 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.namePlaceholder"), &f.name) + }) + a.remoteCell(k.Part("color"), "", i18n.Shared(language, "desktop.remote.color"), i18n.Shared(language, "desktop.remote.colorHelp"), -1, func(k ui.C) { + a.remoteSwatches(k, language, disabled) + }) + }) + line("line-host", func(k ui.C) { + label := i18n.Shared(language, "desktop.remote.host") + a.remoteCell(k.Part("host"), "host", label, i18n.Shared(language, "desktop.remote.hostHelp"), 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.hostPlaceholder"), &f.host) + }) + label = i18n.Shared(language, "desktop.remote.port") + a.remoteCell(k.Part("port"), "port", label, "", remotePortWidth, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.portPlaceholder"), &f.port) + }) + }) + line("line-user", func(k ui.C) { + label := i18n.Shared(language, "desktop.remote.user") + a.remoteCell(k.Part("user"), "user", label, "", 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.userPlaceholder"), &f.user) + }) + authLabel := i18n.Shared(language, "desktop.remote.authentication") + a.remoteCell(k.Part("authentication"), "authentication", authLabel, i18n.Shared(language, "desktop.remote.authenticationHelp"), 0, func(k ui.C) { + ui.Select(k, &f.authentication, remoteAuthentications, func(way string) string { + return remoteAuthenticationLabel(language, way) + }).Label(authLabel).FillWidth().MinWidth(0).Disabled(disabled) + }) + if f.authentication != core.RemoteAuthenticationPrivateKey { + // The line keeps three columns, so that the fields line up with the key's. + ui.Row(k.Part("identityFile-space")).Grow(1).Basis(0) + return } + label = i18n.Shared(language, "desktop.remote.identityFile") + a.remoteCell(k.Part("identityFile"), "identityFile", label, i18n.Shared(language, "desktop.remote.identityFileHelp"), 0, func(k ui.C) { + box := ui.TextField(k, &f.identityFile, label, i18n.Shared(language, "desktop.remote.identityFilePlaceholder")).FillWidth().MinWidth(0).Disabled(disabled). + Action(icons.FolderOpen, i18n.Shared(language, "desktop.remote.choose")) + if box.ActionClicked() { + c.After(a.chooseRemoteIdentity) + } + }) }) - } - ui.Collapsible(c.Part("advanced"), &f.advanced, i18n.Shared(language, "desktop.remote.advanced"), func() { - k := c.Part("advanced-fields") - ui.Column(k).FillWidth().Gap(10).Children(func() { - text := func(key, label, placeholder, help string, field *ui.Field) { - a.remoteRow(k.Part(key), key, label, help, func(k ui.C) { - ui.TextField(k, field, label, placeholder).Grow(1).MinWidth(0).Disabled(disabled) + line("line-group", func(k ui.C) { a.remoteGroupCells(k, language, disabled) }) + ui.Collapsible(c.Part("advanced"), &f.advanced, i18n.Shared(language, "desktop.remote.advanced"), func() { + k := c.Part("advanced-fields") + ui.Column(k).FillWidth().Gap(14).PadTop(4).Children(func() { + label := i18n.Shared(language, "desktop.remote.proxyJump") + a.remoteCell(k.Part("proxyJump"), "proxyJump", label, i18n.Shared(language, "desktop.remote.proxyJumpHelp"), 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.proxyJumpPlaceholder"), &f.proxyJump) }) - } - text("proxyJump", i18n.Shared(language, "desktop.remote.proxyJump"), i18n.Shared(language, "desktop.remote.proxyJumpPlaceholder"), i18n.Shared(language, "desktop.remote.proxyJumpHelp"), &f.proxyJump) - text("connectTimeoutSeconds", i18n.Shared(language, "desktop.remote.timeout"), i18n.Shared(language, "desktop.remote.timeoutPlaceholder"), "", &f.timeout) - text("keepAliveSeconds", i18n.Shared(language, "desktop.remote.keepAlive"), i18n.Shared(language, "desktop.remote.keepAlivePlaceholder"), i18n.Shared(language, "desktop.remote.keepAliveHelp"), &f.keepAlive) + ui.Row(k.Part("line-timing")).FillWidth().Gap(14).Items(ui.Start).Children(func() { + label := i18n.Shared(language, "desktop.remote.timeout") + a.remoteCell(k.Part("connectTimeoutSeconds"), "connectTimeoutSeconds", label, "", 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.timeoutPlaceholder"), &f.timeout) + }) + label = i18n.Shared(language, "desktop.remote.keepAlive") + a.remoteCell(k.Part("keepAliveSeconds"), "keepAliveSeconds", label, i18n.Shared(language, "desktop.remote.keepAliveHelp"), 0, func(k ui.C) { + text(k, label, i18n.Shared(language, "desktop.remote.keepAlivePlaceholder"), &f.keepAlive) + }) + }) + }) }) }) } +// remoteSwatches declares the color choices: none, then Core's colors, as one stop of Tab that +// the arrows move through. +func (a *App) remoteSwatches(c ui.C, language i18n.Language, disabled bool) { + f := &a.remote.form + ui.Row(c).MinHeight(a.theme.Metrics.ControlHeight).Gap(8).Items(ui.Center).FocusGroup(ui.FocusHorizontal).Children(func() { + for index, choice := range remoteColorChoices { + color, _ := remoteColor(a.colors.Dark, choice) + chosen := f.color == choice + name := remoteColorName(language, choice) + swatch := ui.ColorSwatch(c.KeyInt(index), color, chosen, name).Size(remoteSwatchSize, remoteSwatchSize).TabStop(chosen). + Disabled(disabled).Tooltip(name) + if swatch.Clicked() { + c.After(func() { f.color = choice }) + } + } + }) +} + +// remoteGroupCells declares the group choice: none, the list's groups and a new one, whose name is +// typed in the field beside it. +func (a *App) remoteGroupCells(c ui.C, language i18n.Language, disabled bool) { + r := &a.remote + f := &r.form + label := i18n.Shared(language, "desktop.remote.group") + choices := make([]string, 0, len(r.groups)+2) + choices = append(append(append(choices, ""), r.groups...), remoteNewGroup) + typing := f.group == remoteNewGroup + refused := "group" + if typing { + refused = "" + } + a.remoteCell(c.Part("group"), refused, label, i18n.Shared(language, "desktop.remote.groupHelp"), 0, func(k ui.C) { + ui.Select(k, &f.group, choices, func(group string) string { + switch group { + case "": + return i18n.Shared(language, "desktop.remote.group.none") + case remoteNewGroup: + return i18n.Shared(language, "desktop.remote.group.new") + } + return group + }).Label(label).FillWidth().MinWidth(0).Disabled(disabled) + }) + if !typing { + ui.Row(c.Part("newGroup-space")).Grow(1).Basis(0) + return + } + name := i18n.Shared(language, "desktop.remote.groupPlaceholder") + a.remoteCell(c.Part("newGroup"), "group", name, "", 0, func(k ui.C) { + ui.TextField(k, &f.newGroup, name, name).FillWidth().MinWidth(0).Disabled(disabled).AutoFocus() + }) +} + // remoteAuthenticationLabel names way, one of remoteAuthentications. func remoteAuthenticationLabel(language i18n.Language, way string) string { switch way { @@ -218,24 +505,30 @@ func remoteAuthenticationLabel(language i18n.Language, way string) string { return i18n.Shared(language, "desktop.remote.auth.auto") } -// remoteRow declares one field: its label and ⓘ in the label column, the control beside them, -// and the reason Core refused field under the control. -func (a *App) remoteRow(c ui.C, field, label, help string, control func(ui.C)) { +// remoteCell declares one field of the form: its label and ⓘ over its control, and under it the +// reason Core refused field ("" for a control Core never refuses). width is the cell's width: 0 +// shares the line's width with the other cells, -1 takes what the control needs. +func (a *App) remoteCell(c ui.C, field, label, help string, width float32, control func(ui.C)) { r := &a.remote - ui.Column(c).FillWidth().Gap(4).Children(func() { - ui.Row(c).FillWidth().Gap(12).Items(ui.Center).Children(func() { - ui.Row(c.Part("label")).Width(remoteLabelWidth).MinHeight(28).Shrink(0).Items(ui.Center).Gap(4).Children(func() { - ui.Text(c, label).Ellipsis().Shrink(1).MinWidth(0) - if help != "" { - a.remoteHelp(c, help) - } - }) - control(c) + cell := ui.Column(c).Gap(6).MinWidth(0) + switch { + case width > 0: + cell.Width(width).Shrink(0) + case width == 0: + cell.Grow(1).Basis(0) + default: + cell.Shrink(0) + } + cell.Children(func() { + ui.Row(c.Part("label")).FillWidth().Height(18).Items(ui.Center).Gap(4).Children(func() { + ui.Text(c, label).FontSize(a.theme.Metrics.FontSizeS).Weight(gfx.WeightMedium).Ellipsis().Shrink(1).MinWidth(0) + if help != "" { + a.remoteHelp(c, help) + } }) - if r.fieldErr.field == field { - ui.Row(c.Part("error")).FillWidth().PadSides(0, 0, 0, remoteLabelWidth+12).Children(func() { - ui.Paragraph(c, remoteRefusalText(a.language(), r.fieldErr), 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) - }) + control(c) + if field != "" && r.fieldErr.field == field { + ui.Paragraph(c.Part("error"), remoteRefusalText(a.language(), r.fieldErr), 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) } }) } @@ -254,21 +547,28 @@ func (a *App) remoteNotice(c ui.C, icon gfx.Icon, color gfx.Color, text string) }) } -// remoteResult declares what the running or last test found: the host's platform and what it has -// for a connection, or why it failed with OpenSSH's own output under it. That output is upstream -// text, shown as Core passed it and never logged. -func (a *App) remoteResult(c ui.C, language i18n.Language) { +// remoteFormResult declares, under the form, what the running or last test of what it holds +// found. +func (a *App) remoteFormResult(c ui.C, language i18n.Language) { r := &a.remote - if r.probe != nil { - a.remoteNotice(c, icons.LoaderCircle, a.colors.Subtle, i18n.Shared(language, "desktop.remote.testing")) - return - } - outcome := r.result - if outcome == nil { + if r.probe == nil && r.result == nil { return } - ui.Column(c).FillWidth().Gap(8).PadTop(6).Children(func() { + ui.Column(c).FillWidth().Gap(10).PadTop(2).Children(func() { ui.Row(c).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) + if r.probe != nil { + a.remoteNotice(c.Part("testing"), icons.LoaderCircle, a.colors.Subtle, i18n.Shared(language, "desktop.remote.testing")) + return + } + a.remoteOutcome(c.Part("outcome"), language, r.result) + }) +} + +// remoteOutcome declares what a test found: the host's platform and what it has for a connection, +// or why it failed with OpenSSH's own output under it. That output is upstream text, shown as Core +// passed it and never logged. +func (a *App) remoteOutcome(c ui.C, language i18n.Language, outcome *remoteProbeOutcome) { + ui.Column(c).FillWidth().Gap(8).Children(func() { if outcome.err != nil { text := i18n.SharedFormat(language, "desktop.remote.probe.error", map[string]string{"reason": outcome.err.Error()}) var coreErr *core.Error @@ -340,45 +640,49 @@ func (a *App) remoteHostDetails(c ui.C, language i18n.Language, host core.Remote for index, entry := range items { k := c.KeyInt(index) ui.Row(k).FillWidth().Gap(12).Items(ui.Center).Children(func() { - ui.Text(k, entry.label).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Width(remoteLabelWidth - 24).Shrink(0).Ellipsis() + ui.Text(k, entry.label).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Width(remoteSettingWidth - 24).Shrink(0).Ellipsis() ui.Text(k, entry.value).FontSize(a.theme.Metrics.FontSizeS).Ellipsis().Grow(1).MinWidth(0) }) } }) } -// remoteFooter declares Delete, or the question whether to delete, then Test Connection, Close and -// Save. +// remoteFooter declares the footer. The overview has Delete, or the question whether to delete, +// then Test Connection and Close; the form has Test Connection, then Cancel (Close while nothing +// is saved to go back to) and Save. func (a *App) remoteFooter(c ui.C) { r := &a.remote language := a.language() entry := r.entry(r.selected) - if r.confirmDelete && entry != nil { - ui.Text(c, i18n.SharedFormat(language, "desktop.remote.deleteConfirm", map[string]string{"name": entry.Name})).Ellipsis().Shrink(1).MinWidth(0) - if ui.Button(c.Part("delete-confirm"), i18n.Shared(language, "desktop.remote.delete")).Destructive().Disabled(!r.editable()).Clicked() { - c.After(a.removeRemote) - } - if ui.Button(c.Part("delete-cancel"), i18n.Shared(language, "desktop.remote.cancel")).Outline().Clicked() { - c.After(func() { r.confirmDelete = false }) + if !r.editingForm() { + if r.confirmDelete { + ui.Text(c, i18n.SharedFormat(language, "desktop.remote.deleteConfirm", map[string]string{"name": entry.Name})).Ellipsis().Shrink(1).MinWidth(0) + if ui.Button(c.Part("delete-confirm"), i18n.Shared(language, "desktop.remote.delete")).Destructive().Disabled(!r.editable()).Clicked() { + c.After(a.removeRemote) + } + if ui.Button(c.Part("delete-cancel"), i18n.Shared(language, "desktop.remote.cancel")).Outline().Clicked() { + c.After(func() { r.confirmDelete = false }) + } + ui.Spacer(c) + return } - ui.Spacer(c) - return - } - if entry != nil { if ui.Button(c.Part("delete"), i18n.Shared(language, "desktop.remote.delete")).DestructiveOutline().Disabled(!r.editable()).Clicked() { c.After(func() { r.confirmDelete = true }) } + ui.Spacer(c) + a.remoteTestButton(c, language) + if ui.Button(c.Part("close"), i18n.Shared(language, "desktop.remote.close")).Outline().Clicked() { + c.After(a.closeRemote) + } + return } + a.remoteTestButton(c, language) ui.Spacer(c) - if r.probe != nil { - if ui.Button(c.Part("stop"), i18n.Shared(language, "desktop.remote.stop")).Outline().Clicked() { - c.After(a.stopRemoteTest) + if entry != nil || len(r.rows) > 0 { + if ui.Button(c.Part("cancel"), i18n.Shared(language, "desktop.remote.cancel")).Outline().Disabled(r.saving).Clicked() { + c.After(a.cancelRemoteEdit) } - } else if ui.Button(c.Part("test"), i18n.Shared(language, "desktop.remote.test")).Outline(). - Disabled(strings.TrimSpace(r.form.host.Text()) == "").Clicked() { - c.After(a.testRemote) - } - if ui.Button(c.Part("close"), i18n.Shared(language, "desktop.remote.close")).Outline().Clicked() { + } else if ui.Button(c.Part("close"), i18n.Shared(language, "desktop.remote.close")).Outline().Clicked() { c.After(a.closeRemote) } label := i18n.Shared(language, "desktop.remote.save") @@ -389,3 +693,18 @@ func (a *App) remoteFooter(c ui.C) { c.After(a.saveRemote) } } + +// remoteTestButton declares Test Connection, or Stop while a test runs. +func (a *App) remoteTestButton(c ui.C, language i18n.Language) { + r := &a.remote + if r.probe != nil { + if ui.Button(c.Part("stop"), i18n.Shared(language, "desktop.remote.stop")).Outline().Clicked() { + c.After(a.stopRemoteTest) + } + return + } + if ui.Button(c.Part("test"), i18n.Shared(language, "desktop.remote.test")).Outline(). + Disabled(strings.TrimSpace(r.form.host.Text()) == "").Clicked() { + c.After(a.testRemote) + } +} diff --git a/docs/assets/remote-connections/README.md b/docs/assets/remote-connections/README.md index e71f11a5c..aa95d7167 100644 --- a/docs/assets/remote-connections/README.md +++ b/docs/assets/remote-connections/README.md @@ -1,17 +1,20 @@ # 远程开发连接窗口(#2231)无头测试截图 -来自生产 Viva Page 的无头渲染。连接列表由真实 Core 写入测试临时偏好目录;“测试连接”的结果由测试替换的内核直接返回固定的主机信息,不启动 OpenSSH,密码询问由测试直接放入提问队列。截图覆盖深色与浅色主题、中文与英文界面,用于确认: +来自生产 Viva Page 的无头渲染。连接列表由真实 Core 写入测试临时偏好目录,颜色、分组和分组顺序都由 Core 保存和给出;“测试连接”的结果由测试替换的内核直接返回固定的主机信息,不启动 OpenSSH,密码询问由测试直接放入提问队列。截图里的主机、用户和路径都是虚构的。截图覆盖深色与浅色主题、中文与英文界面,用于确认: -- 保存第二个连接后,列表高亮的是表单正在编辑的连接;测试成功后显示主机名、系统、CPU 数、内存和主目录磁盘; -- 主机字段填了 `user@host` 时,Core 拒绝的原因显示在主机字段下方,没有写入列表; +- 左侧列表按 Core 给出的分组列出连接,分组标题带数量,没有分组的连接排在最后的“未分组”下;每个连接左侧是它的颜色条; +- 选中已保存的连接时右侧显示概览:颜色图标、名称、分组标签、地址和跳板机,“主机信息”显示这次运行中最近一次测试得到的系统、CPU、内存和磁盘,“连接设置”逐项列出设置,未填写的项显示它的回退规则,例如“自动(SSH 配置,否则 22)”; +- 点“编辑”后右侧换成表单:名称与颜色、主机与端口、用户名、身份验证与私钥、分组各占一行,高级选项折叠在下方; +- 新建连接时可以选“新建分组…”并在旁边输入分组名;主机字段填了 `user@host` 时,Core 拒绝的原因显示在主机字段下方,没有写入列表; - OpenSSH 询问密码时,窗口上方弹出“SSH 身份验证”,提示原文照搬,输入框为密码框,说明答案只交给这次连接、不会保存。 截图不代表 macOS/Windows 原生窗口验收。 | 场景 | 浅色英文 | 深色中文 | | --- | --- | --- | -| 测试连接成功 | [浅色英文](remote-connections-tested-light-en-US.png) | [深色中文](remote-connections-tested-dark-zh-CN.png) | -| 主机字段被拒绝 | [浅色英文](remote-connections-refused-light-en-US.png) | [深色中文](remote-connections-refused-dark-zh-CN.png) | +| 已测试连接的概览 | [浅色英文](remote-connections-overview-light-en-US.png) | [深色中文](remote-connections-overview-dark-zh-CN.png) | +| 编辑已保存的连接(展开高级选项) | [浅色英文](remote-connections-edit-light-en-US.png) | [深色中文](remote-connections-edit-dark-zh-CN.png) | +| 新建连接:新分组,主机字段被拒绝 | [浅色英文](remote-connections-refused-light-en-US.png) | [深色中文](remote-connections-refused-dark-zh-CN.png) | | SSH 密码询问 | [浅色英文](remote-connections-password-light-en-US.png) | [深色中文](remote-connections-password-dark-zh-CN.png) | 复验:从仓库根目录设置绝对路径 `LITHE_VISUAL_OUTPUT_DIR="$(pwd)/docs/assets/remote-connections"`,在 `desktop/` 下通过 diff --git a/docs/assets/remote-connections/remote-connections-edit-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-edit-dark-zh-CN.png new file mode 100644 index 000000000..c11e76917 Binary files /dev/null and b/docs/assets/remote-connections/remote-connections-edit-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-edit-light-en-US.png b/docs/assets/remote-connections/remote-connections-edit-light-en-US.png new file mode 100644 index 000000000..4b92a1d54 Binary files /dev/null and b/docs/assets/remote-connections/remote-connections-edit-light-en-US.png differ diff --git a/docs/assets/remote-connections/remote-connections-overview-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-overview-dark-zh-CN.png new file mode 100644 index 000000000..905b2388e Binary files /dev/null and b/docs/assets/remote-connections/remote-connections-overview-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-overview-light-en-US.png b/docs/assets/remote-connections/remote-connections-overview-light-en-US.png new file mode 100644 index 000000000..035cbfa85 Binary files /dev/null and b/docs/assets/remote-connections/remote-connections-overview-light-en-US.png differ diff --git a/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png index 131e4915e..33d0ade83 100644 Binary files a/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png and b/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-password-light-en-US.png b/docs/assets/remote-connections/remote-connections-password-light-en-US.png index 78d5f2c54..5630a59c0 100644 Binary files a/docs/assets/remote-connections/remote-connections-password-light-en-US.png and b/docs/assets/remote-connections/remote-connections-password-light-en-US.png differ diff --git a/docs/assets/remote-connections/remote-connections-refused-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-refused-dark-zh-CN.png index cd0d3147d..21acd4c8e 100644 Binary files a/docs/assets/remote-connections/remote-connections-refused-dark-zh-CN.png and b/docs/assets/remote-connections/remote-connections-refused-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-refused-light-en-US.png b/docs/assets/remote-connections/remote-connections-refused-light-en-US.png index 80942ebca..80d32baf2 100644 Binary files a/docs/assets/remote-connections/remote-connections-refused-light-en-US.png and b/docs/assets/remote-connections/remote-connections-refused-light-en-US.png differ diff --git a/docs/assets/remote-connections/remote-connections-tested-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-tested-dark-zh-CN.png deleted file mode 100644 index 39dfe7e37..000000000 Binary files a/docs/assets/remote-connections/remote-connections-tested-dark-zh-CN.png and /dev/null differ diff --git a/docs/assets/remote-connections/remote-connections-tested-light-en-US.png b/docs/assets/remote-connections/remote-connections-tested-light-en-US.png deleted file mode 100644 index 769da3c51..000000000 Binary files a/docs/assets/remote-connections/remote-connections-tested-light-en-US.png and /dev/null differ diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index d97a4bc44..356c5ecaa 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -317,7 +317,7 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # Lithe-core-rust main at 66a1476: #147 starts, stops and lists port forwards # (remote.startForward, remote.stopForward, remote.forwards) and names the process of each # listening port (S28/S29, #2231). -PINNED_CORE_REVISION="66a147629cc9f82fc551a52682b522230e6a8340" +PINNED_CORE_REVISION="53c7cfa473f7cd5c41ace7d7a872f02fb5a89865" PROFILE="debug" CHECKOUT_ONLY="no" while [[ $# -gt 0 ]]; do diff --git a/shared/i18n/features/remote-connections.json b/shared/i18n/features/remote-connections.json index 3cabe2fc1..582ab0db8 100644 --- a/shared/i18n/features/remote-connections.json +++ b/shared/i18n/features/remote-connections.json @@ -275,7 +275,7 @@ }, { "id": "desktop.remote.cancel", - "description": "Remote Development window: button that takes back the delete question", + "description": "Remote Development window: button that takes back the delete question, or leaves the form without saving what was typed", "platforms": [ "desktop" ] @@ -627,6 +627,163 @@ "parameters": { "reason": "string" } + }, + { + "id": "desktop.remote.edit", + "description": "Remote Development window: button that turns the selected connection's overview into its form", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.settings", + "description": "Remote Development window: heading of a saved connection's settings in its overview", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.hostSection", + "description": "Remote Development window: heading of what the last test found about the host, in a connection's overview", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.untested", + "description": "Remote Development window: text in a connection's overview before it was tested in this session", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.via", + "description": "Remote Development window: address line of a connection's overview: the jump hosts it connects through", + "platforms": [ + "desktop" + ], + "parameters": { + "jump": "string" + } + }, + { + "id": "desktop.remote.color", + "description": "Remote Development window: label of the color choice of a connection", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.colorHelp", + "description": "Remote Development window: tip of the color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.none", + "description": "Remote Development window: color choice that leaves the connection without a color", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.red", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.orange", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.yellow", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.green", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.blue", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.color.purple", + "description": "Remote Development window: color choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.group", + "description": "Remote Development window: label of the group a connection is listed under", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.groupHelp", + "description": "Remote Development window: tip of the group choice", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.group.none", + "description": "Remote Development window: group choice that lists the connection without a group", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.group.new", + "description": "Remote Development window: group choice that names a new group in a field beside it", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.groupPlaceholder", + "description": "Remote Development window: placeholder of the new group's name", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.ungrouped", + "description": "Remote Development window: heading in the list of the connections without a group, shown when others have one", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.error.groupTooLong", + "description": "Remote Development window: a group name longer than allowed", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.error.groupInvalid", + "description": "Remote Development window: a group name with a control character", + "platforms": [ + "desktop" + ] } ], "locales": { @@ -714,7 +871,29 @@ "desktop.remoteAuth.title": "SSH Authentication", "desktop.remoteAuth.secretHint": "The answer goes only to this SSH connection. Lithe does not keep it.", "desktop.remoteAuth.refused": "SSH did not take the answer: it may be at most 8192 bytes and may not contain a line break. The question was cancelled.", - "desktop.remoteAuth.failed": "Cannot pass the answer to SSH: {reason}" + "desktop.remoteAuth.failed": "Cannot pass the answer to SSH: {reason}", + "desktop.remote.edit": "Edit", + "desktop.remote.settings": "Connection Settings", + "desktop.remote.hostSection": "Host", + "desktop.remote.untested": "Test the connection to see the host's system, CPUs, memory and disk.", + "desktop.remote.via": "via {jump}", + "desktop.remote.color": "Color", + "desktop.remote.colorHelp": "Marks the connection in the list, for example to tell production from test hosts. Kept on this computer only.", + "desktop.remote.color.none": "No Color", + "desktop.remote.color.red": "Red", + "desktop.remote.color.orange": "Orange", + "desktop.remote.color.yellow": "Yellow", + "desktop.remote.color.green": "Green", + "desktop.remote.color.blue": "Blue", + "desktop.remote.color.purple": "Purple", + "desktop.remote.group": "Group", + "desktop.remote.groupHelp": "The list shows connections under their group. Group names that differ only in case are the same group.", + "desktop.remote.group.none": "No Group", + "desktop.remote.group.new": "New Group…", + "desktop.remote.groupPlaceholder": "Group name", + "desktop.remote.ungrouped": "Ungrouped", + "desktop.remote.error.groupTooLong": "Too long: at most 64 characters.", + "desktop.remote.error.groupInvalid": "A group name cannot contain line breaks, tabs or other control characters." }, "zh-CN": { "desktop.remote.title": "远程开发", @@ -800,7 +979,29 @@ "desktop.remoteAuth.title": "SSH 身份验证", "desktop.remoteAuth.secretHint": "回答只交给这次 SSH 连接,Lithe 不会保存。", "desktop.remoteAuth.refused": "SSH 没有接受这个回答:回答最多 8192 字节,且不能包含换行。这个问题已取消。", - "desktop.remoteAuth.failed": "无法把回答交给 SSH:{reason}" + "desktop.remoteAuth.failed": "无法把回答交给 SSH:{reason}", + "desktop.remote.edit": "编辑", + "desktop.remote.settings": "连接设置", + "desktop.remote.hostSection": "主机信息", + "desktop.remote.untested": "测试连接后,这里会显示主机的系统、CPU、内存和磁盘。", + "desktop.remote.via": "经 {jump}", + "desktop.remote.color": "颜色", + "desktop.remote.colorHelp": "在列表中标记这个连接,例如区分生产和测试主机。只保存在本机。", + "desktop.remote.color.none": "无颜色", + "desktop.remote.color.red": "红色", + "desktop.remote.color.orange": "橙色", + "desktop.remote.color.yellow": "黄色", + "desktop.remote.color.green": "绿色", + "desktop.remote.color.blue": "蓝色", + "desktop.remote.color.purple": "紫色", + "desktop.remote.group": "分组", + "desktop.remote.groupHelp": "左侧列表按分组列出连接。只差大小写的分组名视为同一个分组。", + "desktop.remote.group.none": "不分组", + "desktop.remote.group.new": "新建分组…", + "desktop.remote.groupPlaceholder": "分组名称", + "desktop.remote.ungrouped": "未分组", + "desktop.remote.error.groupTooLong": "太长:最多 64 个字符。", + "desktop.remote.error.groupInvalid": "分组名不能包含换行、制表符等控制字符。" } } } diff --git a/shared/platform-feature-matrix/features/remote-connections.json b/shared/platform-feature-matrix/features/remote-connections.json index a90d82aee..5b4338c12 100644 --- a/shared/platform-feature-matrix/features/remote-connections.json +++ b/shared/platform-feature-matrix/features/remote-connections.json @@ -2,7 +2,7 @@ "id": "remote-connections", "area": "工作区", "group": "远程开发", - "capability": "保存 SSH 连接并测试连接,在窗口中回答 SSH 的密码和口令询问", + "capability": "保存 SSH 连接(含颜色和分组)、按分组列出并查看概览,测试连接,在窗口中回答 SSH 的密码和口令询问", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -30,6 +30,6 @@ ] }, "owner": "Remote", - "verification": "从欢迎页的“远程开发”按钮和标题栏项目菜单打开“远程开发”:新建连接只填主机,保存后列表以主机名命名并选中这一行;改名称和端口后保存,列表与偏好目录 remote/connections.json 同步;删除先在底部确认。主机填 user@host、端口填非数字时,错误显示在对应字段下且不写文件。对一台 Linux SSH 主机分别用 SSH Agent、私钥文件和密码测试连接:密码和带口令私钥的询问出现在窗口中,输入以圆点显示,取消或关闭窗口立即停止测试且不再追问;成功后显示系统、架构、CPU、内存和主目录磁盘。首次连接时 OpenSSH 确认主机指纹的询问同样出现在窗口中,由用户回答,Lithe 不替用户接受;拒绝指纹或指纹已改变时测试失败并说明原因。日志只有 remote.connections.open、remote.connection.new/select/save/remove/test/test.stop 和 remote.authentication.answer/cancel 等动作,不含主机、用户名、私钥路径、询问原文或答案。", - "notes": "Viva:连接列表的格式和字段规则在 Core(remote.connections、remote.editConnections),桌面端只读写偏好目录里的 remote/connections.json,按读取时的字节原子写回 Core 返回的文档,文件被改过时不覆盖;测试连接由 Core 运行 PATH 中的 OpenSSH,SSH 询问经 SSH_ASKPASS 指向 lithe 可执行文件的助手模式回到窗口,和 Git 认证共用同一个提问队列。Lithe 只把私钥路径交给 OpenSSH,不读取私钥内容,也不接受粘贴的私钥。macOS 用无头截图和真实 Core 的单元测试覆盖;Windows 上 OpenSSH 调用 GUI 子系统助手读取答案仍待实机验证。打开远程项目、文件夹选择和远端服务部署见 remote-development-workspace,仍未实现。" + "verification": "从欢迎页的“远程开发”按钮和标题栏项目菜单打开“远程开发”:新建连接只填主机,保存后列表以主机名命名并选中这一行,右侧显示概览;点“编辑”进入表单,改名称和端口后保存,回到概览且列表与偏好目录 remote/connections.json 同步;编辑中点“取消”回到原连接、不写文件;删除先在底部确认。选颜色并选“新建分组…”输入分组名后保存,左侧出现带数量的分组标题和颜色条,未分组的连接排在最后的“未分组”下,第二个连接可从下拉框选同一分组(大小写不同视为同一分组)。概览的“连接设置”逐项列出设置,未填的项显示回退规则(例如“自动(SSH 配置,否则 22)”);测试成功后概览的“主机信息”显示本次运行最近一次测试的结果,关闭再打开窗口仍在,未测试的连接显示提示。主机填 user@host、端口填非数字、分组超过 64 个字符时,错误显示在对应字段下且不写文件。对一台 Linux SSH 主机分别用 SSH Agent、私钥文件和密码测试连接:密码和带口令私钥的询问出现在窗口中,输入以圆点显示,取消或关闭窗口立即停止测试且不再追问;成功后显示系统、架构、CPU、内存和主目录磁盘。首次连接时 OpenSSH 确认主机指纹的询问同样出现在窗口中,由用户回答,Lithe 不替用户接受;拒绝指纹或指纹已改变时测试失败并说明原因。日志只有 remote.connections.open、remote.connection.new/select/edit/edit.cancel/save/remove/test/test.stop 和 remote.authentication.answer/cancel 等动作,不含主机、用户名、私钥路径、分组名、询问原文或答案。", + "notes": "Viva:连接列表的格式和字段规则在 Core(remote.connections、remote.editConnections),桌面端只读写偏好目录里的 remote/connections.json,按读取时的字节原子写回 Core 返回的文档,文件被改过时不覆盖;测试连接由 Core 运行 PATH 中的 OpenSSH,SSH 询问经 SSH_ASKPASS 指向 lithe 可执行文件的助手模式回到窗口,和 Git 认证共用同一个提问队列。Lithe 只把私钥路径交给 OpenSSH,不读取私钥内容,也不接受粘贴的私钥。macOS 用无头截图和真实 Core 的单元测试覆盖;Windows 上 OpenSSH 调用 GUI 子系统助手读取答案仍待实机验证。打开远程项目、文件夹选择和远端服务部署见 remote-development-workspace,仍未实现。 2026-11-21(#2231 窗口重设计):颜色(六种固定色或无)和分组随连接保存在 Core 的 connections.json(Lithe-IDEA/Lithe-core-rust#152),分组顺序由 Core 的 sections 给出(按首次使用的顺序,未分组在最后),桌面端只展示;概览的“主机信息”只保存在本次运行的内存里,不写文件。连接、打开文件夹、搜索、从 Motty 或 SSH 配置导入、ssh -G 实际生效值和最近一次测试时间尚未实现。自动化:TestRemoteConnectionsColorAndGroup、TestRemoteCancelGoesBackToTheSavedConnection、TestRemoteOverviewShowsTheTestedHost 与 TestVisualRemoteConnections。" }