fix(app): scope pending pipeline runs by endpoint
This commit is contained in:
@@ -77,6 +77,7 @@ class PipelinesDestination extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _pipelinesScreen() => PipelinesScreen(
|
Widget _pipelinesScreen() => PipelinesScreen(
|
||||||
gateway: session.gateway,
|
gateway: session.gateway,
|
||||||
|
endpoint: server.uri?.toString() ?? '',
|
||||||
embedded: true,
|
embedded: true,
|
||||||
onRunStarted: onRunStarted,
|
onRunStarted: onRunStarted,
|
||||||
onViewPipelineRuns: onViewPipelineRuns,
|
onViewPipelineRuns: onViewPipelineRuns,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class PipelinesScreen extends StatefulWidget {
|
|||||||
const PipelinesScreen({
|
const PipelinesScreen({
|
||||||
super.key,
|
super.key,
|
||||||
required this.gateway,
|
required this.gateway,
|
||||||
|
this.endpoint = '',
|
||||||
this.embedded = false,
|
this.embedded = false,
|
||||||
this.syncToken = 0,
|
this.syncToken = 0,
|
||||||
this.onRunStarted,
|
this.onRunStarted,
|
||||||
@@ -37,6 +38,9 @@ class PipelinesScreen extends StatefulWidget {
|
|||||||
|
|
||||||
final ApiGateway gateway;
|
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.
|
/// True under the application shell, which owns the single navigation bar.
|
||||||
final bool embedded;
|
final bool embedded;
|
||||||
|
|
||||||
@@ -84,7 +88,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_controller = PipelinesController(
|
_controller = PipelinesController(
|
||||||
PipelinesRepository(widget.gateway),
|
PipelinesRepository(widget.gateway),
|
||||||
pendingRunStore: const SharedPreferencesPendingRunStore(''),
|
pendingRunStore: SharedPreferencesPendingRunStore(widget.endpoint),
|
||||||
)..load();
|
)..load();
|
||||||
final id = widget.initialPipelineId;
|
final id = widget.initialPipelineId;
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@@ -96,11 +100,12 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
@override
|
@override
|
||||||
void didUpdateWidget(PipelinesScreen oldWidget) {
|
void didUpdateWidget(PipelinesScreen oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (oldWidget.gateway != widget.gateway) {
|
if (oldWidget.gateway != widget.gateway ||
|
||||||
|
oldWidget.endpoint != widget.endpoint) {
|
||||||
_controller.dispose();
|
_controller.dispose();
|
||||||
_controller = PipelinesController(
|
_controller = PipelinesController(
|
||||||
PipelinesRepository(widget.gateway),
|
PipelinesRepository(widget.gateway),
|
||||||
pendingRunStore: const SharedPreferencesPendingRunStore(''),
|
pendingRunStore: SharedPreferencesPendingRunStore(widget.endpoint),
|
||||||
)..load();
|
)..load();
|
||||||
} else if (oldWidget.syncToken != widget.syncToken) {
|
} else if (oldWidget.syncToken != widget.syncToken) {
|
||||||
// The socket was replaced; re-read through the existing controller so the
|
// The socket was replaced; re-read through the existing controller so the
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.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/api_gateway.dart';
|
||||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/screen.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 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
|
||||||
|
|
||||||
import '../fixtures.dart';
|
import '../fixtures.dart';
|
||||||
@@ -81,6 +84,53 @@ Future<void> fillFields(
|
|||||||
void main() {
|
void main() {
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
SharedPreferences.setMockInitialValues({});
|
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(
|
testWidgets(
|
||||||
'workspace directory suggestions load on open and selection is local',
|
'workspace directory suggestions load on open and selection is local',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
|
|||||||
Reference in New Issue
Block a user