Skip to content

select any dimension#663

Open
lazarusA wants to merge 8 commits into
mainfrom
la/sliders_again
Open

select any dimension#663
lazarusA wants to merge 8 commits into
mainfrom
la/sliders_again

Conversation

@lazarusA

Copy link
Copy Markdown
Member

when this is done it should close #529 #632 #625

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a multi-dimensional slicing and configuration UI, adding components like DimConfigBar, DimConfigEntry, and DimSlicer to manage dimensions, axes, and slice selections, while integrating them into MetaDimSelector and updating ZarrLoaderLRU.ts to handle uncached dimension data. Feedback on these changes highlights a critical compilation error due to an incorrect import path in DimConfigEntry.tsx, an invalid Tailwind CSS class in DimSlicer.tsx, and a potential out-of-bounds array access. Additionally, the reviewer recommended using safer React keys in MetaDimSelector.tsx, removing debug console.log statements in Variables.tsx, and cleaning up unused components (DimSlicerAxisToggle and DimSlicerModeToggle).

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +3 to +7
import {
Axis,
SelectionMode,
SliceSelectionState,
} from '@/components/DimSlicer';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The import path for DimSlicer is incorrect. It is imported from '@/components/DimSlicer', but the actual path is '@/components/ui/DimSlicer'. This will cause a compilation/build error.

Suggested change
import {
Axis,
SelectionMode,
SliceSelectionState,
} from '@/components/DimSlicer';
import {
Axis,
SelectionMode,
SliceSelectionState,
} from '@/components/ui/DimSlicer';

Comment on lines +72 to +75
const MODE_ACCENT: Record<SelectionMode, string> = {
scalar: 'border-l-black-700',
slice: 'border-l-pink-400',
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Tailwind CSS class border-l-black-700 is invalid because the color black does not have numeric shades (like 700) in Tailwind's default color palette. This will result in no border color being applied. Consider using a valid color like slate-700 or neutral-700.

Suggested change
const MODE_ACCENT: Record<SelectionMode, string> = {
scalar: 'border-l-black-700',
slice: 'border-l-pink-400',
};
const MODE_ACCENT: Record<SelectionMode, string> = {
scalar: 'border-l-slate-700',
slice: 'border-l-pink-400',
};

{showSliders && (
<div className="space-y-2">
{DIMS.map((dim: typeof DIMS[0], i: number) => (
<div key={dimNames[i]} className="rounded-lg bg-muted/20 p-2">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using dimNames[i] as a React key can lead to duplicate or undefined keys if dimNames is shorter than DIMS or undefined. It is safer and more robust to use dim.name as the key, which is guaranteed to be defined and unique.

Suggested change
<div key={dimNames[i]} className="rounded-lg bg-muted/20 p-2">
<div key={dim.name} className="rounded-lg bg-muted/20 p-2">

Comment on lines +180 to +183
const formattedValue = (index: number) =>
values && effectiveDimSize > 0 && index < values.length
? String(formatValue ? formatValue(values[index]) : values[index].toString())
: String(index);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For defensive programming, we should ensure that index is non-negative before accessing values[index]. If index is negative, it could result in an out-of-bounds access and potentially throw a runtime error when calling .toString().

Suggested change
const formattedValue = (index: number) =>
values && effectiveDimSize > 0 && index < values.length
? String(formatValue ? formatValue(values[index]) : values[index].toString())
: String(index);
const formattedValue = (index: number) =>
values && effectiveDimSize > 0 && index >= 0 && index < values.length
? String(formatValue ? formatValue(values[index]) : values[index].toString())
: String(index);

Comment on lines +327 to +328
// future: persist sels/axes to store
console.log('Applied slices', sels, axes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid leaving debug console.log statements in production code. Since this is a placeholder for future state persistence, consider replacing it with a TODO comment or implementing the state update.

Suggested change
// future: persist sels/axes to store
console.log('Applied slices', sels, axes);
// TODO: persist sels/axes to store

onApply={(sels, axes) => {
setShowMeta(false);
setOpenVariables(false);
console.log('Applied slices', sels, axes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid leaving debug console.log statements in production code. Consider replacing it with a TODO comment.

Suggested change
console.log('Applied slices', sels, axes);
// TODO: persist sels/axes to store

Comment on lines +1 to +6
'use client';
import React from 'react';
import { Button } from '@/components/ui/button';
import { ButtonGroup } from '@/components/ui/button-group';

export type Axis = 'x' | 'y' | 'z' | 'c';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The component DimSlicerAxisToggle is defined but never imported or used anywhere in the codebase. If this is dead code, please remove it to keep the codebase clean and maintainable.

Comment on lines +1 to +6
'use client';
import React, { useEffect, useRef, useState } from 'react';
import { Button } from '@/components/ui/button';
import { ButtonGroup } from '@/components/ui/button-group';

export type SelectionMode = 'scalar' | 'slice';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The component DimSlicerModeToggle is defined but never imported or used anywhere in the codebase. If this is dead code, please remove it to keep the codebase clean and maintainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a robust way to determine dimensions and shape

1 participant