feat(expo-router): add Expo Router support for Screens and navigations and introduce Steps API

- Adds Expo Router integration with a new Screens view and a Steps API to surface screens and their transitions.
- Extends codegraph extraction/resolution to handle namespace objects, React hook bindings for handlers, and Swift RN bridge evidence; introduces per-site guard arguments and trigger metadata, enabling richer flow analysis across JS ↔ native boundaries.
- Introduces UI and data-model changes to represent conditions as words (WHEN/AND/OR/NOT), display per-site call arguments, and show what fires a site (triggers). Adds new utilities (ui/conditions.ts) and updates ScreensView and StepsView to render scenarios with multiple sites and “ways” counts.
- Implements site readers for WHEN/ARGS/TRIGGER, and wiring to expose steps via API endpoints (including /api/steps); enhances tests to cover namespace resolution, useCallback-driven handlers, and inline RN event listeners.
- Updates styling and templates to reflect the new wording, scenario rows, and per-site details, including NOT instead of leading negation strings and multi-way links.
- Documents and reflects changes in changelog and design docs to describe Expo Router integration and the Steps surface.
This commit is contained in:
Colby McHenry
2026-08-28 10:21:46 -05:00
parent 873f133c96
commit e288d7645b
16 changed files with 1028 additions and 127 deletions
+70 -1
View File
@@ -4,7 +4,7 @@ import * as os from 'os';
import * as path from 'path';
import { CodeGraph } from '../src';
import { initGrammars } from '../src/extraction/grammars';
import { guardsInSource, guardLabel, supportsBranchGuards } from '../src/graph/branch-guards';
import { callArgumentsInSource, guardsInSource, guardLabel, supportsBranchGuards } from '../src/graph/branch-guards';
import { buildNode } from '../src/ui-server/api/node';
import { buildFlow } from '../src/ui-server/api/flow';
@@ -48,6 +48,21 @@ export function ItemCard(props) {
expect(await labelAt(handlePress, 'openObjectDetail(')).toBe('!isUploading && isCollected');
});
it('keeps a disjunctive guard in parentheses, so the join stays unambiguous', async () => {
const src = `
function go(object) {
if (isUploading) return
if (!object?.id || !object?.name) {
bail()
return
}
proceed()
}
`;
expect(await labelAt(src, 'bail(')).toBe('!isUploading && (!object?.id || !object?.name)');
expect(await labelAt(src, 'proceed(')).toBe('!isUploading && !(!object?.id || !object?.name)');
});
it('turns each earlier early-return into a negated guard, in source order', async () => {
expect(await labelAt(handlePress, 'handleAddToQueue(')).toBe('!isUploading && !isCollected && queueHasItems');
expect(await labelAt(handlePress, 'handleStartCapture(')).toBe('!isUploading && !isCollected && !queueHasItems');
@@ -238,3 +253,57 @@ describe('branch guards: on the wire', () => {
cg.close();
});
});
// =============================================================================
// Call arguments — what a site passes
// =============================================================================
async function argsAt(src: string, needle: string, language: 'tsx' | 'typescript' | 'swift' = 'tsx') {
const line = lineOf(src, needle);
const column = src.split('\n')[line - 1]!.indexOf(needle);
return callArgumentsInSource(src, language, line, column);
}
describe('call arguments', () => {
const login = `
async function handleLogin(values) {
await SecureStore.setItemAsync('userEmail', values.email)
const res = await client.post('/auth/login', { email: values.email, password, ...rest })
Alert.alert(i18n.t('error_login_failed'), err.message, [{ text: 'OK' }])
router.push({ pathname: '/item/[id]', params: { id } })
captureView.finalizeCaptureSession()
run(() => go(), async (x) => x, new Thing(1))
const big = fetch(\`/api/\${id}\`, { method: 'POST', headers, body, mode, cache, credentials })
}
`;
it('keeps literals and names whole, folds objects to their keys, arrays and functions to a shape', async () => {
expect(await argsAt(login, 'SecureStore.setItemAsync(')).toBe("'userEmail', values.email");
expect(await argsAt(login, 'client.post(')).toBe("'/auth/login', { email, password, ...rest }");
expect(await argsAt(login, 'Alert.alert(')).toBe('i18n.t(…), err.message, […]');
expect(await argsAt(login, 'router.push(')).toBe('{ pathname, params }');
expect(await argsAt(login, 'run(')).toBe('() => …, () => …, new Thing(…)');
expect(await argsAt(login, 'fetch(')).toBe('`/api/${id}`, { method, headers, body, mode, … }');
});
it('an empty argument list is an empty string; a position outside a call is null', async () => {
expect(await argsAt(login, 'captureView.finalizeCaptureSession(')).toBe('');
expect(await argsAt(login, 'async function handleLogin')).toBeNull();
});
it('Swift: labels stay with their values, a trailing closure is a shape', async () => {
const src = `
class CaptureEvents {
func emitZipComplete(result: ZipResult) {
sendEvent(withName: "onZipComplete", body: ["zipURL": result.url])
tracker.setup(side: side, angle: 45)
DispatchQueue.main.async { finish() }
}
}
`;
expect(await argsAt(src, 'sendEvent(', 'swift')).toBe('withName: "onZipComplete", body: […]');
expect(await argsAt(src, 'tracker.setup(', 'swift')).toBe('side: side, angle: 45');
expect(await argsAt(src, 'DispatchQueue.main.async', 'swift')).toBe('{ … }');
});
});