Files
backnotprop__plannotator/packages/review-editor/utils/resolvePanelView.test.ts
Michael Ramos eb34960da9 fix(review): remember the last-used panel view; full-width toggle and cleaner panel chrome (#1273)
* fix(review): remember the last-used panel view across sessions

- Add cookie-only reviewPanelViewLastUsed config (sections | tree, never
  commits); the header toggle records it and new sessions resolve
  session state, then last-used, then the persisted reviewPanelView.
  Explicit Settings/setup-dialog writes through the reviewView setters
  sync last-used so a stale memo cannot shadow them.
- Wire the FileTree fallback PanelViewToggle to the real panel-view
  selection and route Tree clicks through the shared select funnel
  instead of rendering a hardcoded, no-op tree segment.
- Mark the review-setup-seen cookie when the first-run reset runs, not
  only on the Got it click, so closing the tab without dismissing no
  longer re-stomps preferences every session.

* fix(review): full-width panel toggle, relocated tree controls, click-to-copy diff count

- Give the Git status | Tree | Commits toggle the entire top row in all
  three left panels; segments stretch to fill the row width.
- Move the controls that shared that row (staged count, search,
  collapse-all, hide-viewed, viewed counter) into a shared
  PanelControlsRow rendered below the All files entry, directly above
  the file list; the Commits panel's loaded-commit count moves to its
  own sub-row.
- Replace the footer Copy button with the diff count itself as the copy
  trigger (shared CopyDiffFooter): a keyboard-reachable button with the
  "click to copy the entire diff set" tooltip and transient
  Copied/Failed feedback in the old button's slot.
- Add a tooltip to the file-row stage button using the same Tooltip
  mechanism as the viewed control ("Stage file (git add)").

* fix(review): put Tree first in the panel view toggle

* fix(review): resolve effective panel view for the toggle; keep self-heal off the last-used memo

- Add resolvePanelView() and pass the EFFECTIVE view to FileTree so a
  latent sections/commits selection the session cannot offer highlights
  Tree instead of a hidden or wrong segment; allFilesOrder reuses it.
  Unit test covers the no-segment and wrong-segment cases.
- setReviewPanelView() gains { recordLastUsed?: boolean } (default
  true); the App self-heal passes false so repairing a conflicted
  persisted pair no longer overwrites the user's last-used memo.
- Update the AGENTS.md since-base section to the new toggle semantics
  (last-used memo, resolution order, setter sync, one-time first-run).
- Hardening: fold the diff counts into the copy button's aria-label,
  skip the tooltip while the copy button is disabled (hover never fires
  on a disabled native button in several browsers), let toggle segments
  shrink (min-w-0 + truncate), and rework the config test onto a fresh
  ConfigStoreForTest instead of resolving the singleton against a
  throwaway backend.
2026-08-11 23:54:22 -07:00

34 lines
1.3 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { resolvePanelView } from './resolvePanelView';
describe('resolvePanelView', () => {
test('a sections selection on a session without sections resolves to tree', () => {
// The no-segment-highlighted bug: sections memo on a repo with no
// resolvable base (sections gone, commits offered) must light Tree,
// not a hidden Git status segment.
expect(
resolvePanelView('sections', { sectionsAvailable: false, commitsCapable: true }),
).toBe('tree');
// Sections merely unavailable for the active diff (classic diff default):
// the tree renders, so Tree must be the highlighted segment.
expect(
resolvePanelView('sections', { sectionsAvailable: false, commitsCapable: false }),
).toBe('tree');
});
test('sections selected and available resolves to sections', () => {
expect(
resolvePanelView('sections', { sectionsAvailable: true, commitsCapable: true }),
).toBe('sections');
});
test('commits resolves to commits only when the session offers it', () => {
expect(
resolvePanelView('commits', { sectionsAvailable: true, commitsCapable: true }),
).toBe('commits');
expect(
resolvePanelView('commits', { sectionsAvailable: true, commitsCapable: false }),
).toBe('tree');
});
});