Offer the upgrade, and say what it costs

Two presses, and the second one spells out what the first cannot be
allowed to hide: the conversation stays in the old room, and the people
in it cross over as their own clients notice the tombstone. An upgrade
is the one thing in this panel that makes a new room rather than
changing this one.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-09-13 13:43:41 -04:00
co-authored by Claude Opus 5
parent d612fccb1e
commit 91c1d194b1
2 changed files with 63 additions and 1 deletions
+1 -1
Submodule nobilis updated: 2c3c48407e...086a0af7c8
@@ -12,6 +12,14 @@ interface Choice {
canChange: boolean
}
/** What room version this room is on, and whether it is worth moving. */
interface Version {
current: string
default: string
behind: boolean
canUpgrade: boolean
}
/**
* The settings a room keeps about itself.
*
@@ -30,14 +38,26 @@ export function RoomSettings({ buffer }: { buffer: BufferEntry }): JSX.Element {
const button = useRef<HTMLSpanElement>(null)
const [open, setOpen] = useState(false)
const [history, setHistory] = useState<Choice | null>(null)
const [version, setVersion] = useState<Version | null>(null)
const [upgrading, setUpgrading] = useState(false)
const [confirmUpgrade, setConfirmUpgrade] = useState(false)
const [saving, setSaving] = useState(false)
const load = (): void => {
setHistory(null)
setVersion(null)
setConfirmUpgrade(false)
void window.moho
.rpc<Choice>('matrixHistoryVisibility', { bufferId: buffer.id })
.then(setHistory)
.catch((e: Error) => store.toast('error', e.message))
void window.moho
.rpc<Version>('matrixRoomVersion', { bufferId: buffer.id })
.then(setVersion)
// Quietly. A room whose version is not known yet is a room with
// nothing to say here, not an error to put in front of somebody who
// came to change something else.
.catch(() => setVersion(null))
}
const show = (): void => {
@@ -102,6 +122,48 @@ export function RoomSettings({ buffer }: { buffer: BufferEntry }): JSX.Element {
)}
</>
)}
{/* Not a setting: an upgrade makes a new room and leaves a
tombstone pointing at it. Offered only where there is somewhere
to go and somebody who can make the tombstone - and with what
it costs written out, because the conversation does not come
with it. */}
{version?.behind && version.canUpgrade && (
<div className="setting-row">
<div className="setting-text">
<div>Room version {version.current}</div>
<div className="small muted">
{confirmUpgrade
? `This makes a new room on version ${version.default} and leaves a pointer here. The conversation above stays in this room, and the people in it move across as their clients notice.`
: `This server now makes rooms on version ${version.default}.`}
</div>
</div>
{confirmUpgrade ? (
<button
type="button"
className="button danger"
disabled={upgrading}
onClick={() => {
setUpgrading(true)
void window.moho
.rpc<{ roomId: string }>('upgradeMatrixRoom', { bufferId: buffer.id })
.then(() => {
store.toast('info', 'Upgraded — the new room is in your list')
setOpen(false)
})
.catch((e: Error) => store.toast('error', `Couldn’t upgrade: ${e.message}`))
.finally(() => setUpgrading(false))
}}
>
Upgrade it
</button>
) : (
<button type="button" className="button subtle" onClick={() => setConfirmUpgrade(true)}>
Upgrade…
</button>
)}
</div>
)}
</HeaderPopover>
)}
</>