Skip to content

Commit b28a03c

Browse files
authored
Apps MCP: address prompts issues (#4046)
Reduce friction observed during bulk generations
1 parent 789bb75 commit b28a03c

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

experimental/apps-mcp/cmd/init_template.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ After initialization:
273273

274274
configFile := tmpFile.Name()
275275

276+
// Create output directory if specified and doesn't exist
277+
if outputDir != "" {
278+
if err := os.MkdirAll(outputDir, 0o755); err != nil {
279+
return fmt.Errorf("create output directory: %w", err)
280+
}
281+
}
282+
276283
r := template.Resolver{
277284
TemplatePathOrUrl: templatePathOrUrl,
278285
ConfigFile: configFile,

experimental/apps-mcp/lib/prompts/apps.tmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ invoke_databricks_cli 'experimental apps-mcp tools validate ./your-app-location'
2323

2424
# Deployment
2525

26-
⚠️ Always use the sequence of commands:
26+
⚠️ Use the deploy command which validates, deploys, and runs the app:
2727

28-
invoke_databricks_cli 'bundle deploy'
29-
invoke_databricks_cli 'bundle run app'
28+
invoke_databricks_cli 'experimental apps-mcp tools deploy'
3029

3130
# View and manage your app:
3231

experimental/apps-mcp/templates/appkit/template/{{.project_name}}/CLAUDE.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ The init-template command validates this automatically.
2121

2222
## TypeScript Import Rules
2323

24-
This template uses strict TypeScript settings with `verbatimModuleSyntax: true`. **Always use `import type` for type-only imports**:
24+
This template uses strict TypeScript settings with `verbatimModuleSyntax: true`. **Always use `import type` for type-only imports**.
25+
26+
Template enforces `noUnusedLocals` - remove unused imports immediately or build fails.
27+
28+
**Type-only imports**:
2529

2630
```typescript
2731
// ✅ CORRECT - use import type for types
@@ -166,6 +170,20 @@ WHERE DATE(timestamp_column) >= :start_date
166170
- **Dates**: Format as `YYYY-MM-DD`, use with `DATE()` in SQL
167171
- **Optional**: Use empty string default, check with `(:param = '' OR column = :param)`
168172

173+
## SQL Type Handling
174+
175+
Numeric fields from Databricks SQL (especially `ROUND()`, `AVG()`, `SUM()`) are returned as strings in JSON. Convert before using numeric methods:
176+
177+
```typescript
178+
// ❌ WRONG - fails at runtime
179+
<span>{row.total_amount.toFixed(2)}</span>
180+
181+
// ✅ CORRECT
182+
<span>{Number(row.total_amount).toFixed(2)}</span>
183+
```
184+
185+
Use helpers from `shared/types.ts`: `toNumber()`, `formatCurrency()`, `formatPercent()`.
186+
169187
## tRPC for Custom Endpoints:
170188

171189
**CRITICAL**: Do NOT use tRPC for SQL queries or data retrieval. Use `config/queries/` + `useAnalyticsQuery` instead.
@@ -363,6 +381,10 @@ npm run test:e2e:ui # Run with Playwright UI
363381
- Feature components: `client/src/components/FeatureName.tsx`
364382
- Split components when logic exceeds ~100 lines or component is reused
365383

384+
### Radix UI Constraints
385+
386+
- `SelectItem` cannot have `value=""`. Use sentinel value like `"all"` for "show all" options.
387+
366388
### Best Practices:
367389

368390
- Use shadcn/radix components (Button, Input, Card, etc.) for consistent UI
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
export interface QueryResult {
22
value: string;
33
}
4+
5+
// SQL type helpers - numeric fields from Databricks SQL return as strings
6+
export const toNumber = (val: string | number | null | undefined): number =>
7+
Number(val || 0);
8+
9+
export const formatCurrency = (val: string | number | null | undefined): string =>
10+
`$${toNumber(val).toFixed(2)}`;
11+
12+
export const formatPercent = (val: string | number | null | undefined): string =>
13+
`${toNumber(val).toFixed(1)}%`;

experimental/apps-mcp/templates/appkit/template/{{.project_name}}/tests/smoke.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ test('smoke test - app loads and displays data', async ({ page }) => {
1212
// Navigate to the app
1313
await page.goto('/');
1414

15-
// Wait for the page title to be visible
15+
// ⚠️ UPDATE THESE SELECTORS after customizing App.tsx:
16+
// - Change heading name to match your app title
17+
// - Change data selector to match your primary data display
1618
await expect(page.getByRole('heading', { name: 'Minimal Databricks App' })).toBeVisible();
17-
18-
// Wait for SQL query result to load (wait for "hello world" to appear)
1919
await expect(page.getByText('hello world', { exact: true })).toBeVisible({ timeout: 30000 });
2020

2121
// Wait for health check to complete (wait for "OK" status)

0 commit comments

Comments
 (0)