Skip to content

Commit 969b6ea

Browse files
committed
factor out common type
1 parent d7efe7e commit 969b6ea

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

packages/compass-assistant/src/compass-assistant-provider.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ type AssistantActionsContextType = {
7070
callback: () => void
7171
) => Promise<void>;
7272
};
73+
74+
type AssistantActionsType = Omit<
75+
AssistantActionsContextType,
76+
'ensureOptInAndSend' | 'clearChat'
77+
>;
78+
7379
export const AssistantActionsContext =
7480
createContext<AssistantActionsContextType>({
7581
interpretExplainPlan: () => {},
@@ -79,10 +85,7 @@ export const AssistantActionsContext =
7985
ensureOptInAndSend: async () => {},
8086
});
8187

82-
export function useAssistantActions(): Omit<
83-
AssistantActionsContextType,
84-
'ensureOptInAndSend' | 'clearChat'
85-
> {
88+
export function useAssistantActions(): AssistantActionsType {
8689
const actions = useContext(AssistantActionsContext);
8790
const isAIFeatureEnabled = useIsAIFeatureEnabled();
8891
const isAssistantFlagEnabled = usePreference('enableAIAssistant');
@@ -105,16 +108,10 @@ export function useAssistantActions(): Omit<
105108

106109
export const compassAssistantServiceLocator = createServiceLocator(function () {
107110
const actions = useAssistantActions();
108-
109111
return actions;
110112
}, 'compassAssistantLocator');
111113

112-
export type CompassAssistantService = Omit<
113-
AssistantActionsContextType,
114-
'ensureOptInAndSend' | 'clearChat'
115-
> & {
116-
getIsAssistantEnabled: () => boolean;
117-
};
114+
export type CompassAssistantService = AssistantActionsType;
118115

119116
export const AssistantProvider: React.FunctionComponent<
120117
PropsWithChildren<{

0 commit comments

Comments
 (0)