From 50e249d5d204d1b12982e13ea12b632ec22a20f9 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 8 Oct 2026 10:47:52 -0400 Subject: [PATCH 1/7] feat(walkthrough): open on an overview page and page through stops --- .../session/ChangesWalkthroughSheet.test.tsx | 65 +++++++-- .../session/ChangesWalkthroughSheet.tsx | 127 ++++++++++-------- 2 files changed, 127 insertions(+), 65 deletions(-) diff --git a/frontend/src/components/session/ChangesWalkthroughSheet.test.tsx b/frontend/src/components/session/ChangesWalkthroughSheet.test.tsx index 221a26cf..ebf7c931 100644 --- a/frontend/src/components/session/ChangesWalkthroughSheet.test.tsx +++ b/frontend/src/components/session/ChangesWalkthroughSheet.test.tsx @@ -79,7 +79,7 @@ describe('ChangesWalkthroughSheet', () => { vi.clearAllMocks() }) - it('generates a walkthrough and renders the summary and first stop', async () => { + it('generates a walkthrough and opens on the overview page', async () => { const user = userEvent.setup() let generated = false mocks.getChangeWalkthrough.mockImplementation(async () => @@ -98,33 +98,73 @@ describe('ChangesWalkthroughSheet', () => { expect(mocks.generateChangeWalkthrough).toHaveBeenCalledWith('ses_1', {}) }) expect(await screen.findByText('This change adds a greeting.')).toBeInTheDocument() - expect(screen.getByText('Stop 1 of 2')).toBeInTheDocument() - expect(screen.getByText('src/greet.ts')).toBeInTheDocument() - expect(screen.getByText('const a = 2')).toBeInTheDocument() - expect(screen.queryByText('src/main.ts')).not.toBeInTheDocument() + expect(screen.getByText('Overview')).toBeInTheDocument() + expect(screen.getByRole('button', { name: '1. Add the greeting' })).toBeInTheDocument() + expect(screen.getByRole('button', { name: '2. Wire it up' })).toBeInTheDocument() + expect(screen.queryByText('src/greet.ts')).not.toBeInTheDocument() expect(screen.getByText('assets/logo.png — binary file')).toBeInTheDocument() }) - it('moves through the stops with the navigator in order', async () => { + it('opens a stop from the overview list without the summary or list', async () => { const user = userEvent.setup() mocks.getChangeWalkthrough.mockResolvedValue(state()) renderSheet() - expect(await screen.findByText('Stop 1 of 2')).toBeInTheDocument() - expect(screen.getByText('src/greet.ts')).toBeInTheDocument() + await user.click(await screen.findByRole('button', { name: '2. Wire it up' })) + + expect(await screen.findByText('2 of 2')).toBeInTheDocument() + expect(screen.getByText('src/main.ts')).toBeInTheDocument() + expect(screen.queryByText('This change adds a greeting.')).not.toBeInTheDocument() + expect(screen.queryByRole('button', { name: '1. Add the greeting' })).not.toBeInTheDocument() + }) + + it('jumps between pages from the header dropdown', async () => { + const user = userEvent.setup() + mocks.getChangeWalkthrough.mockResolvedValue(state()) + renderSheet() + + await user.click(await screen.findByRole('button', { name: '1. Add the greeting' })) + expect(await screen.findByText('1 of 2')).toBeInTheDocument() + + await user.click(screen.getByRole('button', { name: 'Jump to page' })) + await user.click(await screen.findByRole('menuitemradio', { name: '2. Wire it up' })) + expect(await screen.findByText('2 of 2')).toBeInTheDocument() + expect(screen.getByText('src/main.ts')).toBeInTheDocument() + + await user.click(screen.getByRole('button', { name: 'Jump to page' })) + await user.click(await screen.findByRole('menuitemradio', { name: 'Overview' })) + expect(await screen.findByText('This change adds a greeting.')).toBeInTheDocument() + }) + + it('moves through the overview and stops with the navigator in order', async () => { + const user = userEvent.setup() + mocks.getChangeWalkthrough.mockResolvedValue(state()) + renderSheet() + + expect(await screen.findByText('Overview')).toBeInTheDocument() expect(screen.getByRole('button', { name: /previous/i })).toBeDisabled() await user.click(screen.getByRole('button', { name: /next/i })) - expect(await screen.findByText('Stop 2 of 2')).toBeInTheDocument() + expect(await screen.findByText('1 of 2')).toBeInTheDocument() + expect(screen.getByText('src/greet.ts')).toBeInTheDocument() + expect(screen.getByText('const a = 2')).toBeInTheDocument() + expect(screen.queryByText('This change adds a greeting.')).not.toBeInTheDocument() + + await user.click(screen.getByRole('button', { name: /next/i })) + + expect(await screen.findByText('2 of 2')).toBeInTheDocument() expect(screen.getByText('src/main.ts')).toBeInTheDocument() expect(screen.queryByText('src/greet.ts')).not.toBeInTheDocument() expect(screen.getByText('truncated')).toBeInTheDocument() expect(screen.getByRole('button', { name: /next/i })).toBeDisabled() await user.click(screen.getByRole('button', { name: /previous/i })) + expect(await screen.findByText('1 of 2')).toBeInTheDocument() - expect(await screen.findByText('Stop 1 of 2')).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: /previous/i })) + expect(await screen.findByText('Overview')).toBeInTheDocument() + expect(screen.getByText('This change adds a greeting.')).toBeInTheDocument() }) it('shows the stale warning and regenerates', async () => { @@ -150,7 +190,7 @@ describe('ChangesWalkthroughSheet', () => { mocks.generateChangeWalkthrough.mockResolvedValue(state()) renderSheet() - await screen.findByText('Stop 1 of 2') + await screen.findByText('Overview') await user.click(screen.getByRole('button', { name: 'Regenerate walkthrough' })) await waitFor(() => { @@ -237,9 +277,12 @@ describe('ChangesWalkthroughSheet', () => { }, }), ) + const user = userEvent.setup() const { container } = renderSheet() expect(await screen.findByText(/Summary/)).toBeInTheDocument() + expect(container.querySelector('iframe')).toBeNull() + await user.click(screen.getByRole('button', { name: /next/i })) expect(await screen.findByText(/Explanation/)).toBeInTheDocument() expect(container.querySelector('iframe')).toBeNull() expect(container.querySelector('script')).toBeNull() diff --git a/frontend/src/components/session/ChangesWalkthroughSheet.tsx b/frontend/src/components/session/ChangesWalkthroughSheet.tsx index 44ac695b..00af3202 100644 --- a/frontend/src/components/session/ChangesWalkthroughSheet.tsx +++ b/frontend/src/components/session/ChangesWalkthroughSheet.tsx @@ -1,14 +1,21 @@ import { createContext, memo, useCallback, useContext, useEffect, useRef, useState } from 'react' import type { ReactNode, RefObject } from 'react' -import { ChevronLeft, ChevronRight, Loader2, RefreshCw } from 'lucide-react' +import { ChevronDown, ChevronLeft, ChevronRight, Loader2, RefreshCw } from 'lucide-react' import { SideDrawer, SideDrawerHeader } from '@/components/ui/side-drawer' import { Button } from '@/components/ui/button' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' import { Badge } from '@/components/ui/badge' import { DiffLines } from '@/components/file-browser/DiffLines' import { ScheduleRunMarkdown } from '@/components/schedules/ScheduleRunMarkdown' import { useChangeWalkthrough, useGenerateChangeWalkthrough } from '@/hooks/useChangeWalkthrough' import { GIT_STATUS_COLORS, GIT_STATUS_LABELS } from '@/lib/git-status-styles' -import { cn } from '@/lib/utils' import { WalkthroughOmittedFileSchema } from '@opencode-manager/shared/schemas' import type { ChangeWalkthrough, @@ -80,11 +87,11 @@ interface ChangesWalkthroughContextValue { generate: () => void regenerate: () => void stops: WalkthroughStop[] - stopIndex: number + stopIndex: number | null selectedStop: WalkthroughStop | null selectedHunks: WalkthroughHunk[] - selectStop: (index: number) => void - detailRef: RefObject + selectStop: (index: number | null) => void + scrollRef: RefObject } const ChangesWalkthroughContext = createContext(null) @@ -106,8 +113,8 @@ export function ChangesWalkthroughProvider({ sessionId, active, children }: Chan const stateQuery = useChangeWalkthrough(sessionId, active) const generate = useGenerateChangeWalkthrough(sessionId) const resetGenerate = generate.reset - const [stopIndex, setStopIndex] = useState(0) - const detailRef = useRef(null) + const [stopIndex, setStopIndex] = useState(null) + const scrollRef = useRef(null) const state = stateQuery.data const walkthrough = state?.walkthrough ?? null @@ -121,20 +128,20 @@ export function ChangesWalkthroughProvider({ sessionId, active, children }: Chan }, [active, sessionId, resetGenerate]) useEffect(() => { - setStopIndex(0) + setStopIndex(null) }, [active, sessionId, walkthrough?.createdAt]) const hunksById = new Map(walkthrough?.hunks.map((hunk) => [hunk.id, hunk]) ?? []) const stops = walkthrough?.stops ?? [] - const clampedIndex = stops.length > 0 ? Math.min(stopIndex, stops.length - 1) : 0 - const selectedStop = stops[clampedIndex] ?? null + const clampedIndex = stopIndex === null || stops.length === 0 ? null : Math.min(stopIndex, stops.length - 1) + const selectedStop = clampedIndex === null ? null : stops[clampedIndex] ?? null const selectedHunks = (selectedStop?.hunkIds ?? []) .map((id) => hunksById.get(id)) .filter((hunk): hunk is WalkthroughHunk => hunk !== undefined) - const selectStop = useCallback((index: number) => { + const selectStop = useCallback((index: number | null) => { setStopIndex(index) - detailRef.current?.scrollIntoView?.({ block: 'start', behavior: 'smooth' }) + scrollRef.current?.scrollTo?.({ top: 0 }) }, []) const value: ChangesWalkthroughContextValue = { @@ -151,13 +158,13 @@ export function ChangesWalkthroughProvider({ sessionId, active, children }: Chan selectedStop, selectedHunks, selectStop, - detailRef, + scrollRef, } return {children} } -/** Previous/next stop controls for the walkthrough chrome; renders nothing until a walkthrough has stops. */ +/** Previous/next page controls (overview, then each stop) for the walkthrough chrome; renders nothing until a walkthrough has stops. */ export const ChangesWalkthroughNav = memo(function ChangesWalkthroughNav() { const { stops, stopIndex, selectStop } = useChangesWalkthrough() @@ -169,20 +176,39 @@ export const ChangesWalkthroughNav = memo(function ChangesWalkthroughNav() { variant="outline" size="icon-sm" aria-label="Previous stop" - onClick={() => selectStop(stopIndex - 1)} - disabled={stopIndex === 0} + onClick={() => selectStop(stopIndex === null || stopIndex === 0 ? null : stopIndex - 1)} + disabled={stopIndex === null} > - - Stop {stopIndex + 1} of {stops.length} - + + + + + + selectStop(value === 'overview' ? null : Number(value))} + > + Overview + + {stops.map((stop, index) => ( + + {index + 1}. {stop.title} + + ))} + + + @@ -221,15 +247,14 @@ export const ChangesWalkthroughView = memo(function ChangesWalkthroughView() { generate, regenerate, stops, - stopIndex, selectedStop, selectedHunks, selectStop, - detailRef, + scrollRef, } = useChangesWalkthrough() return ( -
+
{error ? (

{walkthroughErrorMessage(error)}

@@ -271,35 +296,9 @@ export const ChangesWalkthroughView = memo(function ChangesWalkthroughView() {
) : null} - - - {stops.length > 0 ? ( -
    - {stops.map((stop, index) => ( -
  1. - -
  2. - ))} -
- ) : null} - {selectedStop ? ( -
-

- {stopIndex + 1}. {selectedStop.title} -

+
+

{selectedStop.title}

{selectedHunks.map((hunk) => (
@@ -318,9 +317,29 @@ export const ChangesWalkthroughView = memo(function ChangesWalkthroughView() {
))}
- ) : null} + ) : ( + <> + - {walkthrough.omittedFiles.length > 0 ? : null} + {stops.length > 0 ? ( +
    + {stops.map((stop, index) => ( +
  1. + +
  2. + ))} +
+ ) : null} + + {walkthrough.omittedFiles.length > 0 ? : null} + + )}
)}
From b16f1f894479ffb1b96831ad31cb436f07a6a141 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:49:11 -0400 Subject: [PATCH 2/7] fix(commands): broadcast location catalog events to all stream clients Location-scoped command, agent and skill catalog events were only delivered to clients subscribed to the originating directory, so a client attached to another location never saw a catalog change and its slash menu stayed on the builtin commands. Route command.updated, agent.updated and skill.updated through the resolved-event broadcast so every connected client receives them. --- backend/src/services/sse-aggregator.ts | 7 +++- backend/test/services/sse-aggregator.test.ts | 43 ++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/backend/src/services/sse-aggregator.ts b/backend/src/services/sse-aggregator.ts index 1692fbeb..2aa2d9aa 100644 --- a/backend/src/services/sse-aggregator.ts +++ b/backend/src/services/sse-aggregator.ts @@ -34,6 +34,7 @@ type ReplayEventType = 'permission.asked' | 'form.created' | 'session.status' const { RECONNECT_DELAY_MS, MAX_RECONNECT_DELAY_MS } = DEFAULTS.SSE const MULTILINE_PATTERN = /[\r\n]/ +const LOCATION_CATALOG_EVENT_TYPES = new Set(['command.updated', 'agent.updated', 'skill.updated']) function serializeEnvelope(directory: string | null, payloadJson: string): string { return '{"directory":' + JSON.stringify(directory) + ',"payload":' + payloadJson + '}' @@ -434,7 +435,11 @@ class SSEAggregator { } if (directory) { - this.deliverEvent(directory, event, payloadJson) + if (LOCATION_CATALOG_EVENT_TYPES.has(event.type)) { + this.deliverResolvedEvent(directory, event, payloadJson) + } else { + this.deliverEvent(directory, event, payloadJson) + } return } diff --git a/backend/test/services/sse-aggregator.test.ts b/backend/test/services/sse-aggregator.test.ts index 0fe3d2b6..f4545f41 100644 --- a/backend/test/services/sse-aggregator.test.ts +++ b/backend/test/services/sse-aggregator.test.ts @@ -797,3 +797,46 @@ describe('SSEAggregator directory-less session event routing', () => { expect(seen).toEqual([{ directory: '/r', type: 'session.execution.succeeded', sessionID: 'ses_fork' }]) }) }) + +describe('SSEAggregator location-scoped catalog event broadcast', () => { + beforeEach(() => { + sseAggregator.shutdown() + sseAggregator.setPendingActionsFetcher(null) + sseAggregator.setScheduledSessionsResolver(() => []) + }) + + it.each(['command.updated', 'agent.updated', 'skill.updated'])( + 'broadcasts a location-scoped %s catalog event to every client without leaking other location-scoped events', + (type) => { + const subscribed = createCapturingClient() + const unsubscribed = createCapturingClient() + sseAggregator.addClient('catalog-a', subscribed.callback, subscribed.writeFrame, ['/repo-a']) + sseAggregator.addClient('catalog-b', unsubscribed.callback, unsubscribed.writeFrame, []) + + const seen: Array<{ directory: string; type: string }> = [] + sseAggregator.onEvent((directory, event) => { + seen.push({ directory, type: event.type }) + }) + + emitRawEvent({ id: 'evt_catalog', type, location: { directory: '/repo-c' }, data: {} }) + + const expected = { + directory: null, + payload: { id: 'evt_catalog', created: 1, type, location: { directory: '/repo-c' }, data: {} }, + } + expect(subscribed.frames.map(parseFrame)).toEqual([expected]) + expect(unsubscribed.frames.map(parseFrame)).toEqual([expected]) + expect(seen).toEqual([{ directory: '/repo-c', type }]) + + emitRawEvent({ + id: 'evt_status', + type: 'session.status', + location: { directory: '/repo-c' }, + data: { sessionID: 'ses-1', status: { type: 'busy' } }, + }) + + expect(subscribed.frames).toHaveLength(1) + expect(unsubscribed.frames).toHaveLength(1) + }, + ) +}) From 299675819824f14b65fee357f84dc6d35664dc3d Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:49:13 -0400 Subject: [PATCH 3/7] fix(pwa): show a persistent update banner instead of a toast The service worker update notice was a dismissible toast that was easy to miss, leaving users on a stale build. Render a persistent status bar above the app shell with an explicit Reload action, and switch the shell to a flex column so pages size against the shell height (h-full) rather than the viewport (h-dvh), keeping the layout correct while the banner is visible. --- frontend/src/App.tsx | 14 ++-- .../src/components/PwaUpdatePrompt.test.tsx | 73 +++++++++++++++++++ frontend/src/components/PwaUpdatePrompt.tsx | 43 +++++++---- frontend/src/components/ui/sidebar.tsx | 2 +- frontend/src/pages/AssistantRedirect.tsx | 4 +- frontend/src/pages/GlobalSchedules.tsx | 2 +- frontend/src/pages/Login.tsx | 2 +- frontend/src/pages/Register.tsx | 2 +- frontend/src/pages/RepoDetail.tsx | 4 +- frontend/src/pages/Repos.tsx | 4 +- frontend/src/pages/Schedules.tsx | 2 +- frontend/src/pages/SessionDetail.tsx | 2 +- frontend/src/pages/Setup.tsx | 2 +- 13 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 frontend/src/components/PwaUpdatePrompt.test.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 06d5782e..3cd9d97b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -197,11 +197,14 @@ function AppShell() { -
- -
- -
+
+ +
+ +
+ +
+
@@ -210,7 +213,6 @@ function AppShell() { - diff --git a/frontend/src/components/PwaUpdatePrompt.test.tsx b/frontend/src/components/PwaUpdatePrompt.test.tsx new file mode 100644 index 00000000..e90ddf15 --- /dev/null +++ b/frontend/src/components/PwaUpdatePrompt.test.tsx @@ -0,0 +1,73 @@ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' +import { render, screen, fireEvent, act } from '@testing-library/react' +import { PwaUpdatePrompt } from './PwaUpdatePrompt' + +const mocks = vi.hoisted(() => ({ + onServiceWorkerUpdate: vi.fn(), + offServiceWorkerUpdate: vi.fn(), +})) + +vi.mock('@/lib/serviceWorker', () => ({ + onServiceWorkerUpdate: mocks.onServiceWorkerUpdate, + offServiceWorkerUpdate: mocks.offServiceWorkerUpdate, +})) + +function triggerUpdate() { + const callback = mocks.onServiceWorkerUpdate.mock.calls[0]?.[0] + if (typeof callback !== 'function') throw new Error('update callback was not registered') + act(() => callback()) +} + +describe('PwaUpdatePrompt', () => { + let reloadMock: ReturnType + + beforeEach(() => { + mocks.onServiceWorkerUpdate.mockReset() + mocks.offServiceWorkerUpdate.mockReset() + reloadMock = vi.fn() + Object.defineProperty(window, 'location', { + configurable: true, + writable: true, + value: { ...window.location, reload: reloadMock }, + }) + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + it('renders nothing until an update is signalled', () => { + const { container } = render() + + expect(container).toBeEmptyDOMElement() + expect(screen.queryByRole('status')).toBeNull() + }) + + it('shows a status bar with a Reload button when an update is signalled', () => { + render() + + triggerUpdate() + + expect(screen.getByRole('status')).toHaveTextContent( + 'A new version of OpenCode Manager is available.', + ) + expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument() + }) + + it('reloads the page when Reload is clicked', () => { + render() + + triggerUpdate() + fireEvent.click(screen.getByRole('button', { name: 'Reload' })) + + expect(reloadMock).toHaveBeenCalledTimes(1) + }) + + it('unsubscribes from updates on unmount', () => { + const { unmount } = render() + + unmount() + + expect(mocks.offServiceWorkerUpdate).toHaveBeenCalledTimes(1) + }) +}) diff --git a/frontend/src/components/PwaUpdatePrompt.tsx b/frontend/src/components/PwaUpdatePrompt.tsx index 90871141..996b460e 100644 --- a/frontend/src/components/PwaUpdatePrompt.tsx +++ b/frontend/src/components/PwaUpdatePrompt.tsx @@ -1,21 +1,38 @@ -import { useEffect } from 'react' -import { showToast } from '@/lib/toast' +import { useEffect, useState } from 'react' +import { RefreshCw } from 'lucide-react' +import { Button } from '@/components/ui/button' import { onServiceWorkerUpdate, offServiceWorkerUpdate } from '@/lib/serviceWorker' export function PwaUpdatePrompt() { + const [visible, setVisible] = useState(false) + useEffect(() => { - onServiceWorkerUpdate(() => { - showToast.info('New build deployed', { - description: 'Refresh to load the latest changes.', - action: { - label: 'Refresh', - onClick: () => window.location.reload(), - }, - duration: Infinity, - }) - }) + onServiceWorkerUpdate(() => setVisible(true)) return () => offServiceWorkerUpdate() }, []) - return null + if (!visible) return null + + return ( +
+
+
+
+ ) } diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsx index f03a2ab6..2a5f5479 100644 --- a/frontend/src/components/ui/sidebar.tsx +++ b/frontend/src/components/ui/sidebar.tsx @@ -25,7 +25,7 @@ export function Sidebar({ return (