Skip to content

Commit 2cf69d4

Browse files
jonasnobileclaude
andcommitted
chore(mobile): regenerate flutter_rust_bridge bindings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 59102b1 commit 2cf69d4

File tree

5 files changed

+434
-804
lines changed

5 files changed

+434
-804
lines changed

mobile/lib/src/rust/api/state.dart

Lines changed: 101 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import '../frb_generated.dart';
77
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
88

9-
// These functions are ignored because they are not marked as `pub`: `collect_layout_ids_vec`
10-
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `fmt`
9+
// These functions are ignored because they are not marked as `pub`: `collect_layout_ids`, `find_terminal_size`, `folder_color_to_string`
10+
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`
1111

1212
/// Get all projects from the cached remote state.
1313
List<ProjectInfo> getProjects({required String connId}) =>
@@ -17,6 +17,14 @@ List<ProjectInfo> getProjects({required String connId}) =>
1717
String? getFocusedProjectId({required String connId}) =>
1818
RustLib.instance.api.crateApiStateGetFocusedProjectId(connId: connId);
1919

20+
/// Get all folders from the cached remote state.
21+
List<FolderInfo> getFolders({required String connId}) =>
22+
RustLib.instance.api.crateApiStateGetFolders(connId: connId);
23+
24+
/// Get the project order from the cached remote state.
25+
List<String> getProjectOrder({required String connId}) =>
26+
RustLib.instance.api.crateApiStateGetProjectOrder(connId: connId);
27+
2028
/// Check if a terminal has unprocessed output (dirty flag).
2129
bool isDirty({required String connId, required String terminalId}) => RustLib
2230
.instance
@@ -36,11 +44,33 @@ Future<void> sendSpecialKey({
3644
key: key,
3745
);
3846

47+
/// Get a project's layout tree as JSON.
48+
///
49+
/// Returns the `ApiLayoutNode` serialized as JSON, or `None` if the project
50+
/// has no layout. Using JSON avoids complex recursive enum FRB codegen.
51+
String? getProjectLayoutJson({
52+
required String connId,
53+
required String projectId,
54+
}) => RustLib.instance.api.crateApiStateGetProjectLayoutJson(
55+
connId: connId,
56+
projectId: projectId,
57+
);
58+
3959
/// Get all terminal IDs from the cached remote state (flat list).
4060
List<String> getAllTerminalIds({required String connId}) =>
4161
RustLib.instance.api.crateApiStateGetAllTerminalIds(connId: connId);
4262

43-
/// Create a new terminal in the given project via POST /v1/actions.
63+
/// Get the server-side terminal size from the cached state.
64+
/// Returns (0, 0) if the terminal is not found or size is not available.
65+
ServerTerminalSize getServerTerminalSize({
66+
required String connId,
67+
required String terminalId,
68+
}) => RustLib.instance.api.crateApiStateGetServerTerminalSize(
69+
connId: connId,
70+
terminalId: terminalId,
71+
);
72+
73+
/// Create a new terminal in a project.
4474
Future<void> createTerminal({
4575
required String connId,
4676
required String projectId,
@@ -49,7 +79,7 @@ Future<void> createTerminal({
4979
projectId: projectId,
5080
);
5181

52-
/// Close a terminal in the given project via POST /v1/actions.
82+
/// Close a terminal in a project.
5383
Future<void> closeTerminal({
5484
required String connId,
5585
required String projectId,
@@ -60,32 +90,72 @@ Future<void> closeTerminal({
6090
terminalId: terminalId,
6191
);
6292

93+
/// Focus a terminal in a project.
94+
Future<void> focusTerminal({
95+
required String connId,
96+
required String projectId,
97+
required String terminalId,
98+
}) => RustLib.instance.api.crateApiStateFocusTerminal(
99+
connId: connId,
100+
projectId: projectId,
101+
terminalId: terminalId,
102+
);
103+
104+
/// FFI-friendly folder info.
105+
class FolderInfo {
106+
final String id;
107+
final String name;
108+
final List<String> projectIds;
109+
final String folderColor;
110+
111+
const FolderInfo({
112+
required this.id,
113+
required this.name,
114+
required this.projectIds,
115+
required this.folderColor,
116+
});
117+
118+
@override
119+
int get hashCode =>
120+
id.hashCode ^ name.hashCode ^ projectIds.hashCode ^ folderColor.hashCode;
121+
122+
@override
123+
bool operator ==(Object other) =>
124+
identical(this, other) ||
125+
other is FolderInfo &&
126+
runtimeType == other.runtimeType &&
127+
id == other.id &&
128+
name == other.name &&
129+
projectIds == other.projectIds &&
130+
folderColor == other.folderColor;
131+
}
132+
63133
/// Flat FFI-friendly project info.
64134
class ProjectInfo {
65135
final String id;
66136
final String name;
67137
final String path;
68-
final bool showInOverview;
138+
final bool isVisible;
69139
final List<String> terminalIds;
70-
final Map<String, String> terminalNames;
140+
final String folderColor;
71141

72142
const ProjectInfo({
73143
required this.id,
74144
required this.name,
75145
required this.path,
76-
required this.showInOverview,
146+
required this.isVisible,
77147
required this.terminalIds,
78-
required this.terminalNames,
148+
required this.folderColor,
79149
});
80150

81151
@override
82152
int get hashCode =>
83153
id.hashCode ^
84154
name.hashCode ^
85155
path.hashCode ^
86-
showInOverview.hashCode ^
156+
isVisible.hashCode ^
87157
terminalIds.hashCode ^
88-
terminalNames.hashCode;
158+
folderColor.hashCode;
89159

90160
@override
91161
bool operator ==(Object other) =>
@@ -95,7 +165,26 @@ class ProjectInfo {
95165
id == other.id &&
96166
name == other.name &&
97167
path == other.path &&
98-
showInOverview == other.showInOverview &&
168+
isVisible == other.isVisible &&
99169
terminalIds == other.terminalIds &&
100-
terminalNames == other.terminalNames;
170+
folderColor == other.folderColor;
171+
}
172+
173+
/// Server terminal size returned via FFI.
174+
class ServerTerminalSize {
175+
final int cols;
176+
final int rows;
177+
178+
const ServerTerminalSize({required this.cols, required this.rows});
179+
180+
@override
181+
int get hashCode => cols.hashCode ^ rows.hashCode;
182+
183+
@override
184+
bool operator ==(Object other) =>
185+
identical(this, other) ||
186+
other is ServerTerminalSize &&
187+
runtimeType == other.runtimeType &&
188+
cols == other.cols &&
189+
rows == other.rows;
101190
}

mobile/lib/src/rust/api/terminal.dart

Lines changed: 23 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import '../frb_generated.dart';
77
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
88

9-
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`
9+
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`
1010

1111
/// Get the visible terminal cells for rendering.
1212
List<CellData> getVisibleCells({
@@ -24,88 +24,24 @@ CursorState getCursor({required String connId, required String terminalId}) =>
2424
terminalId: terminalId,
2525
);
2626

27-
/// Scroll the terminal display (positive = up, negative = down).
28-
void scroll({
27+
/// Scroll the terminal display by delta lines (positive = up into history, negative = down).
28+
void scrollTerminal({
2929
required String connId,
3030
required String terminalId,
3131
required int delta,
32-
}) => RustLib.instance.api.crateApiTerminalScroll(
32+
}) => RustLib.instance.api.crateApiTerminalScrollTerminal(
3333
connId: connId,
3434
terminalId: terminalId,
3535
delta: delta,
3636
);
3737

38-
/// Get scroll info: total lines, visible lines, display offset.
39-
ScrollInfo getScrollInfo({
40-
required String connId,
41-
required String terminalId,
42-
}) => RustLib.instance.api.crateApiTerminalGetScrollInfo(
43-
connId: connId,
44-
terminalId: terminalId,
45-
);
46-
47-
/// Start a character-level selection at col/row.
48-
void startSelection({
49-
required String connId,
50-
required String terminalId,
51-
required int col,
52-
required int row,
53-
}) => RustLib.instance.api.crateApiTerminalStartSelection(
54-
connId: connId,
55-
terminalId: terminalId,
56-
col: col,
57-
row: row,
58-
);
59-
60-
/// Start a word (semantic) selection at col/row.
61-
void startWordSelection({
62-
required String connId,
63-
required String terminalId,
64-
required int col,
65-
required int row,
66-
}) => RustLib.instance.api.crateApiTerminalStartWordSelection(
67-
connId: connId,
68-
terminalId: terminalId,
69-
col: col,
70-
row: row,
71-
);
72-
73-
/// Extend the current selection to col/row.
74-
void updateSelection({
75-
required String connId,
76-
required String terminalId,
77-
required int col,
78-
required int row,
79-
}) => RustLib.instance.api.crateApiTerminalUpdateSelection(
80-
connId: connId,
81-
terminalId: terminalId,
82-
col: col,
83-
row: row,
84-
);
85-
86-
/// Clear the current selection.
87-
void clearSelection({required String connId, required String terminalId}) =>
88-
RustLib.instance.api.crateApiTerminalClearSelection(
38+
/// Get the current scroll display offset (0 = at bottom).
39+
int getDisplayOffset({required String connId, required String terminalId}) =>
40+
RustLib.instance.api.crateApiTerminalGetDisplayOffset(
8941
connId: connId,
9042
terminalId: terminalId,
9143
);
9244

93-
/// Get the selected text, if any.
94-
String? getSelectedText({required String connId, required String terminalId}) =>
95-
RustLib.instance.api.crateApiTerminalGetSelectedText(
96-
connId: connId,
97-
terminalId: terminalId,
98-
);
99-
100-
/// Get selection bounds for rendering.
101-
SelectionBounds? getSelectionBounds({
102-
required String connId,
103-
required String terminalId,
104-
}) => RustLib.instance.api.crateApiTerminalGetSelectionBounds(
105-
connId: connId,
106-
terminalId: terminalId,
107-
);
108-
10945
/// Send text input to a terminal.
11046
Future<void> sendText({
11147
required String connId,
@@ -117,8 +53,8 @@ Future<void> sendText({
11753
text: text,
11854
);
11955

120-
/// Resize a terminal.
121-
void resizeTerminal({
56+
/// Resize a terminal (local + send WS message to server).
57+
Future<void> resizeTerminal({
12258
required String connId,
12359
required String terminalId,
12460
required int cols,
@@ -130,6 +66,20 @@ void resizeTerminal({
13066
rows: rows,
13167
);
13268

69+
/// Resize only the local alacritty terminal — does NOT send a WS resize message to the server.
70+
/// Used when mobile adapts to the server's terminal size.
71+
void resizeLocal({
72+
required String connId,
73+
required String terminalId,
74+
required int cols,
75+
required int rows,
76+
}) => RustLib.instance.api.crateApiTerminalResizeLocal(
77+
connId: connId,
78+
terminalId: terminalId,
79+
cols: cols,
80+
rows: rows,
81+
);
82+
13383
/// Cell data for FFI transfer (flat, no pointers).
13484
class CellData {
13585
/// The character in this cell.
@@ -197,58 +147,3 @@ class CursorState {
197147
shape == other.shape &&
198148
visible == other.visible;
199149
}
200-
201-
/// Scroll info for FFI transfer.
202-
class ScrollInfo {
203-
final int totalLines;
204-
final int visibleLines;
205-
final int displayOffset;
206-
207-
const ScrollInfo({
208-
required this.totalLines,
209-
required this.visibleLines,
210-
required this.displayOffset,
211-
});
212-
213-
@override
214-
int get hashCode =>
215-
totalLines.hashCode ^ visibleLines.hashCode ^ displayOffset.hashCode;
216-
217-
@override
218-
bool operator ==(Object other) =>
219-
identical(this, other) ||
220-
other is ScrollInfo &&
221-
runtimeType == other.runtimeType &&
222-
totalLines == other.totalLines &&
223-
visibleLines == other.visibleLines &&
224-
displayOffset == other.displayOffset;
225-
}
226-
227-
/// Selection bounds for FFI transfer.
228-
class SelectionBounds {
229-
final int startCol;
230-
final int startRow;
231-
final int endCol;
232-
final int endRow;
233-
234-
const SelectionBounds({
235-
required this.startCol,
236-
required this.startRow,
237-
required this.endCol,
238-
required this.endRow,
239-
});
240-
241-
@override
242-
int get hashCode =>
243-
startCol.hashCode ^ startRow.hashCode ^ endCol.hashCode ^ endRow.hashCode;
244-
245-
@override
246-
bool operator ==(Object other) =>
247-
identical(this, other) ||
248-
other is SelectionBounds &&
249-
runtimeType == other.runtimeType &&
250-
startCol == other.startCol &&
251-
startRow == other.startRow &&
252-
endCol == other.endCol &&
253-
endRow == other.endRow;
254-
}

0 commit comments

Comments
 (0)