feat: several terminal tabs per project, with a dropdown
A directory now has a TerminalWorkspace holding a list of tabs instead of a
single session. The status bar's left side became a dropdown: it shows the
active tab and its state ("终端 2 · 运行中") and lists the other tabs (the
active one checked) plus "新建终端". New tabs take the smallest free number,
so closing one frees its name.
Only the active tab keeps a socket: switching detaches the old tab and
attaches the new one, whose screen is replayed from the server snapshot; the
shell itself keeps running. The tab's model stays in memory, so switching
back is immediate.
The tab list (ids, labels, active one) is saved per connection and directory.
On the first open the server's sessions for the directory are reconciled with
it: saved labels and order are kept for sessions that still exist, sessions
opened elsewhere (web UI) are appended in creation order, and tabs whose
session is gone are dropped. Project-action command runners are not shown as
tabs. The 0.4.2 single-session value is read as one tab.
0.4.3 (403).
This commit is contained in:
1 parent
675d19d563
commit
a7bc380ac0
9 files changed
+717
-298
No files matched your search
+21
-6
@@ -38,20 +38,35 @@ class ServerTerminal {
|
||||
final String cwd;
|
||||
final String status; // running | exited
|
||||
final int? createdAt;
|
||||
final String mode; // interactive | command
|
||||
final String purpose; // terminal | project-action (or empty)
|
||||
|
||||
const ServerTerminal({
|
||||
required this.sessionId,
|
||||
this.cwd = '',
|
||||
this.status = 'running',
|
||||
this.createdAt,
|
||||
this.mode = 'interactive',
|
||||
this.purpose = '',
|
||||
});
|
||||
|
||||
factory ServerTerminal.fromJson(Map<String, dynamic> j) => ServerTerminal(
|
||||
sessionId: j['sessionId'] as String? ?? '',
|
||||
cwd: j['cwd'] as String? ?? '',
|
||||
status: j['status'] as String? ?? 'running',
|
||||
createdAt: (j['createdAt'] as num?)?.toInt(),
|
||||
);
|
||||
/// A terminal a person opened. A project action's command runner is also a
|
||||
/// PTY, but it is not one of the user's tabs.
|
||||
bool get interactive => mode != 'command' && purpose != 'project-action';
|
||||
|
||||
factory ServerTerminal.fromJson(Map<String, dynamic> j) {
|
||||
final purposeJson = j['purpose'];
|
||||
return ServerTerminal(
|
||||
sessionId: j['sessionId'] as String? ?? '',
|
||||
cwd: j['cwd'] as String? ?? '',
|
||||
status: j['status'] as String? ?? 'running',
|
||||
createdAt: (j['createdAt'] as num?)?.toInt(),
|
||||
mode: j['mode'] as String? ?? 'interactive',
|
||||
purpose: purposeJson is Map
|
||||
? purposeJson['type'] as String? ?? ''
|
||||
: '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// One frame from the server: a snapshot (the authoritative screen), output,
|
||||
|
||||
Reference in new issue
Block a user