fix(ui): a plan belongs to the app, not to the screen that started it
Found by counting the install flow's clicks in the running app. Two bugs, neither of which
any test would have caught, and the first of which made the whole flow a dead end.
**`plan_resolve` succeeded and the preview rendered nowhere.** `PdPlanPanel` was owned by
`PdPackages`, so a plan started from the Search dock bay resolved into a screen that does
not render it — the command ran, the flow parked in `AppState`, and the user saw the search
results unchanged. The panel now lives in the shell, which is also where it belongs
conceptually: there is one plan at a time (`PD-RES-003`), it can be started from Updates or
from Search, and which tab happens to be showing is not part of that.
**Every search result offered [Add], including packages already installed.** The chips read
`useEnvStore.packages`, which only `PdPackages` ever loaded — so a user who opened Search
first got no chips at all and could queue something they already had, which is exactly the
mistake DATA-FLOW §4 added them to prevent. Search now ensures the load, and the store's
existing `loadedFor` guard makes that free when Installed has already run.
Verified the way they were found: **install-one is 4 clicks** — Search (autofocused) → Add →
Install → Confirm — the queue holds `httpx`, `requests` shows `INSTALLED` and no [Add], the
preview groups `new-install` and `new-dependency`, `Confirm (3 changes)` starts execution,
and the intent that crosses is `{ intent: "install", specs: ["httpx"] }`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4890985e2
commit
411bb0e7b2
3 files changed
+35
-20
No files matched your search
+21
-3
@@ -9,9 +9,10 @@ import { PdStatusLine } from '@/components/PdStatusLine'
|
||||
import type { NavKey } from '@/components/nav'
|
||||
import { PdEnvironments } from '@/screens/PdEnvironments'
|
||||
import { PdPackages } from '@/screens/PdPackages'
|
||||
import { PdPlanPanel } from '@/screens/PdPlanPanel'
|
||||
import { PdSearch } from '@/screens/PdSearch'
|
||||
import { PdSettings } from '@/screens/PdSettings'
|
||||
import { useEnvStore, useLegalStore, useUiStore } from '@/stores'
|
||||
import { useEnvStore, useLegalStore, usePlanStore, useUiStore } from '@/stores'
|
||||
|
||||
/**
|
||||
* Which screen each tab shows. A lookup rather than a ternary chain: the chain's last branch was a
|
||||
@@ -39,6 +40,13 @@ export function App() {
|
||||
const accepted = useLegalStore((s) => s.accepted)
|
||||
const checkConsent = useLegalStore((s) => s.check)
|
||||
const selected = useEnvStore((s) => s.selected)
|
||||
const loadPackages = useEnvStore((s) => s.loadPackages)
|
||||
const loadOutdated = useEnvStore((s) => s.loadOutdated)
|
||||
const clearSelection = useEnvStore((s) => s.clearSelection)
|
||||
// A plan belongs to the app, not to a screen: there is one at a time (PD-RES-003) and it can be
|
||||
// started from Updates *or* from the Search dock bay. Owning it here is what stops an install
|
||||
// resolving into nowhere because the tab that renders the preview is not the tab you are on.
|
||||
const planPhase = usePlanStore((s) => s.phase)
|
||||
|
||||
useEffect(() => {
|
||||
void checkConsent()
|
||||
@@ -95,11 +103,21 @@ export function App() {
|
||||
can observe, and nesting one inside an already-scrolling <main> gives two scrollbars
|
||||
and an outer one whose content is already the virtualizer's full height. */}
|
||||
<main className="flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
{SCREENS[nav] ?? (
|
||||
{planPhase !== 'idle' ? (
|
||||
<PdPlanPanel
|
||||
onFinished={() => {
|
||||
// The environment changed under whatever screen is behind this, so re-read it
|
||||
// rather than showing the versions from before the run.
|
||||
clearSelection()
|
||||
void loadPackages()
|
||||
void loadOutdated()
|
||||
}}
|
||||
/>
|
||||
) : (SCREENS[nav] ?? (
|
||||
<p className="h-full overflow-auto p-6 font-mono text-text-dim">
|
||||
{`▸ ${t(`nav.${nav}`)}`}
|
||||
</p>
|
||||
)}
|
||||
))}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import { useTranslation } from 'react-i18next'
|
||||
import { PdEmptyState } from '@/components/PdEmptyState'
|
||||
import { PdErrorRow } from '@/components/PdErrorRow'
|
||||
import { PdPackageTable } from '@/components/PdPackageTable'
|
||||
import { PdPlanPanel } from '@/screens/PdPlanPanel'
|
||||
import { outdatedOnly, selectableForUpdate } from '@/screens/rows'
|
||||
import { useEnvStore, usePlanStore } from '@/stores'
|
||||
|
||||
@@ -45,7 +44,6 @@ export function PdPackages({ mode }: PdPackagesProps) {
|
||||
const selectAll = useEnvStore((s) => s.selectAll)
|
||||
const clearSelection = useEnvStore((s) => s.clearSelection)
|
||||
const togglePin = useEnvStore((s) => s.togglePin)
|
||||
const planPhase = usePlanStore((s) => s.phase)
|
||||
const planResolve = usePlanStore((s) => s.resolve)
|
||||
|
||||
// The row's handler must return void. Wrapped here rather than in the store so `togglePin` stays
|
||||
@@ -71,21 +69,6 @@ export function PdPackages({ mode }: PdPackagesProps) {
|
||||
const { selectable, pinnedExcluded } = selectableForUpdate(visible)
|
||||
const title = mode === 'updates' ? t('packages.updatesTitle') : t('packages.installedTitle')
|
||||
|
||||
// The preview *replaces* the table (UI-SPEC §4) rather than sitting beside it: one plan, one
|
||||
// screen, and nothing to mis-click while a decision is pending.
|
||||
if (planPhase !== 'idle') {
|
||||
return (
|
||||
<PdPlanPanel
|
||||
onFinished={() => {
|
||||
// The environment changed under the table, so re-read it rather than showing the
|
||||
// versions from before the run.
|
||||
clearSelection()
|
||||
void loadPackages()
|
||||
void loadOutdated()
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (selected === null) {
|
||||
return (
|
||||
|
||||
@@ -46,6 +46,9 @@ export function PdSearch() {
|
||||
const packages = useEnvStore((s) => s.packages)
|
||||
const rows = useEnvStore((s) => s.rows)
|
||||
const envSelected = useEnvStore((s) => s.selected)
|
||||
const loadedFor = useEnvStore((s) => s.loadedFor)
|
||||
const loadPackages = useEnvStore((s) => s.loadPackages)
|
||||
const loadOutdated = useEnvStore((s) => s.loadOutdated)
|
||||
const planResolve = usePlanStore((s) => s.resolve)
|
||||
|
||||
const envRow = rows.find((r) => r.interpreter === envSelected)
|
||||
@@ -56,6 +59,17 @@ export function PdSearch() {
|
||||
field.current?.focus()
|
||||
}, [])
|
||||
|
||||
// DATA-FLOW §4's installed chips need the installed set, and a user who opens Search first has
|
||||
// never loaded it — the chips then silently never appear and every result offers [Add],
|
||||
// including packages they already have. The store's own guard makes this free when Installed
|
||||
// has already run.
|
||||
useEffect(() => {
|
||||
if (envSelected !== null && loadedFor !== envSelected) {
|
||||
void loadPackages()
|
||||
void loadOutdated()
|
||||
}
|
||||
}, [envSelected, loadedFor, loadPackages, loadOutdated])
|
||||
|
||||
// What is already installed, so a result can say so instead of offering [Add].
|
||||
const installed = useMemo(
|
||||
() => new Map(packages.map((p) => [p.name, p])),
|
||||
|
||||
Reference in new issue
Block a user