Chat: unnamed chats take the harness title, harness default per folder, word-safe tables, Send later
- New chat: a cleared Name creates the chat without an operator title; the list shows the harness's own title, or the default name until it has one. The server no longer records "New chat" for a blank title and OpenCode is created without a title so it names the session itself. - New chat harness defaults to the one last used in the chosen folder, else anywhere, else OpenCode; remembered on the device per server. - Markdown tables wrap at word boundaries and never go below a column's longest word (tokens over ~40 characters may break); a table whose words cannot fit scrolls sideways with the code block affordance. - Composer: right-click, long-press, Shift+F10 or the context menu key on Send opens Send later... (30 min, 1 h, tomorrow 9:00, usage reset, pick a time), sent through the same path with send_at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import 'chat_markdown_speech.dart';
|
||||
import 'chat_message_bubble.dart';
|
||||
import '../../speech/speech.dart';
|
||||
import 'chat_table_cell_measure.dart';
|
||||
import 'chat_table_column_width.dart';
|
||||
import 'chat_table_viewport.dart';
|
||||
|
||||
/// Renders one assistant text part with native text widgets and the host's own
|
||||
/// theme roles. Links (`http`, `https`, `mailto` and `www.` hosts only) open
|
||||
@@ -233,11 +233,12 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
),
|
||||
);
|
||||
case MarkdownTable(header: final header, rows: final rows):
|
||||
// Cells wrap to the transcript width; the table never scrolls sideways.
|
||||
return Table(
|
||||
defaultColumnWidth: ChatTableColumnWidth(header.length),
|
||||
// Cells wrap at word boundaries to the transcript width; a table
|
||||
// whose longest words cannot fit scrolls sideways instead.
|
||||
return ChatTableViewport(
|
||||
columns: header.length,
|
||||
border: TableBorder.all(color: _dividerColor(context)),
|
||||
children: [
|
||||
rows: [
|
||||
TableRow(
|
||||
decoration: BoxDecoration(color: _headerFill(context)),
|
||||
children: [
|
||||
|
||||
@@ -2,18 +2,20 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Sizes a markdown table column to its content but lets it wrap to fit the
|
||||
/// transcript instead of scrolling sideways.
|
||||
/// Sizes a markdown table column to its content, wrapping at word boundaries
|
||||
/// when the table is wider than the transcript.
|
||||
///
|
||||
/// A column asks for its widest line ([IntrinsicColumnWidth]). When the table
|
||||
/// is wider than its container, [Table] shrinks columns towards their minimum,
|
||||
/// which is normally the longest single word. That floor is capped at an equal
|
||||
/// share of the container, so a long identifier or URL breaks inside its cell
|
||||
/// rather than pushing the table past the edge.
|
||||
/// is wider than its container, [Table] shrinks columns towards their minimum:
|
||||
/// the longest single word, so a word never breaks inside itself. Only a
|
||||
/// token wider than [tokenCap] (about forty characters: a URL or a hash) may
|
||||
/// break, down to an equal share of the transcript ([shareCap]), so one cell
|
||||
/// cannot force the whole table to scroll sideways.
|
||||
class ChatTableColumnWidth extends TableColumnWidth {
|
||||
const ChatTableColumnWidth(this.columnCount);
|
||||
const ChatTableColumnWidth({required this.tokenCap, required this.shareCap});
|
||||
|
||||
final int columnCount;
|
||||
final double tokenCap;
|
||||
final double shareCap;
|
||||
|
||||
static const _content = IntrinsicColumnWidth();
|
||||
|
||||
@@ -23,9 +25,9 @@ class ChatTableColumnWidth extends TableColumnWidth {
|
||||
|
||||
@override
|
||||
double minIntrinsicWidth(Iterable<RenderBox> cells, double containerWidth) {
|
||||
final words = _content.minIntrinsicWidth(cells, containerWidth);
|
||||
if (!containerWidth.isFinite || columnCount < 1) return words;
|
||||
return math.min(words, containerWidth / columnCount);
|
||||
final word = _content.minIntrinsicWidth(cells, containerWidth);
|
||||
if (word <= tokenCap) return word;
|
||||
return math.min(tokenCap, shareCap);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'chat_table_column_width.dart';
|
||||
import 'chat_transcript_selection.dart';
|
||||
|
||||
/// About forty characters of body text: the widest a column's minimum may be
|
||||
/// (see ChatTableColumnWidth), in multiples of the font size.
|
||||
const double chatTableTokenCapEms = 22;
|
||||
|
||||
/// A markdown table in the transcript: it fits the transcript's width,
|
||||
/// wrapping its cells at word boundaries, whenever every column's longest
|
||||
/// word fits. Only when they cannot does the table keep those minimums and
|
||||
/// scroll sideways, with the same affordance code blocks use.
|
||||
class ChatTableViewport extends StatelessWidget {
|
||||
const ChatTableViewport({
|
||||
super.key,
|
||||
required this.columns,
|
||||
required this.rows,
|
||||
this.border,
|
||||
});
|
||||
|
||||
final int columns;
|
||||
final List<TableRow> rows;
|
||||
final TableBorder? border;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final em = DefaultTextStyle.of(context).style.fontSize ?? 14;
|
||||
final tokenCap =
|
||||
MediaQuery.textScalerOf(context).scale(em) * chatTableTokenCapEms;
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final share = width.isFinite && columns > 0
|
||||
? width / columns
|
||||
: double.infinity;
|
||||
return ChatTranscriptHorizontalScrollView(
|
||||
label: 'table',
|
||||
child: ChatTableFit(
|
||||
width: width,
|
||||
child: Table(
|
||||
defaultColumnWidth: ChatTableColumnWidth(
|
||||
tokenCap: tokenCap,
|
||||
shareCap: share,
|
||||
),
|
||||
border: border,
|
||||
children: rows,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Lays its child out at [width], or at the child's minimum intrinsic width
|
||||
/// when that is wider, so a table inside a horizontal scroll view wraps to the
|
||||
/// visible width instead of taking its widest line.
|
||||
class ChatTableFit extends SingleChildRenderObjectWidget {
|
||||
const ChatTableFit({super.key, required this.width, required super.child});
|
||||
|
||||
final double width;
|
||||
|
||||
@override
|
||||
RenderChatTableFit createRenderObject(BuildContext context) =>
|
||||
RenderChatTableFit(width);
|
||||
|
||||
@override
|
||||
void updateRenderObject(
|
||||
BuildContext context,
|
||||
RenderChatTableFit renderObject,
|
||||
) => renderObject.width = width;
|
||||
}
|
||||
|
||||
class RenderChatTableFit extends RenderProxyBox {
|
||||
RenderChatTableFit(this._width);
|
||||
|
||||
double _width;
|
||||
set width(double value) {
|
||||
if (value == _width) return;
|
||||
_width = value;
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
@override
|
||||
void performLayout() {
|
||||
final child = this.child;
|
||||
if (child == null) {
|
||||
size = constraints.smallest;
|
||||
return;
|
||||
}
|
||||
var width = _width;
|
||||
if (width.isFinite) {
|
||||
width = math.max(width, child.getMinIntrinsicWidth(double.infinity));
|
||||
}
|
||||
child.layout(
|
||||
BoxConstraints(maxWidth: math.min(width, constraints.maxWidth)),
|
||||
parentUsesSize: true,
|
||||
);
|
||||
size = constraints.constrain(child.size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user