feat: group the server's chats and use OpenChamber's project icons

Sessions under the server's managed chats root (chats/<date>/session-…) were
grouped per directory, so each one appeared as its own session-xxxxx band.
GET /api/fs/home now supplies the chats root plus its canonical and legacy
aliases; every chat folder becomes the single 聊天 group. The new-session
picker can target 聊天 too: the first send creates a fresh chat directory
before creating the session, and a new session started from an existing chat
gets a new one instead of sharing its folder.

Projects merge their OpenChamber settings row (label, icon key, colour,
iconBackground and uploaded/auto icon image) with /api/project. Group
headers, the picker and the draft chip draw the chosen icon in its colour,
and custom images are fetched through the client transport (SVG included)
with a themed fallback to the glyph. The chat group uses a chat bubble rather
than a folder.

0.4.8 (408).
This commit is contained in:
blumia committed 2026-11-23 17:42:49 +08:00
1 parent 91bf5e5b81
commit 79221e57d7
14 files changed
+599 -32

No files matched your search

+30 -9
View File
@@ -10,6 +10,7 @@ import '../widgets/composer_attachment.dart';
import '../widgets/composer_box.dart';
import '../widgets/model_controls.dart';
import '../widgets/pet_sprite.dart';
import '../widgets/project_icon.dart';
import '../widgets/slash_palette.dart';
import 'files_panel.dart';
@@ -280,6 +281,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
Widget _projectChip(SessionDraft draft) {
final theme = Theme.of(context);
final isChat = draft.directory == AppState.chatTarget;
final label = widget.app.projectLabelFor(draft.directory);
return InkWell(
borderRadius: BorderRadius.circular(18),
@@ -289,8 +291,12 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.folder_outlined,
size: 15, color: theme.hintColor),
ProjectIcon(
app: widget.app,
project: isChat ? null : widget.app.projectFor(draft.directory),
chat: isChat,
size: 15,
),
const SizedBox(width: 5),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 170),
@@ -455,7 +461,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
Future<void> _pickProject() async {
final app = widget.app;
await app.refreshProjects();
await Future.wait([app.refreshProjects(), app.refreshFsHome()]);
if (!mounted) return;
final draft = app.draft;
if (draft == null) return;
@@ -479,14 +485,29 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
child: ListView(
controller: controller,
children: [
ListTile(
dense: true,
leading: ProjectIcon(
app: widget.app, chat: true, size: 20),
title: const Text('聊天'),
subtitle: const Text('不关联项目,保存在 OpenChamber 的聊天目录'),
trailing: draft.directory == AppState.chatTarget
? Icon(Icons.check,
size: 18,
color: Theme.of(context).colorScheme.primary)
: null,
onTap: () {
app.updateDraftTarget(AppState.chatTarget);
_slashLoaded = false;
_slashItems = [];
Navigator.pop(context);
},
),
for (final project in projects)
ListTile(
dense: true,
leading: Icon(
project.vcs.isNotEmpty
? Icons.account_tree_outlined
: Icons.folder_outlined,
size: 20),
leading:
ProjectIcon(app: widget.app, project: project, size: 20),
title: Text(project.label,
maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: Text(project.canonical,
@@ -525,7 +546,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
final byPath = <String, ProjectInfo>{};
for (final project in projects) {
if (project.canonical.isEmpty) continue;
if (project.canonical.contains('/.config/openchamber/')) continue;
if (widget.app.isChatDirectory(project.canonical)) continue;
final existing = byPath[project.canonical];
if (existing == null ||
(existing.vcs.isEmpty && project.vcs.isNotEmpty)) {