Files
OpenHands/__tests__/utils
Robert Brennanandopenhands 0068b5f465 chore: address post-merge feedback on #284 + small cleanups (#288)
Three of the four post-merge review comments on #284 are still real:

- `src/utils/file-priority.ts` — `pathDepth` used `split('/').length - 1`
  without filtering empty segments, so a leading slash, trailing slash
  or double slash silently inflated the computed depth and dropped a
  top-level file behind genuinely-nested ones in the Files tab pill row.
  Aligned with the `.filter(Boolean)` convention already used by
  `buildFileTree`, with regression tests for both the leading-slash and
  double-slash cases.

- `src/utils/conversation-local-storage.ts` — `filesTabContentViewMode`
  is typed `ViewMode` ("rich" | "plain") but came from
  `JSON.parse(localStorage)`, so a corrupt / hand-edited value would
  leak past TypeScript into the UI. `sanitizeStoredState` now drops
  unknown values so the typed default re-applies, with a test that
  asserts `{ filesTabContentViewMode: 'fancy' }` falls back to 'rich'.

- `src/routes/files-tab.tsx` — the toolbar refresh button used
  `aria-label={t(I18nKey.COMMON$FILES)}` which translates to just
  "Files". Screen-reader users would hear the button as
  "Files button" instead of "Refresh files". Added a dedicated
  `FILES$REFRESH` translation ("Refresh files" + the 14 sibling
  locales), wired the button's aria-label and title to it, and updated
  the existing test to assert the new label.

The fourth comment (id-less events re-processed on every effect run in
`use-auto-refresh-files-on-edit`) was already addressed in a follow-up
commit via a `WeakSet<OHEvent>` keyed by object identity, so no change
needed there.

Also: `src/components/shared/buttons/refresh-button.tsx` and its
companion `src/icons/refresh.svg` had zero references in the codebase
(the only refresh button left in use is the inline one in
`routes/files-tab.tsx` with `u-refresh.svg`). Deleted.

Co-authored-by: openhands <openhands@all-hands.dev>
2026-05-10 19:57:28 -07:00
..