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:
1 parent
91bf5e5b81
commit
79221e57d7
14 files changed
+599
-32
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:openchamber/api/models.dart';
|
||||
import 'package:openchamber/widgets/project_icon.dart';
|
||||
|
||||
void main() {
|
||||
test('OpenChamber icon keys map to Flutter icons', () {
|
||||
expect(projectIconData('code'), Icons.code);
|
||||
expect(projectIconData('terminal'), Icons.terminal);
|
||||
expect(projectIconData('ai'), Icons.psychology_outlined);
|
||||
expect(projectIconData('unknown'), isNull);
|
||||
expect(projectIconData(''), isNull);
|
||||
});
|
||||
|
||||
test('hex and legacy project colours resolve', () {
|
||||
final scheme = ColorScheme.fromSeed(seedColor: Colors.indigo);
|
||||
expect(projectHexColor('#30a46c'), const Color(0xff30a46c));
|
||||
expect(projectHexColor('#abc'), const Color(0xffaabbcc));
|
||||
expect(projectHexColor('30a46c'), isNull);
|
||||
expect(projectColor('error', scheme), scheme.error);
|
||||
expect(projectColor('primary', scheme), scheme.primary);
|
||||
expect(projectColor('comment', scheme), scheme.onSurfaceVariant);
|
||||
expect(projectColor('#30a46c', scheme), const Color(0xff30a46c));
|
||||
expect(projectColor('', scheme), isNull);
|
||||
});
|
||||
|
||||
test('a settings row decorates the project with label and icon metadata', () {
|
||||
const project = ProjectInfo(id: 'p1', canonical: '/w/app');
|
||||
final merged = project.withMeta({
|
||||
'id': 'path_L3cL2FwcA',
|
||||
'path': '/w/app',
|
||||
'label': 'My App',
|
||||
'icon': 'rocket',
|
||||
'color': '#30a46c',
|
||||
'iconBackground': '#101010',
|
||||
'iconImage': {'mime': 'image/svg+xml', 'updatedAt': 42},
|
||||
});
|
||||
expect(merged.label, 'My App');
|
||||
expect(merged.icon, 'rocket');
|
||||
expect(merged.color, '#30a46c');
|
||||
expect(merged.metaId, 'path_L3cL2FwcA');
|
||||
expect(merged.hasIconImage, isTrue);
|
||||
expect(merged.iconImageMime, 'image/svg+xml');
|
||||
expect(merged.iconImageUpdatedAt, 42);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user