select any dimension#663
Conversation
There was a problem hiding this comment.
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.
| import { | ||
| Axis, | ||
| SelectionMode, | ||
| SliceSelectionState, | ||
| } from '@/components/DimSlicer'; |
There was a problem hiding this comment.
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.
| import { | |
| Axis, | |
| SelectionMode, | |
| SliceSelectionState, | |
| } from '@/components/DimSlicer'; | |
| import { | |
| Axis, | |
| SelectionMode, | |
| SliceSelectionState, | |
| } from '@/components/ui/DimSlicer'; |
| const MODE_ACCENT: Record<SelectionMode, string> = { | ||
| scalar: 'border-l-black-700', | ||
| slice: 'border-l-pink-400', | ||
| }; |
There was a problem hiding this comment.
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.
| 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"> |
There was a problem hiding this comment.
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.
| <div key={dimNames[i]} className="rounded-lg bg-muted/20 p-2"> | |
| <div key={dim.name} className="rounded-lg bg-muted/20 p-2"> |
| const formattedValue = (index: number) => | ||
| values && effectiveDimSize > 0 && index < values.length | ||
| ? String(formatValue ? formatValue(values[index]) : values[index].toString()) | ||
| : String(index); |
There was a problem hiding this comment.
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().
| 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); |
| // future: persist sels/axes to store | ||
| console.log('Applied slices', sels, axes); |
There was a problem hiding this comment.
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.
| // 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); |
| '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'; |
| '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'; |
when this is done it should close #529 #632 #625