fix(app): scope pending pipeline runs by endpoint
This commit is contained in:
@@ -77,6 +77,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
|
||||
Widget _pipelinesScreen() => PipelinesScreen(
|
||||
gateway: session.gateway,
|
||||
endpoint: server.uri?.toString() ?? '',
|
||||
embedded: true,
|
||||
onRunStarted: onRunStarted,
|
||||
onViewPipelineRuns: onViewPipelineRuns,
|
||||
|
||||
@@ -26,6 +26,7 @@ class PipelinesScreen extends StatefulWidget {
|
||||
const PipelinesScreen({
|
||||
super.key,
|
||||
required this.gateway,
|
||||
this.endpoint = '',
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
this.onRunStarted,
|
||||
@@ -37,6 +38,9 @@ class PipelinesScreen extends StatefulWidget {
|
||||
|
||||
final ApiGateway gateway;
|
||||
|
||||
/// Validated websocket endpoint used to isolate stored launch intents.
|
||||
final String endpoint;
|
||||
|
||||
/// True under the application shell, which owns the single navigation bar.
|
||||
final bool embedded;
|
||||
|
||||
@@ -84,7 +88,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
super.initState();
|
||||
_controller = PipelinesController(
|
||||
PipelinesRepository(widget.gateway),
|
||||
pendingRunStore: const SharedPreferencesPendingRunStore(''),
|
||||
pendingRunStore: SharedPreferencesPendingRunStore(widget.endpoint),
|
||||
)..load();
|
||||
final id = widget.initialPipelineId;
|
||||
if (id != null) {
|
||||
@@ -96,11 +100,12 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
@override
|
||||
void didUpdateWidget(PipelinesScreen oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.gateway != widget.gateway) {
|
||||
if (oldWidget.gateway != widget.gateway ||
|
||||
oldWidget.endpoint != widget.endpoint) {
|
||||
_controller.dispose();
|
||||
_controller = PipelinesController(
|
||||
PipelinesRepository(widget.gateway),
|
||||
pendingRunStore: const SharedPreferencesPendingRunStore(''),
|
||||
pendingRunStore: SharedPreferencesPendingRunStore(widget.endpoint),
|
||||
)..load();
|
||||
} else if (oldWidget.syncToken != widget.syncToken) {
|
||||
// The socket was replaced; re-read through the existing controller so the
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -7,6 +8,8 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pending_run_store.dart';
|
||||
import 'package:pipelines_app/features/pipelines/run_pipeline_intent.dart';
|
||||
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
|
||||
|
||||
import '../fixtures.dart';
|
||||
@@ -81,6 +84,53 @@ Future<void> fillFields(
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
testWidgets('pending launch intent is scoped to its server endpoint', (
|
||||
tester,
|
||||
) async {
|
||||
const intent = RunPipelineIntent(
|
||||
pipelineId: 1,
|
||||
version: 2,
|
||||
prompt: 'pending',
|
||||
workspace: '/work/alpha',
|
||||
notifyMode: RunNotifyMode.notify,
|
||||
requestKey: 'endpoint-intent',
|
||||
);
|
||||
SharedPreferences.setMockInitialValues({
|
||||
pendingRunStorageKey('ws://server-a/connect', 1, 2):
|
||||
jsonEncode(intent.toJson()),
|
||||
});
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = launchGateway(fixture, onLaunch: (_) => noRun());
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: PipelinesScreen(
|
||||
gateway: gateway,
|
||||
endpoint: 'ws://server-b/connect',
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await openDetail(tester);
|
||||
await tester.tap(find.byKey(runPipelineActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runPipelineCheckRetryLabel), findsNothing);
|
||||
await tester.tap(find.byKey(runPipelineCancelKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: PipelinesScreen(
|
||||
gateway: gateway,
|
||||
endpoint: 'ws://server-a/connect',
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await openDetail(tester);
|
||||
await tester.tap(find.byKey(runPipelineActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runPipelineCheckRetryLabel), findsOneWidget);
|
||||
});
|
||||
testWidgets(
|
||||
'workspace directory suggestions load on open and selection is local',
|
||||
(tester) async {
|
||||
|
||||
Reference in New Issue
Block a user