Skip to content

Commit af07969

Browse files
committed
feat: add feature toggle for action cards and approval
1 parent 08e2454 commit af07969

8 files changed

Lines changed: 43 additions & 20 deletions

File tree

ai-server/src/mastra/tools/book-flight.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createTool } from '@mastra/core/tools';
22
import { z } from 'zod';
33

4+
import { USE_APPROVAL } from '../../../../feature-flags.js';
45
import {
56
addBooking,
67
fetchFlight,
@@ -97,7 +98,7 @@ export const bookFlightTool = createTool({
9798
};
9899
}
99100

100-
if (resumeData?.approved !== true) {
101+
if (USE_APPROVAL && resumeData?.approved !== true) {
101102
await suspend?.({
102103
action: 'book',
103104
flightId,

ai-server/src/mastra/tools/cancel-flight.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createTool } from '@mastra/core/tools';
22
import { z } from 'zod';
33

4+
import { USE_APPROVAL } from '../../../../feature-flags.js';
45
import {
56
fetchFlight,
67
isBooked,
@@ -70,7 +71,7 @@ export const cancelFlightTool = createTool({
7071

7172
const flight = await fetchFlight(flightId).catch(() => null);
7273

73-
if (resumeData?.approved !== true) {
74+
if (USE_APPROVAL && resumeData?.approved !== true) {
7475
const flightContext = flight
7576
? ` from ${flight.from} to ${flight.to} on ${formatFlightDate(flight.date)}`
7677
: '';

ai-server/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
"isolatedModules": true,
1414
"outDir": "./out-tsc/ai-server"
1515
},
16-
"include": ["src/**/*.ts", "../libs/ag-ui-server/**/*.ts"]
16+
"include": [
17+
"src/**/*.ts",
18+
"../libs/ag-ui-server/**/*.ts",
19+
"../feature-flags.ts"
20+
]
1721
}

feature-flags.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const USE_ACTION_CARDS = true;
2+
export const USE_APPROVAL = true;

sheriff.config.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ export const config: SheriffConfig = {
2424
depRules: {
2525
root: '*',
2626

27-
'domain:*': [sameTag, 'domain:shared'],
28-
29-
'type:ai': ['type:ai', 'type:feature', 'type:ui', 'type:data', 'type:util'],
30-
31-
'type:feature': ['type:ui', 'type:data', 'type:util'],
32-
'type:ui': ['type:ui', 'type:data', 'type:util'],
33-
'type:data': ['type:util'],
34-
'type:util': [],
27+
'domain:*': [sameTag, 'domain:shared', 'root'],
28+
29+
'type:ai': [
30+
'type:ai',
31+
'type:feature',
32+
'type:ui',
33+
'type:data',
34+
'type:util',
35+
'root',
36+
],
37+
38+
'type:feature': ['type:ui', 'type:data', 'type:util', 'root'],
39+
'type:ui': ['type:ui', 'type:data', 'type:util', 'root'],
40+
'type:data': ['type:util', 'root'],
41+
'type:util': ['root'],
3542

3643
'lib:*': '*',
3744

3845
testing: '*',
39-
'*': ['testing', 'lib:*'],
46+
'*': ['testing', 'lib:*', 'root'],
4047
},
4148
};

src/app/domains/ticketing/ai/ticketing-chat-service.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Injectable,
55
runInInjectionContext,
66
} from '@angular/core';
7+
import { USE_ACTION_CARDS } from '@flights42/feature-flags';
78
import {
89
type AgUiChatResourceRef,
910
agUiResource,
@@ -23,6 +24,10 @@ import { bookFlightActionCard } from './widgets/book-flight-action-card';
2324
import { cancelFlightActionCard } from './widgets/cancel-flight-action-card';
2425
import { flightWidget } from './widgets/flight-widget';
2526

27+
const ACTION_CARDS = USE_ACTION_CARDS
28+
? [bookFlightActionCard, cancelFlightActionCard]
29+
: [];
30+
2631
@Injectable({ providedIn: 'root' })
2732
export class TicketingChatService {
2833
private readonly config = inject(ConfigService);
@@ -33,6 +38,13 @@ export class TicketingChatService {
3338

3439
public init(): void {
3540
if (!this.chat) {
41+
const components = [
42+
messageWidget,
43+
flightWidget,
44+
mcpAppsWidgetComponent,
45+
...ACTION_CARDS,
46+
];
47+
3648
this.chat = runInInjectionContext(this.injector, () =>
3749
agUiResource({
3850
url: this.config.agUiUrl,
@@ -44,13 +56,7 @@ export class TicketingChatService {
4456
toggleFlightSelectionTool,
4557
getCurrentBasketTool,
4658
displayFlightDetailTool,
47-
createShowComponentsTool([
48-
messageWidget,
49-
flightWidget,
50-
mcpAppsWidgetComponent,
51-
bookFlightActionCard,
52-
cancelFlightActionCard,
53-
]),
59+
createShowComponentsTool(components),
5460
],
5561
}),
5662
);

tsconfig.app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"include": [
1010
"src/**/*.ts",
1111
"libs/ag-ui-client/**/*.ts",
12+
"feature-flags.ts",
1213
"src/app/domains/shared/signals/delegated-signal.spec.ts",
1314
"src/app/domains/ticketing/feature-booking/flight-search/flight-store.spec.ts"
1415
],

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"module": "preserve",
1717
"paths": {
1818
"@internal/ag-ui-client": ["./libs/ag-ui-client/index.ts"],
19-
"@internal/ag-ui-client/*": ["./libs/ag-ui-client/*"]
19+
"@internal/ag-ui-client/*": ["./libs/ag-ui-client/*"],
20+
"@flights42/feature-flags": ["./feature-flags.ts"]
2021
}
2122
},
2223
"angularCompilerOptions": {

0 commit comments

Comments
 (0)