Skip to content

Commit 7c9ad4e

Browse files
committed
style: dart format + whitespace normalization (pre-push hook)
1 parent 1f10f29 commit 7c9ad4e

9 files changed

Lines changed: 105 additions & 113 deletions

app/lib/main.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ Future<void> main() async {
5757
input: input,
5858
);
5959
if (body == null) return;
60-
container
61-
.read(connectionControllerProvider.notifier)
62-
.respondTo(rid, body);
60+
container.read(connectionControllerProvider.notifier).respondTo(rid, body);
6361
};
6462
container.read(notificationControllerProvider);
6563

app/lib/notifications/notification_request.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ String encodeRequestPayload({
125125
required String sessionId,
126126
required String requestId,
127127
required String kind,
128-
}) =>
129-
jsonEncode({'sid': sessionId, 'rid': requestId, 'kind': kind});
128+
}) => jsonEncode({'sid': sessionId, 'rid': requestId, 'kind': kind});
130129

131130
/// Decode a notification payload. Handles three cases:
132131
/// - JSON object → structured [NotificationPayload]

app/lib/transport/ws_client.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,7 @@ class WsClient implements Transport {
147147
cancelOnError: true,
148148
);
149149

150-
_send(
151-
Envelope(
152-
t: MsgType.hello,
153-
id: Ulid().toString(),
154-
body: _helloBody,
155-
),
156-
);
150+
_send(Envelope(t: MsgType.hello, id: Ulid().toString(), body: _helloBody));
157151

158152
_attempt = 0;
159153
_setState(WsState.connected);

app/lib/ui/widgets/srv_request_handler.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class _SrvRequestHandlerState extends ConsumerState<SrvRequestHandler>
142142
Future<void> _presentDialog(Envelope env) async {
143143
final kind = env.body['kind'] as String? ?? 'unknown';
144144

145-
146145
// Use the router's Navigator, not this widget's context — we're above it.
147146
final navCtx = pinoNavigatorKey.currentContext;
148147
if (navCtx == null) return;

app/test/notification_request_test.dart

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,39 @@ void main() {
1717
expect(n.body, contains('rm -rf build/'));
1818
});
1919

20-
test('askUserQuestion (single form) → question category + first question',
21-
() {
22-
final n = notificationForRequest(
23-
kind: 'askUserQuestion',
24-
body: {'kind': 'askUserQuestion', 'question': 'Deploy to prod?'},
25-
label: label,
26-
);
27-
expect(n, isNotNull);
28-
expect(n!.category, kQuestionCategoryId);
29-
expect(n.body, contains('Deploy to prod?'));
30-
});
31-
32-
test('askUserQuestion (wizard form) → question category + first question',
33-
() {
34-
final n = notificationForRequest(
35-
kind: 'askUserQuestion',
36-
body: {
37-
'kind': 'askUserQuestion',
38-
'questions': [
39-
{'question': 'Pick a branch'},
40-
{'question': 'ignored second'},
41-
],
42-
},
43-
label: label,
44-
);
45-
expect(n, isNotNull);
46-
expect(n!.category, kQuestionCategoryId);
47-
expect(n.body, contains('Pick a branch'));
48-
});
20+
test(
21+
'askUserQuestion (single form) → question category + first question',
22+
() {
23+
final n = notificationForRequest(
24+
kind: 'askUserQuestion',
25+
body: {'kind': 'askUserQuestion', 'question': 'Deploy to prod?'},
26+
label: label,
27+
);
28+
expect(n, isNotNull);
29+
expect(n!.category, kQuestionCategoryId);
30+
expect(n.body, contains('Deploy to prod?'));
31+
},
32+
);
33+
34+
test(
35+
'askUserQuestion (wizard form) → question category + first question',
36+
() {
37+
final n = notificationForRequest(
38+
kind: 'askUserQuestion',
39+
body: {
40+
'kind': 'askUserQuestion',
41+
'questions': [
42+
{'question': 'Pick a branch'},
43+
{'question': 'ignored second'},
44+
],
45+
},
46+
label: label,
47+
);
48+
expect(n, isNotNull);
49+
expect(n!.category, kQuestionCategoryId);
50+
expect(n.body, contains('Pick a branch'));
51+
},
52+
);
4953

5054
test('input kind → null', () {
5155
final n = notificationForRequest(
@@ -157,10 +161,7 @@ void main() {
157161

158162
test('approve/deny require confirmAction kind → mismatch is null', () {
159163
expect(
160-
responseForAction(
161-
kind: 'askUserQuestion',
162-
actionId: kApproveActionId,
163-
),
164+
responseForAction(kind: 'askUserQuestion', actionId: kApproveActionId),
164165
isNull,
165166
);
166167
expect(

app/test/notification_service_test.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@ void main() {
2121
expect(decoded['actionId'], 'pino_approve');
2222
});
2323

24-
test('caps the queue to the most recent kMaxPendingActions entries',
25-
() async {
26-
for (var i = 0; i < kMaxPendingActions + 20; i++) {
27-
await persistPendingActionForTest('p$i', 'pino_approve', null);
28-
}
24+
test(
25+
'caps the queue to the most recent kMaxPendingActions entries',
26+
() async {
27+
for (var i = 0; i < kMaxPendingActions + 20; i++) {
28+
await persistPendingActionForTest('p$i', 'pino_approve', null);
29+
}
2930

30-
final prefs = await SharedPreferences.getInstance();
31-
final queue = prefs.getStringList(kPendingActionsKey)!;
32-
expect(queue, hasLength(kMaxPendingActions));
33-
// Oldest entries dropped; newest retained.
34-
final first = jsonDecode(queue.first) as Map<String, dynamic>;
35-
final last = jsonDecode(queue.last) as Map<String, dynamic>;
36-
expect(first['payload'], 'p20');
37-
expect(last['payload'], 'p${kMaxPendingActions + 19}');
38-
});
31+
final prefs = await SharedPreferences.getInstance();
32+
final queue = prefs.getStringList(kPendingActionsKey)!;
33+
expect(queue, hasLength(kMaxPendingActions));
34+
// Oldest entries dropped; newest retained.
35+
final first = jsonDecode(queue.first) as Map<String, dynamic>;
36+
final last = jsonDecode(queue.last) as Map<String, dynamic>;
37+
expect(first['payload'], 'p20');
38+
expect(last['payload'], 'p${kMaxPendingActions + 19}');
39+
},
40+
);
3941
});
4042
}

app/test/srv_request_handler_notify_test.dart

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ _FakeSecureStorage _seeded() => _FakeSecureStorage({
123123

124124
void main() {
125125
Future<
126-
(
127-
_EmittingTransport,
128-
_RecordingNotificationService,
129-
ConnectionController,
130-
)
126+
(_EmittingTransport, _RecordingNotificationService, ConnectionController)
131127
>
132128
pumpHandler(
133129
WidgetTester tester, {
@@ -138,8 +134,8 @@ void main() {
138134
final controller = ConnectionController(
139135
_seeded(),
140136
transportFactory: () => transport,
141-
browseLan:
142-
({Duration timeout = const Duration(seconds: 3)}) async => const [],
137+
browseLan: ({Duration timeout = const Duration(seconds: 3)}) async =>
138+
const [],
143139
rediscoverStall: Duration.zero,
144140
);
145141

@@ -290,40 +286,39 @@ void main() {
290286
},
291287
);
292288

293-
testWidgets(
294-
'backgrounded confirmAction is replayed as a dialog on resume',
295-
(tester) async {
296-
final (transport, notifications, _) = await pumpHandler(tester);
297-
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.paused);
298-
await tester.pump();
289+
testWidgets('backgrounded confirmAction is replayed as a dialog on resume', (
290+
tester,
291+
) async {
292+
final (transport, notifications, _) = await pumpHandler(tester);
293+
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.paused);
294+
await tester.pump();
299295

300-
transport.emit(
301-
Envelope(
302-
t: MsgType.srvRequest,
303-
id: 'req-replay',
304-
body: {
305-
'kind': 'confirmAction',
306-
'action': 'rm -rf build/',
307-
'sessionId': 's1',
308-
},
309-
),
310-
);
311-
await tester.pump();
312-
await tester.pump();
296+
transport.emit(
297+
Envelope(
298+
t: MsgType.srvRequest,
299+
id: 'req-replay',
300+
body: {
301+
'kind': 'confirmAction',
302+
'action': 'rm -rf build/',
303+
'sessionId': 's1',
304+
},
305+
),
306+
);
307+
await tester.pump();
308+
await tester.pump();
313309

314-
// Notification shown, dialog withheld while backgrounded.
315-
expect(notifications.shown, hasLength(1));
316-
expect(find.text('Approve'), findsNothing);
310+
// Notification shown, dialog withheld while backgrounded.
311+
expect(notifications.shown, hasLength(1));
312+
expect(find.text('Approve'), findsNothing);
317313

318-
// Resume and pump past the drain delay → dialog now presented.
319-
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
320-
await tester.pump();
321-
await tester.pump(const Duration(milliseconds: 500));
322-
await tester.pump();
314+
// Resume and pump past the drain delay → dialog now presented.
315+
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
316+
await tester.pump();
317+
await tester.pump(const Duration(milliseconds: 500));
318+
await tester.pump();
323319

324-
expect(find.text('Approve'), findsOneWidget);
325-
},
326-
);
320+
expect(find.text('Approve'), findsOneWidget);
321+
});
327322

328323
testWidgets(
329324
'answered-from-notification request is not double-prompted on resume',

app/test/store_reducer_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ void main() {
187187
}),
188188
}),
189189
transportFactory: () => transport,
190-
browseLan: ({Duration timeout = const Duration(seconds: 3)}) async => const [],
190+
browseLan:
191+
({Duration timeout = const Duration(seconds: 3)}) async =>
192+
const [],
191193
rediscoverStall: const Duration(seconds: 30),
192194
),
193195
),
@@ -226,7 +228,9 @@ void main() {
226228
}),
227229
}),
228230
transportFactory: () => transport,
229-
browseLan: ({Duration timeout = const Duration(seconds: 3)}) async => const [],
231+
browseLan:
232+
({Duration timeout = const Duration(seconds: 3)}) async =>
233+
const [],
230234
rediscoverStall: const Duration(seconds: 30),
231235
),
232236
),

docs/ARCHITECT-SLICE-1.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@
4747
test("pi adapter's askUser callback sends srv.request", async () => {
4848
const sent: OutgoingFrame[] = [];
4949
const rpc = new ReverseRpc({ send: (f) => sent.push(f) });
50-
50+
5151
const adapter = new PiAdapter();
52-
52+
5353
// Inject askUser callback that feeds to rpc
5454
await adapter.start({
5555
cwd: "/tmp",
5656
sessionId: "sess-1",
5757
askUser: (req) => rpc.askDevice(req, "sess-1"),
5858
});
59-
59+
6060
// Fake pi emitting a ui.select
6161
adapter.emit("event", {
6262
kind: "agent.message",
6363
payload: { text: "... choices: [a, b]" },
6464
});
6565
// TODO: simulate the actual pi ui.select RPC that triggers askUser
66-
66+
6767
const req = sent.find((f) => f.t === "srv.request");
6868
assert.ok(req);
6969
assert.deepEqual(req.body.questions[0].options, ["a", "b"]);
@@ -92,7 +92,7 @@ const resp = await this.askUser?.({
9292
```dart
9393
test("ApprovalDialog renders on srv.request frame", () {
9494
final tester = WidgetTester();
95-
95+
9696
// Inject a fake StoreController
9797
final controller = FakeStoreController()
9898
..incomingFrames.add(Envelope(
@@ -106,11 +106,11 @@ test("ApprovalDialog renders on srv.request frame", () {
106106
}],
107107
},
108108
));
109-
109+
110110
await tester.pumpWidget(MaterialApp(
111111
home: ApprovalDialog(),
112112
));
113-
113+
114114
expect(find.text("Approve tool call?"), findsOneWidget);
115115
expect(find.byType(ElevatedButton), findsWidgets(count: 2));
116116
});
@@ -131,11 +131,11 @@ test("ApprovalDialog sends srv.response on button tap", () async {
131131
final outgoing = <Envelope>[];
132132
final controller = FakeStoreController()
133133
..onSend = (env) => outgoing.add(env);
134-
134+
135135
await tester.pumpWidget(/* as above */);
136136
await tester.tap(find.text("Approve"));
137137
await tester.pumpAndSettle();
138-
138+
139139
final resp = outgoing.whereType<Envelope>().firstWhere(
140140
(e) => e.t == MsgType.srvResponse && e.id == "req-1"
141141
);
@@ -151,7 +151,7 @@ test("ApprovalDialog sends srv.response on button tap", () async {
151151

152152
#### Test: `app/test/e2e/approval_e2e_test.dart``session awaiting approval flows end-to-end`
153153

154-
**Red:**
154+
**Red:**
155155
1. Stub server emits `session.status { status: "awaiting-approval" }`
156156
2. App renders approval UI
157157
3. User taps "Approve"
@@ -162,7 +162,7 @@ test("e2e: awaiting-approval → approval UI → srv.response → session contin
162162
// 1. Spin up stub server + app
163163
final stubServer = StubServer();
164164
await app.connect(stubServer.url);
165-
165+
166166
// 2. Stub: emit session.status awaiting-approval + srv.request
167167
stubServer.emitEvent(SessionEvent(
168168
kind: "session.status",
@@ -173,15 +173,15 @@ test("e2e: awaiting-approval → approval UI → srv.response → session contin
173173
id: "req-123",
174174
body: { "questions": [{ "options": ["Yes", "No"] }] },
175175
));
176-
176+
177177
// 3. App renders approval UI
178178
await tester.pumpAndSettle();
179179
expect(find.text("Approve?"), findsOneWidget);
180-
180+
181181
// 4. User taps
182182
await tester.tap(find.text("Yes"));
183183
await tester.pumpAndSettle();
184-
184+
185185
// 5. Verify stub server saw srv.response
186186
final resp = stubServer.capturedFrames.whereType<Envelope>()
187187
.firstWhere((e) => e.t == MsgType.srvResponse && e.id == "req-123");

0 commit comments

Comments
 (0)