feat: stats page, and the client becomes Chamber Go

- 全部功能 gains 统计 (Stats): ranges Today/7/30/90 days/all time, a
  project scope (reusing the shared project sheet, plus "All projects"),
  session/prompt/token/cost/active-days/streak tiles, a daily activity
  chart (weekly past 92 days), token composition, efficiency tiles, model
  ranking by tokens/cost/steps and on-request tool-call stats; data comes
  from /api/experimental/session/stats and the day buckets use the device's
  IANA zone (a small platform channel; desktop falls back to UTC)
- the model bars draw a full-width track with a left-aligned fill, so a
  small token share reads as a sliver instead of an empty bar
- AI token strings read 词元 (not 令牌) in Chinese
- the client's display name is Chamber Go (launcher, iOS, Linux window,
  About), package unchanged; pairing/login labels and the user-agent
  follow, so a newly paired device shows "Chamber Go" on the web client's
  "Connect to this server" list
- bump to 0.5.6
This commit is contained in:
blumia committed 2026-11-26 17:18:09 +08:00
1 parent a70e9290ef
commit b65498d73e
19 files changed
+1637 -25

No files matched your search

+44 -8
View File
@@ -8,17 +8,29 @@ import '../l10n.dart';
import '../state.dart';
import 'project_icon.dart';
/// What the picker returns: the Chat row or a project checkout.
/// The "All projects" row of the stats scope picker, where a report is not
/// narrowed to one checkout.
const allProjectsTarget = '\u0000all-projects';
/// What the picker returns: the Chat row, the All projects row, or a checkout.
class ProjectChoice {
/// Null for the Chat row: a chat is not tied to a project.
/// Null for the Chat and All projects rows.
final ProjectInfo? project;
final bool all;
const ProjectChoice.chat() : project = null;
const ProjectChoice.project(this.project);
const ProjectChoice.chat()
: project = null,
all = false;
const ProjectChoice.allProjects()
: project = null,
all = true;
const ProjectChoice.project(this.project) : all = false;
bool get isChat => project == null;
String get canonical => project?.canonical ?? AppState.chatTarget;
String get label => project?.label ?? tr('Chat');
bool get isChat => project == null && !all;
bool get isAll => all;
String get canonical =>
all ? allProjectsTarget : (project?.canonical ?? AppState.chatTarget);
String get label => all ? tr('All projects') : (project?.label ?? tr('Chat'));
}
/// Opens the project sheet and returns the chosen target, or null when the
@@ -28,6 +40,8 @@ Future<ProjectChoice?> showProjectPicker(
BuildContext context, {
required AppState app,
required String selected,
bool includeAll = false,
bool includeChat = true,
}) {
return showModalBottomSheet<ProjectChoice>(
context: context,
@@ -39,6 +53,8 @@ Future<ProjectChoice?> showProjectPicker(
builder: (context, controller) => _ProjectPickerSheet(
app: app,
selected: selected,
includeAll: includeAll,
includeChat: includeChat,
controller: controller,
),
),
@@ -65,11 +81,15 @@ List<ProjectInfo> selectableProjects(AppState app) {
class _ProjectPickerSheet extends StatefulWidget {
final AppState app;
final String selected;
final bool includeAll;
final bool includeChat;
final ScrollController controller;
const _ProjectPickerSheet({
required this.app,
required this.selected,
required this.includeAll,
required this.includeChat,
required this.controller,
});
@@ -131,7 +151,23 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
: ListView(
controller: widget.controller,
children: [
ListTile(
if (widget.includeAll)
ListTile(
dense: true,
leading: Icon(Icons.folder_copy_outlined,
size: 20,
color: Theme.of(context).colorScheme.onSurfaceVariant),
title: const AppText('All projects'),
trailing: widget.selected == allProjectsTarget
? Icon(Icons.check,
size: 18,
color: Theme.of(context).colorScheme.primary)
: null,
onTap: () => Navigator.pop(
context, const ProjectChoice.allProjects()),
),
if (widget.includeChat)
ListTile(
dense: true,
leading:
ProjectIcon(app: widget.app, chat: true, size: 20),