Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"cross-env": "^10.1.0",
"jiti": "^2.7.0",
"nitro": "3.0.260522-beta",
"typescript": "^6.0.3"
"typescript": "^7.0.2"
}
}
5 changes: 3 additions & 2 deletions packages/junior-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build": "pnpm --filter @sentry/junior-plugin-api build && pnpm --filter @sentry/junior build && pnpm run build:client && pnpm run build:css && pnpm run build:server",
"build:client": "tsup --config tsup.client.config.ts",
"build:css": "tailwindcss -i src/tailwind.css -o dist/tailwind.css --minify",
"build:server": "tsup --config tsup.config.ts",
"build:server": "tsup --config tsup.config.ts && tsdown --config tsdown.dts.config.ts",
"lint": "oxlint --config .oxlintrc.json --deny-warnings src",
"prepare": "pnpm run build",
"prepack": "pnpm run build",
Expand Down Expand Up @@ -60,8 +60,9 @@
"eslint": "^10.8.0",
"oxlint": "^1.79.0",
"tailwindcss": "^4.3.0",
"tsdown": "0.23.1",
"tsup": "^8.5.1",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"vitest": "^4.1.7"
}
}
1 change: 1 addition & 0 deletions packages/junior-dashboard/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ export function createDashboardApp(
c.set("viewer", viewer);
}
await next();
return undefined;
};

app.use("*", requireAuth);
Expand Down
3 changes: 1 addition & 2 deletions packages/junior-dashboard/src/authenticated-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export function isAuthPath(
const requestSegments = segments(pathname);
return routes.some((route) => {
const routeSegments = segments(route.path);
for (let index = 0; index < routeSegments.length; index += 1) {
const pattern = routeSegments[index];
for (const [index, pattern] of routeSegments.entries()) {
if (pattern === "*") return true;
const value = requestSegments[index];
if (!value || (pattern !== value && !pattern.startsWith(":"))) {
Expand Down
6 changes: 3 additions & 3 deletions packages/junior-dashboard/src/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class DashboardErrorBoundary extends Component<
{ children: ReactNode },
ErrorBoundaryState
> {
state: ErrorBoundaryState = { error: null };
override state: ErrorBoundaryState = { error: null };

static getDerivedStateFromError(error: Error): ErrorBoundaryState {
return { error };
}

componentDidCatch(error: Error, errorInfo: ErrorInfo) {
override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
const stack = error.stack ?? errorInfo.componentStack;
window.__JUNIOR_DASHBOARD_SHOW_ERROR__?.(stack ? new Error(stack) : error);
}

render() {
override render() {
if (this.state.error) {
return <DashboardErrorPanel error={this.state.error} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ export function activityGroupSummary(
(entry) => entry.kind === "attachments_delivered",
).length;
const eventCount = entries.filter((entry) => entry.kind === "message").length;
const [onlyHandoff] = handoffs;
const handoffSummary =
handoffs.length === 1
? `model handoff to ${handoffs[0].modelId} (${handoffs[0].modelProfile})`
handoffs.length === 1 && onlyHandoff
? `model handoff to ${onlyHandoff.modelId} (${onlyHandoff.modelProfile})`
: handoffs.length > 1
? countLabel(handoffs.length, "model handoff", "model handoffs")
: undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ export function transcriptFailureTitle(
case "agent_run_failed":
return "Internal error";
}

return "Internal error";
}

/** Short description for one failed turn in the transcript. */
Expand Down Expand Up @@ -111,8 +109,6 @@ export function transcriptFailureDescription(
case "agent_run_failed":
return `${agentName} hit an internal error during this turn.`;
}

return `${agentName} hit an internal error during this turn.`;
}

/** Search text for one failed turn in the transcript. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function findNextMarkdownLink(
start: linkStart,
};
}
return undefined;
}

function findMarkdownLinkSyntaxRanges(
Expand Down Expand Up @@ -148,6 +149,7 @@ function readMarkdownDestination(
const href = text.slice(start, index);
return href ? { end: index + 1, href } : undefined;
}
return undefined;
}

function findCommonMarkAutolinks(
Expand Down Expand Up @@ -199,6 +201,7 @@ function findNextBareLink(
start: match.index,
};
}
return undefined;
}

function findBareLinks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export function AutomationOutcomeFields(props: {
disabled={index === 0}
onClick={() => {
const next = [...props.value];
[next[index - 1], next[index]] = [
next[index],
next[index - 1],
];
const previous = next[index - 1];
if (!previous) return;
next[index - 1] = outcome;
next[index] = previous;
props.onChange(next);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function scheduleDraft(
...fields,
timezone: value.schedule.timezone,
time: `${String(time.hour).padStart(2, "0")}:${String(time.minute).padStart(2, "0")}`,
weekdays: days?.map((day) => weekdays[day]),
weekdays: days?.flatMap((day) => weekdays[day] ?? []),
Comment thread
sentry-junior[bot] marked this conversation as resolved.
};
}
if (value.nextRunAtMs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const toneColors = {
warning: "#fbbf24",
} as const;

function seriesColor(series: Widget["series"][number], index: number): string {
return series.tone
? toneColors[series.tone]
: (colors[index % colors.length] ?? colors[0]);
}

/** Render a validated plugin-owned categorical bar chart. */
export function PluginBarChart(props: {
range?: TimeRangeDays;
Expand Down Expand Up @@ -69,9 +75,7 @@ export function PluginBarChart(props: {
<ChartLegend
ariaLabel="Chart legend"
items={widget.series.map((series, index) => ({
color: series.tone
? toneColors[series.tone]
: colors[index % colors.length],
color: seriesColor(series, index),
key: series.key,
label: series.label,
}))}
Expand Down Expand Up @@ -122,11 +126,7 @@ export function PluginBarChart(props: {
>
<rect
aria-label={`${formatActivityCategoryTooltipLabel(category.label)}, ${series.label}: ${formatted}`}
fill={
series.tone
? toneColors[series.tone]
: colors[seriesIndex % colors.length]
}
fill={seriesColor(series, seriesIndex)}
height={renderedHeight}
opacity={value ? 0.82 : 0.1}
rx="1.5"
Expand Down
6 changes: 3 additions & 3 deletions packages/junior-dashboard/tests/activity-chart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ describe("SystemMetricCharts average line", () => {
expect(
formatCacheShare(summary.input.cacheCreationTokens, summary.total),
).toBe("11.1%");
const missing = { ...days[0], cacheCreationTokens: undefined };
const missing = { ...days[0]!, cacheCreationTokens: undefined };
expect(cacheInputTotal(missing)).toBeUndefined();
expect(summarizeCacheInput([missing, days[1]]).total).toBeUndefined();
expect(summarizeCacheInput([missing, days[1]]).incompletePeriods).toBe(1);
expect(summarizeCacheInput([missing, days[1]!]).total).toBeUndefined();
expect(summarizeCacheInput([missing, days[1]!]).incompletePeriods).toBe(1);
const zeroWrites = { ...days[0], cacheCreationTokens: 0 };
expect(cacheInputTotal(zeroWrites)).toBe(1_000_000_000);
expect(formatCacheShare(0, cacheInputTotal(zeroWrites))).toBe("0.0%");
Expand Down
1 change: 0 additions & 1 deletion packages/junior-dashboard/tests/client-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
setMockConversationArchived,
} from "../src/mock-reporting/fixtures";
import { personalSpendRefreshDelay } from "../src/client/api";
import { fetchDashboardJson } from "../src/client/http";
import { dashboardVersionDrift } from "../src/client/components/VersionDriftBanner";
import { DASHBOARD_VERSION_HEADER } from "../src/dashboard-version";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ function plugin(name: string, overrides: Partial<Plugin> = {}): Plugin {
configKeys: [],
description: `${name} plugin description`,
displayName:
name === "github" ? "GitHub" : `${name[0].toUpperCase()}${name.slice(1)}`,
name === "github"
? "GitHub"
: `${name.charAt(0).toUpperCase()}${name.slice(1)}`,
name,
...overrides,
};
Expand Down
4 changes: 1 addition & 3 deletions packages/junior-dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"jsx": "react-jsx",
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"allowJs": false,
"noEmit": true,
"paths": {
Expand Down
19 changes: 19 additions & 0 deletions packages/junior-dashboard/tsdown.dts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "tsdown";

// tsup still emits the server JavaScript. Its declaration bundler needs the
// TypeScript 6 compiler API, so tsdown bundles the public types instead.
export default defineConfig({
entry: {
index: "src/index.ts",
},
tsconfig: "tsconfig.build.json",
dts: {
emitDtsOnly: true,
},
outDir: "dist",
outExtensions: () => ({
js: ".js",
dts: ".d.ts",
}),
clean: false,
});
10 changes: 1 addition & 9 deletions packages/junior-dashboard/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ export default defineConfig({
},
format: "esm",
tsconfig: "tsconfig.build.json",
dts: {
entry: {
index: "src/index.ts",
},
compilerOptions: {
// TODO(upstream): Remove after tsup stops adding deprecated baseUrl.
ignoreDeprecations: "6.0",
},
},
dts: false,
outDir: "dist",
clean: false,
splitting: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/junior-evals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"hono": "^4.12.27",
"msw": "^2.14.6",
"tinyrainbow": "^3.1.0",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"undici": "7.29.0",
"vitest": "^4.1.7",
"vitest-evals": "0.16.1",
Expand Down
14 changes: 8 additions & 6 deletions packages/junior-evals/src/fixture/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ function offsetMs(ms: number): number {
.formatToParts(ms)
.map((part) => [part.type, Number(part.value)]),
);
const part = (type: Intl.DateTimeFormatPartTypes) => parts[type] ?? 0;
const wall = Date.UTC(
parts.year,
parts.month - 1,
parts.day,
parts.hour,
parts.minute,
part("year"),
part("month") - 1,
part("day"),
part("hour"),
part("minute"),
);
return wall - Math.floor(ms / 60_000) * 60_000;
}

/** The instant of a Pacific time on a day, given as UTC midnight. */
function pacificMs(dayMs: number, clock: string): number {
const [hours, minutes] = clock.split(":").map(Number);
const [hours = 0, minutes = 0] = clock.split(":").map(Number);
const wall = dayMs + hours * 3_600_000 + minutes * 60_000;
// A second pass corrects the offset on days when it changes.
return wall - offsetMs(wall - offsetMs(wall));
Expand All @@ -92,6 +93,7 @@ function occurrences(calendar: MockCalendar, timeMin: string, timeMax: string) {
dayMs += DAY_MS
) {
const weekday = WEEKDAYS[new Date(dayMs).getUTCDay()];
if (!weekday) continue;
const date = new Date(dayMs).toISOString().slice(0, 10).replaceAll("-", "");
for (const [index, event] of calendar.events.entries()) {
const startMs = pacificMs(dayMs, event.start);
Expand Down
4 changes: 1 addition & 3 deletions packages/junior-evals/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"paths": {
Expand Down
2 changes: 1 addition & 1 deletion packages/junior-github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"msw": "^2.14.6",
"oxlint": "^1.79.0",
"tsup": "^8.5.1",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"vitest": "^4.1.7"
}
}
7 changes: 4 additions & 3 deletions packages/junior-github/src/tool-support/attribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ function applyAttribution(body: string, label: string | undefined): string {
`${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`,
);
const existingMatch = normalizedBody.match(existing);
const existingLabels = existingMatch
? parseExistingLabels(existingMatch[1])
: [];
const existingLabels =
existingMatch?.[1] !== undefined
? parseExistingLabels(existingMatch[1])
: [];
const labels =
label && !existingLabels.includes(label)
? [...existingLabels, label]
Expand Down
8 changes: 5 additions & 3 deletions packages/junior-github/src/webhooks/ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ function parseGitHubBotIdentity(
value: string | undefined,
): GitHubBotIdentity | undefined {
const match = GITHUB_BOT_NOREPLY_EMAIL.exec(value?.trim() ?? "");
if (!match?.groups) return undefined;
const login = match?.groups?.login;
const userId = match?.groups?.userId;
if (!login || !userId) return undefined;
return {
login: match.groups.login,
userId: Number(match.groups.userId),
login,
userId: Number(userId),
};
}

Expand Down
4 changes: 1 addition & 3 deletions packages/junior-github/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"noEmit": true,
"types": ["node"]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/junior-google/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"drizzle-kit": "catalog:",
"oxlint": "^1.79.0",
"tsup": "^8.5.1",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"vitest": "^4.1.7"
}
}
Loading
Loading