feat: a new-session draft and a sidebar grouped by project
- Starting a session opens NewSessionScreen instead of a title sheet: a project chip (GET /api/project, one row per canonical), a model/agent chip, attachments and the composer. Nothing is created on the server until the first send, which posts the session with its directory, model and agent and then sends that message. - The draft lives in AppState (memory only): leaving it keeps it; the sidebar shows a draft row with its first line and a discard button; a failed create stays on the draft with its text. - The session list groups by project (chat folders under 聊天), dates the rows (今天/昨天/本周早些时候/更早), pins through session.metadata.openchamber.pinned, archives on demand, pages with "载入更多", and swipes to pin/archive/delete (flutter_slidable). - Child sessions are hidden; a parent's row shows its children's activity. - The chat app bar follows the live session list, so the title the server generates from the first message appears at once. - Attachments and the model picker move to shared widgets, used by the chat and the draft. - 0.3.13 (313).
This commit is contained in:
1 parent
5a371e4faf
commit
fff6562cbc
14 files changed
+1775
-366
No files matched your search
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import 'chat_screen.dart';
|
||||
import 'new_session_screen.dart';
|
||||
import 'sessions_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@@ -39,6 +40,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
void _maybeOpenFirst() {
|
||||
final app = widget.app;
|
||||
if (!mounted || _opening) return;
|
||||
if (app.draftOpen) return;
|
||||
if (app.chat != null || app.sessions.isEmpty) return;
|
||||
_opening = true;
|
||||
app.openChat(app.sessions.first).whenComplete(() => _opening = false);
|
||||
@@ -56,16 +58,27 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final wide = constraints.maxWidth >= _wideBreakpoint;
|
||||
final chat = widget.app.chat;
|
||||
final chatView = chat == null
|
||||
? _empty(wide)
|
||||
: ChatScreen(
|
||||
key: ValueKey(chat.session.id),
|
||||
app: widget.app,
|
||||
session: chat.session,
|
||||
onOpenSessions: wide ? null : () =>
|
||||
_scaffold.currentState?.openDrawer(),
|
||||
);
|
||||
final app = widget.app;
|
||||
final chat = app.chat;
|
||||
final draftOpen = app.draftOpen && app.draft != null;
|
||||
final content = draftOpen
|
||||
? NewSessionScreen(
|
||||
key: const ValueKey('draft'),
|
||||
app: app,
|
||||
onOpenSessions: wide
|
||||
? null
|
||||
: () => _scaffold.currentState?.openDrawer(),
|
||||
)
|
||||
: chat == null
|
||||
? _empty(wide)
|
||||
: ChatScreen(
|
||||
key: ValueKey(chat.session.id),
|
||||
app: app,
|
||||
session: chat.session,
|
||||
onOpenSessions: wide
|
||||
? null
|
||||
: () => _scaffold.currentState?.openDrawer(),
|
||||
);
|
||||
if (wide) {
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
@@ -75,7 +88,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
child: SessionListPane(app: widget.app),
|
||||
),
|
||||
const VerticalDivider(width: 1),
|
||||
Expanded(child: chatView),
|
||||
Expanded(child: content),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -91,7 +104,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
onOpened: _closeDrawer,
|
||||
),
|
||||
),
|
||||
body: chatView,
|
||||
body: content,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user