Skip to content

Commit 15c79b2

Browse files
authored
Feature/launch analyst mode (#258)
* Launch Analyst Mode for MBQL & Dashboards * Don't cache empty metadata values * Add one time optimisation UI for analyst mode
1 parent f44869b commit 15c79b2

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

web/src/cache/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async function clearStaleEntries() {
159159

160160
// Show remaining entries
161161
const remainingEntries = entries.filter(entry => !entry.isStale);
162-
console.table(remainingEntries);
162+
// console.table(remainingEntries);
163163

164164
return {
165165
total: entries.length,

web/src/components/common/ActionStack.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { CodeBlock } from './CodeBlock';
2121
import { ActionRenderInfo } from '../../state/chat/types';
2222
import { Markdown } from './Markdown';
2323
import {processModelToUIText} from '../../helpers/utils';
24+
import { get, isEmpty } from 'lodash';
2425

2526
// Todo: Vivek: Hardcoding here, need to fix this later
2627
// This is a list of actions that are undo/redoable
@@ -275,7 +276,11 @@ const scrollUp = keyframes`
275276
`;
276277

277278
const PlanningActionStack: React.FC = () => {
278-
const planningActions = ['Planning next steps', 'Thinking about the question', 'Understanding App state', 'Finalizing Actions', 'Validating Answers']
279+
const dbId = useAppStore((state) => state.toolContext.dbId) || 0;
280+
const metadataProcessingCache = useSelector((state: RootState) => state.settings.metadataProcessingCache)
281+
const isAnalystmode = useSelector((state: RootState) => state.settings.analystMode) || false;
282+
const dbMetadata = get(metadataProcessingCache, [dbId, 'result'], null);
283+
const planningActions = isEmpty(dbMetadata) && isAnalystmode? ['One time optimizations underway'] : ['Planning next steps', 'Thinking about the question', 'Understanding App state', 'Finalizing Actions', 'Validating Answers']
279284
const [currentTitleIndex, setCurrentTitleIndex] = useState(0);
280285
useEffect(() => {
281286
const intervalId = setInterval(() => {

web/src/components/common/TaskUI.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,17 @@ const TaskUI = forwardRef<HTMLTextAreaElement>((_props, ref) => {
233233
toastDescription = "Please select a database"
234234
preventRunTask = true
235235
}
236-
else if (toolContext.pageType === 'dashboard' && (!drMode || analystMode)) {
236+
else if (toolContext.pageType === 'dashboard' && (!drMode)) {
237237
toastTitle = 'Dashboard is supported only in agent mode'
238238
toastDescription = "You can enable agent mode in settings"
239239
preventRunTask = true
240240
}
241-
else if (toolContext.pageType === 'mbql' && (!drMode || analystMode)) {
241+
else if (toolContext.pageType === 'mbql' && (!drMode)) {
242242
toastTitle = 'MBQL Editor is supported only in agent mode'
243243
toastDescription = "You can enable agent mode in settings"
244244
preventRunTask = true
245245
}
246-
else if (toolContext.pageType === 'mbql' && (selectedCatalog != DEFAULT_TABLES || analystMode)) {
246+
else if (toolContext.pageType === 'mbql' && (selectedCatalog != DEFAULT_TABLES)) {
247247
toastTitle = 'MBQL Editor is supported only in Default Tables catalog'
248248
toastDescription = "You can switch to Default Tables catalog in settings"
249249
preventRunTask = true
@@ -380,9 +380,9 @@ const TaskUI = forwardRef<HTMLTextAreaElement>((_props, ref) => {
380380
{
381381
isAppEnabled && !shouldBeEnabled && <DisabledOverlay toolEnabledReason={"You're currently using MinusX Classic, which only works on SQL Editor pages. [Find out](https://minusx.ai/demo) how to enable Agent mode and unlock all the features!"}/>
382382
}
383-
{
383+
{/* {
384384
analystMode && (toolContext.pageType != 'sql') && <DisabledOverlay toolEnabledReason={"You're currently using `[badge]Analyst Mode (alpha)`, which only works on SQL Editor pages for now!"}/>
385-
}
385+
} */}
386386
<VStack
387387
justifyContent="space-between"
388388
alignItems="stretch"

web/src/helpers/metadataProcessor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import axios from 'axios';
99
import { configs } from '../constants';
1010
import { getOrigin } from './origin';
11-
import { get } from 'lodash';
11+
import { get, isEmpty } from 'lodash';
1212
import { MetadataProcessingResult, setMetadataHash, setMetadataProcessingCache, clearMetadataProcessingCache } from '../state/settings/reducer';
1313
import { getState } from '../state/store';
1414
import { dispatch } from '../state/dispatch';
@@ -120,6 +120,10 @@ async function processMetadataWithCaching(
120120
dataFetcher: () => Promise<any>): Promise<string | undefined> {
121121
// Fetch the data
122122
const data = await dataFetcher()
123+
if (isEmpty(data)) {
124+
console.warn(`[minusx] No data found for ${metadataType}, skipping upload`)
125+
return undefined; // No data to process
126+
}
123127
console.log('Retrieved data for metadata type', metadataType, data)
124128

125129
// Calculate hash of current data
@@ -272,6 +276,10 @@ export async function processAllMetadata() : Promise<MetadataProcessingResult> {
272276
}
273277

274278
// Cache the result for this database ID
279+
if (!result.cardsHash) {
280+
console.warn('[minusx] Cardshash is undefined, not caching result')
281+
return result; // Return even if some hashes are missing
282+
}
275283
dispatch(setMetadataProcessingCache({ dbId: selectedDbId, result }))
276284
console.log(`[minusx] Cached metadata processing result for database ${selectedDbId}`)
277285

web/src/state/store.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,17 @@ const migrations = {
483483
})
484484
return newState
485485
},
486+
47: (state: RootState) => {
487+
let newState = {...state}
488+
// Refresh metadataProcessingCache
489+
newState.settings.metadataProcessingCache = {}
490+
return newState
491+
},
486492
}
487493

488494
const persistConfig = {
489495
key: 'root',
490-
version: 46,
496+
version: 47,
491497
storage,
492498
blacklist: ['billing', 'cache', userStateApi.reducerPath],
493499
// @ts-ignore

0 commit comments

Comments
 (0)