feat: tabs own the panel header, a Termux key bar, and agent memory
- The panel's top row is now the tab group plus the close button; each tab keeps its own header: the files tab has the breadcrumb with new/more (or the name and edit/download while previewing), knowledge its search and refresh, the terminal its status. - The key bar is Termux's two rows of seven: ESC / — HOME ↑ END PGUP, then TAB CTRL ALT ← ↓ → PGDN; the modifiers still apply to what the phone keyboard types. - The panel is a dialog, so it gives the IME's height back itself (viewInsets.bottom). The key bar and the terminal stay above the keyboard, and the PTY reflows to the smaller terminal. - Project knowledge gains the memory tab: both scopes from /api/agent-memory/all, absent when the server has memory switched off, with type, edit and delete. - File preview editing passes minLines: null alongside expands. - 0.3.12 (312).
This commit is contained in:
1 parent
5f95e2da97
commit
5a371e4faf
8 files changed
+675
-231
No files matched your search
@@ -586,6 +586,62 @@ class Client {
|
||||
return ProjectPlanContent.fromJson(r);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------- memory
|
||||
|
||||
/// Both memory scopes at once; null when the server has the feature switched
|
||||
/// off (the route answers 404, which it also uses for a missing entry, but
|
||||
/// this read has no entry id to miss).
|
||||
Future<AgentMemorySnapshot?> agentMemory(String projectId,
|
||||
{String? directory}) async {
|
||||
try {
|
||||
final r = await _json('GET', '/api/agent-memory/all',
|
||||
query: {
|
||||
if (projectId.isNotEmpty) 'projectId': projectId,
|
||||
},
|
||||
directory: directory);
|
||||
return AgentMemorySnapshot.fromJson(r);
|
||||
} on ApiError catch (error) {
|
||||
if (error.status == 404) return null;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateMemory(String memoryId,
|
||||
{required String scope,
|
||||
String? projectId,
|
||||
String? title,
|
||||
String? body,
|
||||
String? type,
|
||||
String? directory}) async {
|
||||
await _json(
|
||||
'PATCH', '/api/agent-memory/${Uri.encodeComponent(memoryId)}',
|
||||
query: {
|
||||
'scope': scope,
|
||||
if (scope == 'project' && projectId != null && projectId.isNotEmpty)
|
||||
'projectId': projectId,
|
||||
},
|
||||
body: {
|
||||
if (title != null) 'title': title,
|
||||
if (body != null) 'body': body,
|
||||
if (type != null) 'type': type,
|
||||
},
|
||||
directory: directory);
|
||||
}
|
||||
|
||||
Future<void> deleteMemory(String memoryId,
|
||||
{required String scope,
|
||||
String? projectId,
|
||||
String? directory}) async {
|
||||
await _json(
|
||||
'DELETE', '/api/agent-memory/${Uri.encodeComponent(memoryId)}',
|
||||
query: {
|
||||
'scope': scope,
|
||||
if (scope == 'project' && projectId != null && projectId.isNotEmpty)
|
||||
'projectId': projectId,
|
||||
},
|
||||
directory: directory);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- terminal
|
||||
|
||||
Future<TerminalSessionInfo> createTerminal(
|
||||
|
||||
@@ -590,6 +590,78 @@ class ProjectContext {
|
||||
bool get isEmpty => notes.isEmpty && todos.isEmpty && plans.isEmpty;
|
||||
}
|
||||
|
||||
/// One remembered fact, preference or reference. The agent writes these
|
||||
/// through its memory tool; the panel reads, corrects and deletes them.
|
||||
class AgentMemoryEntry {
|
||||
final String id;
|
||||
final String title;
|
||||
final String body;
|
||||
final String type; // fact | preference | reference
|
||||
final int createdAt;
|
||||
final int updatedAt;
|
||||
final bool flagged;
|
||||
final String? sessionId;
|
||||
|
||||
const AgentMemoryEntry({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.body,
|
||||
this.type = 'fact',
|
||||
this.createdAt = 0,
|
||||
this.updatedAt = 0,
|
||||
this.flagged = false,
|
||||
this.sessionId,
|
||||
});
|
||||
|
||||
factory AgentMemoryEntry.fromJson(Map<String, dynamic> j) => AgentMemoryEntry(
|
||||
id: j['id'] as String? ?? '',
|
||||
title: j['title'] as String? ?? '',
|
||||
body: j['body'] as String? ?? '',
|
||||
type: j['type'] as String? ?? 'fact',
|
||||
createdAt: (j['createdAt'] as num?)?.toInt() ?? 0,
|
||||
updatedAt: (j['updatedAt'] as num?)?.toInt() ?? 0,
|
||||
flagged: j['flagged'] == true,
|
||||
sessionId: j['sessionId'] as String?,
|
||||
);
|
||||
|
||||
String get typeLabel => switch (type) {
|
||||
'preference' => '偏好',
|
||||
'reference' => '参考',
|
||||
_ => '事实',
|
||||
};
|
||||
}
|
||||
|
||||
/// Both memory scopes in one read, as `/api/agent-memory/all` answers.
|
||||
class AgentMemorySnapshot {
|
||||
final List<AgentMemoryEntry> global;
|
||||
final List<AgentMemoryEntry> project;
|
||||
final bool globalFailed;
|
||||
final bool projectFailed;
|
||||
|
||||
const AgentMemorySnapshot({
|
||||
this.global = const [],
|
||||
this.project = const [],
|
||||
this.globalFailed = false,
|
||||
this.projectFailed = false,
|
||||
});
|
||||
|
||||
factory AgentMemorySnapshot.fromJson(Map<String, dynamic> j) =>
|
||||
AgentMemorySnapshot(
|
||||
global: [
|
||||
for (final m in (j['global'] as List? ?? []))
|
||||
if (m is Map<String, dynamic>) AgentMemoryEntry.fromJson(m),
|
||||
],
|
||||
project: [
|
||||
for (final m in (j['project'] as List? ?? []))
|
||||
if (m is Map<String, dynamic>) AgentMemoryEntry.fromJson(m),
|
||||
],
|
||||
globalFailed: j['globalFailed'] == true,
|
||||
projectFailed: j['projectFailed'] == true,
|
||||
);
|
||||
|
||||
bool get isEmpty => global.isEmpty && project.isEmpty;
|
||||
}
|
||||
|
||||
/// A plan as the server reads it back: the link plus its Markdown.
|
||||
class ProjectPlanContent {
|
||||
final String id;
|
||||
|
||||
Reference in new issue
Block a user