fix(servers): guard stored credentials and reconcile remote session status

Reject a server address change to a new origin unless a password or
pairing is supplied, so the stored password is never sent to another
host. Test connection now checks the edited values and warns when an
origin change needs credentials. Replay and reconcile remote session
statuses on stream reconnect and browser resync so linked-server
sessions no longer stay busy. Treat malformed server session URLs as
not found instead of throwing.
This commit is contained in:
Chris Scott committed 2026-10-18 21:53:19 -04:00
1 parent 3a7227a602
commit 5586120ba2
18 files changed
+843 -62

No files matched your search

@@ -29,6 +29,8 @@ const savedServer: OpenCodeServer = {
updatedAt: 2,
}
const originChangeWarning = 'Changing the server address requires re-entering the password or pairing again.'
function renderDialog(options: {
server?: OpenCodeServer | null
onSubmit?: (values: OpenCodeServerFormValues) => Promise<void>
@@ -132,4 +134,47 @@ describe('OpenCodeServerDialog', () => {
expect(await screen.findByText('Connected — OpenCode 2.0.15')).toBeInTheDocument()
expect(screen.getByText('Supported')).toBeInTheDocument()
})
it('warns that changing the server origin requires credentials', async () => {
const user = userEvent.setup()
renderDialog({ server: savedServer })
expect(screen.queryByText(originChangeWarning)).not.toBeInTheDocument()
await user.clear(screen.getByLabelText('URL'))
await user.type(screen.getByLabelText('URL'), 'https://relocated.example.com')
expect(screen.getByText(originChangeWarning)).toBeInTheDocument()
})
it('does not warn for a same-origin address change', async () => {
const user = userEvent.setup()
renderDialog({ server: savedServer })
await user.clear(screen.getByLabelText('URL'))
await user.type(screen.getByLabelText('URL'), 'https://office.example.com/api')
expect(screen.queryByText(originChangeWarning)).not.toBeInTheDocument()
})
it('does not warn once a password is entered for the new origin', async () => {
const user = userEvent.setup()
renderDialog({ server: savedServer })
await user.clear(screen.getByLabelText('URL'))
await user.type(screen.getByLabelText('URL'), 'https://relocated.example.com')
await user.type(screen.getByLabelText('Password'), 'new-password')
expect(screen.queryByText(originChangeWarning)).not.toBeInTheDocument()
})
it('does not warn about an origin change when no password is stored', async () => {
const user = userEvent.setup()
renderDialog({ server: { ...savedServer, hasPassword: false } })
await user.clear(screen.getByLabelText('URL'))
await user.type(screen.getByLabelText('URL'), 'https://relocated.example.com')
expect(screen.queryByText(originChangeWarning)).not.toBeInTheDocument()
})
})