Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export function PresentationCursorCanvas({
0,
slides.findIndex((slide) => asNumber(slide.index, 1) === selectedIndex),
);
const selectedSlide = slides[selectedPosition] ?? slides[0] ?? {};
const selectedSlide = useMemo(
() => slides[selectedPosition] ?? slides[0] ?? {},
[slides, selectedPosition],
);
const selectedSlideIndex = asNumber(selectedSlide.index, selectedPosition + 1);
const title = asString(artifact.title) || "Presentation";

Expand All @@ -77,7 +80,11 @@ export function PresentationCursorCanvas({
if (slides.some((slide) => asNumber(slide.index, 1) === selectedIndex)) {
return;
}
setSelectedIndex(asNumber(slides[0]?.index, 1));
const firstIndex = asNumber(slides[0]?.index, 1);
if (firstIndex !== selectedIndex) {
// eslint-disable-next-line react-hooks/set-state-in-effect -- sync when slide set changes and current index is stale
setSelectedIndex(firstIndex);
}
}, [selectedIndex, slides]);

const goPrevious = useCallback(() => {
Expand Down Expand Up @@ -151,6 +158,7 @@ export function PresentationCursorCanvas({
>
<span style={styles.thumbnailNumber}>{slideIndex}</span>
{thumbnail ? (
// eslint-disable-next-line @next/next/no-img-element -- office thumbnail, not a Next.js route image
<img
alt=""
src={thumbnail}
Expand Down Expand Up @@ -430,7 +438,8 @@ function useLoadedCanvasImages(
const next = new Map<string, CanvasImageSource>();
const entries = Object.entries(media);
if (entries.length === 0) {
setImages(next);
// eslint-disable-next-line react-hooks/set-state-in-effect -- sync when media set is empty
if (!cancelled) setImages(next);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function SlideshowOverlay({
const frameSize = useElementSize(frameRef);
const didEnterFullscreenRef = useRef(typeof document !== "undefined" && document.fullscreenElement != null);
const selectedIndex = Math.min(activeSlideIndex, Math.max(0, slides.length - 1));
const slide = slides[selectedIndex] ?? {};
const slide = useMemo(() => slides[selectedIndex] ?? {}, [slides, selectedIndex]);
const frame = getSlideFrameSize(slide, layouts);
const fit = computePresentationFit(frameSize, frame, { padding: 0 });
const canvasWidth = Math.max(1, fit.width);
Expand All @@ -396,11 +396,8 @@ function SlideshowOverlay({
const showSpeakerNotesLabel = labels.showSpeakerNotes ?? speakerNotesLabel;
const hideSpeakerNotesLabel = labels.hideSpeakerNotes ?? speakerNotesLabel;

useEffect(() => {
if (!hasSpeakerNotes) {
setShowSpeakerNotes(false);
}
}, [hasSpeakerNotes]);
// When there are no speaker notes, the panel cannot be shown.
const canShowSpeakerNotes = hasSpeakerNotes && showSpeakerNotes;

const goPrevious = useCallback(() => {
setActiveSlideIndex(Math.max(0, selectedIndex - 1));
Expand Down Expand Up @@ -508,7 +505,7 @@ function SlideshowOverlay({
{hasSpeakerNotes ? (
<button
aria-label={showSpeakerNotes ? hideSpeakerNotesLabel : showSpeakerNotesLabel}
aria-pressed={showSpeakerNotes}
aria-pressed={canShowSpeakerNotes}
className={styles.slideshowIconButton}
data-testid="presentation-speaker-notes-toggle"
onClick={() => setShowSpeakerNotes((isOpen) => !isOpen)}
Expand All @@ -521,7 +518,7 @@ function SlideshowOverlay({
<PresentationIcon name="close" />
</button>
</div>
<div className={styles.slideshowPresenterLayout} data-notes-open={showSpeakerNotes && hasSpeakerNotes}>
<div className={styles.slideshowPresenterLayout} data-notes-open={canShowSpeakerNotes}>
<button
aria-label={labels.nextSlide}
className={styles.slideshowFrame}
Expand All @@ -540,7 +537,7 @@ function SlideshowOverlay({
width={canvasWidth}
/>
</button>
{showSpeakerNotes && hasSpeakerNotes ? (
{canShowSpeakerNotes ? (
<aside className={styles.slideshowNotesPanel} data-testid="presentation-speaker-notes">
<div className={styles.slideshowNotesTitle}>{speakerNotesLabel}</div>
<pre className={styles.slideshowNotesText}>{speakerNotes}</pre>
Expand Down
14 changes: 5 additions & 9 deletions packages/office-render/src/shared/office-color-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ function modulateSaturation(
const saturation = lightness > 0.5
? delta / (2 - max - min)
: delta / (max + min);
let hue = 0;
if (max === channels[0]) {
hue = (channels[1]! - channels[2]!) / delta + (channels[1]! < channels[2]! ? 6 : 0);
} else if (max === channels[1]) {
hue = (channels[2]! - channels[0]!) / delta + 2;
} else {
hue = (channels[0]! - channels[1]!) / delta + 4;
}
hue /= 6;
const hue = (max === channels[0]
? (channels[1]! - channels[2]!) / delta + (channels[1]! < channels[2]! ? 6 : 0)
: max === channels[1]
? (channels[2]! - channels[0]!) / delta + 2
: (channels[0]! - channels[1]!) / delta + 4) / 6;

return hslToRgb(hue, Math.max(0, Math.min(1, saturation * factor)), lightness);
}
Expand Down
1 change: 1 addition & 0 deletions packages/office/src/cursor-canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ function officeRenderPresentationRuntimeInline(): string {
`Missing @autodev/office-render Cursor runtime at ${runtimePath}. ` +
"Run `npm --prefix packages/office-render run build` before generating a PPTX Cursor Canvas. " +
message,
{ cause: error },
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/docs/feature-tree-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const {
} = resolveFeatureTreeGeneratorRuntime(featureTreeGeneratorModule as FeatureTreeGeneratorModuleShape);
const { INFERRED_GROUP_ID, buildApiLookupKey, normalizeSurfaceMetadata } = featureSurfaceMetadata;

type GenerateFeatureTreeArtifacts = (options: {
type _GenerateFeatureTreeArtifacts = (options: {
repoRoot: string;
scanRoot?: string;
metadata?: FeatureMetadata | null;
Expand All @@ -56,7 +56,7 @@ type GenerateFeatureTreeArtifacts = (options: {
apisCount: number;
}>;

type FeatureTreePreflightResult = {
type _FeatureTreePreflightResult = {
repoRoot: string;
selectedScanRoot: string;
frameworksDetected: string[];
Expand Down Expand Up @@ -1298,7 +1298,7 @@ export async function main(argv: string[] = process.argv.slice(2)): Promise<void
const metadata = loadPersistedFeatureMetadata(existingFeatureTree, existingSurfaceIndex);
const apiFeatures = extractApiFeatures(apiContract);
const tree = buildFeatureTree(routes, apiFeatures);
const surfaceIndex = buildFeatureSurfaceIndex(routes, apiFeatures, nextjsApis, rustApis, metadata);
void buildFeatureSurfaceIndex(routes, apiFeatures, nextjsApis, rustApis, metadata);

if (args.has("--mermaid")) {
console.log(renderMermaid(tree));
Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/framework-feature-tree-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ function extractSpringControllerRoutes(repoRoot: string): SpringControllerRoute[
const classBasePath = classMappings[0]?.path ?? "";

const methodRegex =
/((?:@\w+(?:\((?:[^()]|\([^()]*\))*\))?\s*)+)\s*public\s+[A-Za-z0-9_<>,?.\[\]\s]+\s+(\w+)\s*\((?:[^()]|\([^()]*\))*\)\s*(?:throws\s+[A-Za-z0-9_<>,?.\[\]\s]+)?\s*\{/gs;
/((?:@\w+(?:\((?:[^()]|\([^()]*\))*\))?\s*)+)\s*public\s+[A-Za-z0-9_<>,?.[\]\s]+\s+(\w+)\s*\((?:[^()]|\([^()]*\))*\)\s*(?:throws\s+[A-Za-z0-9_<>,?.[\]\s]+)?\s*\{/gs;
let match: RegExpExecArray | null;

while ((match = methodRegex.exec(content)) !== null) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/harness/analyze-search-tool-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const FAMILY_KEYS: SearchToolFamily[] = [
"custom_glob",
];

const PATTERN_CATEGORY_KEYS: SearchPatternCategory[] = [
const _PATTERN_CATEGORY_KEYS: SearchPatternCategory[] = [
"path_like",
"symbol_like",
"natural_language",
Expand Down Expand Up @@ -654,7 +654,7 @@ function collectJsonlFiles(rootPath: string, maxFiles?: number): string[] {
continue;
}

let entries: fs.Dirent[] = [];
let entries: fs.Dirent[];
try {
entries = fs.readdirSync(current, { withFileTypes: true });
} catch {
Expand Down
4 changes: 2 additions & 2 deletions scripts/mcp-http-proxy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ proxy.setRequestHandler(GetPromptRequestSchema, async (request) => {
});

let upstreamTransport;
let stdioTransport;
let stdioTransport; // eslint-disable-line prefer-const -- may be undefined until connect()
let shuttingDown = false;

async function shutdown(reason) {
Expand All @@ -101,7 +101,7 @@ function formatError(err) {

// Connect to upstream first, then start stdio server
try {
upstreamTransport = new StreamableHTTPClientTransport(new URL(normalizedEndpoint), {
upstreamTransport = new StreamableHTTPClientTransport(new globalThis.URL(normalizedEndpoint), {
requestInit: headers ? { headers } : undefined,
});
await upstreamClient.connect(upstreamTransport);
Expand Down
2 changes: 1 addition & 1 deletion tools/hook-runtime/src/specialist-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ async function callReviewProvider(params: {
provider: fallbackProvider,
});
if (validate && !validate(raw)) {
throw new Error(`Automatic review specialist returned an invalid verdict: ${raw || "(empty response)"}`);
throw new Error(`Automatic review specialist returned an invalid verdict: ${raw || "(empty response)"}`, { cause: primaryError });
}
return raw;
} catch (fallbackError) {
Expand Down
Loading