feat: the terminal, project knowledge, and downloads that can be cancelled
- lib/api/terminal.dart: the PTY protocol (create/resize/restart/close, and the /api/terminal/ws binary control frames) with a reconnecting socket that replays the server snapshot at the size it was drawn for. - lib/terminal_state.dart: an xterm model plus that socket, kept per workspace on AppState, so closing the panel or switching tabs keeps the shell; the app reattaches when it returns from the background. - lib/screens/terminal_panel.dart: TerminalView, a status bar (keyboard, restart, clear, close) and a Termux-style key bar whose CTRL/ALT/SHIFT modifiers also apply to what the phone keyboard types. - lib/screens/knowledge_panel.dart: notes, todos and plans from /api/project-context, searchable, with a full page for a plan's Markdown and its raw editor. - Downloads stream with a progress dialog (bytes, total, percent) and a cancel that aborts the request; the save dialog only opens on success. The request asks for `accept-encoding: identity` so Content-Length exists. - MarkdownView renders task lists as ✅/⬜ instead of material_ui's Checkbox, which wants a material_ui Material ancestor the app lacks. - Dialogs own their TextEditingControllers, so closing one no longer trips a framework assertion in debug builds. - 0.3.11 (311).
This commit is contained in:
1 parent
60d02083d3
commit
5f95e2da97
14 files changed
+2347
-57
No files matched your search
@@ -440,6 +440,185 @@ class FormInfo {
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- project knowledge
|
||||
|
||||
/// A saved note, as `/api/project-context` stores it.
|
||||
class ProjectNote {
|
||||
final String id;
|
||||
final String body;
|
||||
final int createdAt;
|
||||
final int updatedAt;
|
||||
final String source; // manual | selection | agent
|
||||
final bool pinned;
|
||||
final String? planId;
|
||||
|
||||
const ProjectNote({
|
||||
required this.id,
|
||||
required this.body,
|
||||
this.createdAt = 0,
|
||||
this.updatedAt = 0,
|
||||
this.source = 'manual',
|
||||
this.pinned = false,
|
||||
this.planId,
|
||||
});
|
||||
|
||||
factory ProjectNote.fromJson(Map<String, dynamic> j) => ProjectNote(
|
||||
id: j['id'] as String? ?? '',
|
||||
body: j['body'] as String? ?? '',
|
||||
createdAt: (j['createdAt'] as num?)?.toInt() ?? 0,
|
||||
updatedAt: (j['updatedAt'] as num?)?.toInt() ?? 0,
|
||||
source: j['source'] as String? ?? 'manual',
|
||||
pinned: j['pinned'] as bool? ?? false,
|
||||
planId: j['planId'] as String?,
|
||||
);
|
||||
|
||||
String get firstLine {
|
||||
final line = body.split('\n').firstWhere((l) => l.trim().isNotEmpty,
|
||||
orElse: () => '');
|
||||
return line.trim();
|
||||
}
|
||||
}
|
||||
|
||||
/// A todo item. [planId] links it to a plan; [dependsOn] lists the todos of
|
||||
/// the same plan that must be completed first.
|
||||
class ProjectTodo {
|
||||
final String id;
|
||||
final String text;
|
||||
final bool completed;
|
||||
final int createdAt;
|
||||
final String? planId;
|
||||
final List<String> dependsOn;
|
||||
|
||||
const ProjectTodo({
|
||||
required this.id,
|
||||
required this.text,
|
||||
this.completed = false,
|
||||
this.createdAt = 0,
|
||||
this.planId,
|
||||
this.dependsOn = const [],
|
||||
});
|
||||
|
||||
factory ProjectTodo.fromJson(Map<String, dynamic> j) => ProjectTodo(
|
||||
id: j['id'] as String? ?? '',
|
||||
text: j['text'] as String? ?? '',
|
||||
completed: j['completed'] as bool? ?? false,
|
||||
createdAt: (j['createdAt'] as num?)?.toInt() ?? 0,
|
||||
planId: j['planId'] as String?,
|
||||
dependsOn: [
|
||||
for (final d in (j['dependsOn'] as List? ?? []))
|
||||
if (d is String) d,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A plan the project lists: a manifest entry (personal) or a file from the
|
||||
/// team's shared folder.
|
||||
class ProjectPlanLink {
|
||||
final String id;
|
||||
final String file;
|
||||
final String title;
|
||||
final int createdAt;
|
||||
final bool pinned;
|
||||
final String source; // personal | shared
|
||||
final int progressDone;
|
||||
final int progressTotal;
|
||||
final String? sessionId;
|
||||
|
||||
const ProjectPlanLink({
|
||||
required this.id,
|
||||
required this.file,
|
||||
required this.title,
|
||||
this.createdAt = 0,
|
||||
this.pinned = false,
|
||||
this.source = 'personal',
|
||||
this.progressDone = 0,
|
||||
this.progressTotal = 0,
|
||||
this.sessionId,
|
||||
});
|
||||
|
||||
factory ProjectPlanLink.fromJson(Map<String, dynamic> j) {
|
||||
final progress = j['progress'];
|
||||
final session = j['session'];
|
||||
return ProjectPlanLink(
|
||||
id: j['id'] as String? ?? '',
|
||||
file: j['file'] as String? ?? '',
|
||||
title: j['title'] as String? ?? '',
|
||||
createdAt: (j['createdAt'] as num?)?.toInt() ?? 0,
|
||||
pinned: j['pinned'] as bool? ?? false,
|
||||
source: j['source'] as String? ?? 'personal',
|
||||
progressDone:
|
||||
progress is Map ? (progress['done'] as num?)?.toInt() ?? 0 : 0,
|
||||
progressTotal:
|
||||
progress is Map ? (progress['total'] as num?)?.toInt() ?? 0 : 0,
|
||||
sessionId: session is Map ? session['sessionId'] as String? : null,
|
||||
);
|
||||
}
|
||||
|
||||
bool get hasProgress => progressTotal > 0;
|
||||
}
|
||||
|
||||
/// Everything the project knowledge panel shows for one directory.
|
||||
class ProjectContext {
|
||||
final List<ProjectNote> notes;
|
||||
final List<ProjectTodo> todos;
|
||||
final List<ProjectPlanLink> plans;
|
||||
final String? sharedPlansDir;
|
||||
|
||||
const ProjectContext({
|
||||
this.notes = const [],
|
||||
this.todos = const [],
|
||||
this.plans = const [],
|
||||
this.sharedPlansDir,
|
||||
});
|
||||
|
||||
factory ProjectContext.fromJson(Map<String, dynamic> j) => ProjectContext(
|
||||
notes: [
|
||||
for (final n in (j['notes'] as List? ?? []))
|
||||
if (n is Map<String, dynamic>) ProjectNote.fromJson(n),
|
||||
],
|
||||
todos: [
|
||||
for (final t in (j['todos'] as List? ?? []))
|
||||
if (t is Map<String, dynamic>) ProjectTodo.fromJson(t),
|
||||
],
|
||||
plans: [
|
||||
for (final p in (j['plans'] as List? ?? []))
|
||||
if (p is Map<String, dynamic>) ProjectPlanLink.fromJson(p),
|
||||
],
|
||||
sharedPlansDir: j['sharedPlansDir'] as String?,
|
||||
);
|
||||
|
||||
bool get isEmpty => notes.isEmpty && todos.isEmpty && plans.isEmpty;
|
||||
}
|
||||
|
||||
/// A plan as the server reads it back: the link plus its Markdown.
|
||||
class ProjectPlanContent {
|
||||
final String id;
|
||||
final String title;
|
||||
final String body;
|
||||
final String raw;
|
||||
final String? path;
|
||||
final String source;
|
||||
|
||||
const ProjectPlanContent({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.body,
|
||||
this.raw = '',
|
||||
this.path,
|
||||
this.source = 'personal',
|
||||
});
|
||||
|
||||
factory ProjectPlanContent.fromJson(Map<String, dynamic> j) =>
|
||||
ProjectPlanContent(
|
||||
id: j['id'] as String? ?? '',
|
||||
title: j['title'] as String? ?? '',
|
||||
body: j['body'] as String? ?? '',
|
||||
raw: j['raw'] as String? ?? '',
|
||||
path: j['path'] as String?,
|
||||
source: j['source'] as String? ?? 'personal',
|
||||
);
|
||||
}
|
||||
|
||||
class Page<T> {
|
||||
final List<T> data;
|
||||
final String? next;
|
||||
|
||||
Reference in new issue
Block a user