chore: uptick
This commit is contained in:
@@ -7,7 +7,16 @@ export interface PreviewTarget {
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface PreviewServerRestart {
|
||||
message?: string
|
||||
status: 'complete' | 'error' | 'running'
|
||||
taskId: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export const $previewTarget = atom<PreviewTarget | null>(null)
|
||||
export const $previewReloadRequest = atom(0)
|
||||
export const $previewServerRestart = atom<PreviewServerRestart | null>(null)
|
||||
|
||||
function isSamePreviewTarget(a: PreviewTarget | null, b: PreviewTarget | null): boolean {
|
||||
if (a === b) {
|
||||
@@ -28,3 +37,52 @@ export function setPreviewTarget(target: PreviewTarget | null) {
|
||||
|
||||
$previewTarget.set(target)
|
||||
}
|
||||
|
||||
export function requestPreviewReload() {
|
||||
$previewReloadRequest.set($previewReloadRequest.get() + 1)
|
||||
}
|
||||
|
||||
export function beginPreviewServerRestart(taskId: string, url: string) {
|
||||
$previewServerRestart.set({ status: 'running', taskId, url })
|
||||
}
|
||||
|
||||
export function completePreviewServerRestart(taskId: string, text: string) {
|
||||
const current = $previewServerRestart.get()
|
||||
|
||||
if (current?.taskId !== taskId) {
|
||||
return
|
||||
}
|
||||
|
||||
$previewServerRestart.set({
|
||||
...current,
|
||||
message: text,
|
||||
status: text.trim().toLowerCase().startsWith('error:') ? 'error' : 'complete'
|
||||
})
|
||||
}
|
||||
|
||||
export function progressPreviewServerRestart(taskId: string, text: string) {
|
||||
const current = $previewServerRestart.get()
|
||||
|
||||
if (current?.taskId !== taskId || current.status !== 'running') {
|
||||
return
|
||||
}
|
||||
|
||||
$previewServerRestart.set({
|
||||
...current,
|
||||
message: text
|
||||
})
|
||||
}
|
||||
|
||||
export function failPreviewServerRestart(taskId: string, message: string) {
|
||||
const current = $previewServerRestart.get()
|
||||
|
||||
if (current?.taskId !== taskId || current.status !== 'running') {
|
||||
return
|
||||
}
|
||||
|
||||
$previewServerRestart.set({
|
||||
...current,
|
||||
message,
|
||||
status: 'error'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ export const $busy = atom(false)
|
||||
export const $awaitingResponse = atom(false)
|
||||
export const $currentModel = atom('')
|
||||
export const $currentProvider = atom('')
|
||||
export const $currentReasoningEffort = atom('')
|
||||
export const $currentServiceTier = atom('')
|
||||
export const $currentFastMode = atom(false)
|
||||
export const $currentCwd = atom('')
|
||||
export const $currentBranch = atom('')
|
||||
export const $introPersonality = atom('')
|
||||
@@ -51,6 +54,9 @@ export const setBusy = (next: Updater<boolean>) => updateAtom($busy, next)
|
||||
export const setAwaitingResponse = (next: Updater<boolean>) => updateAtom($awaitingResponse, next)
|
||||
export const setCurrentModel = (next: Updater<string>) => updateAtom($currentModel, next)
|
||||
export const setCurrentProvider = (next: Updater<string>) => updateAtom($currentProvider, next)
|
||||
export const setCurrentReasoningEffort = (next: Updater<string>) => updateAtom($currentReasoningEffort, next)
|
||||
export const setCurrentServiceTier = (next: Updater<string>) => updateAtom($currentServiceTier, next)
|
||||
export const setCurrentFastMode = (next: Updater<boolean>) => updateAtom($currentFastMode, next)
|
||||
export const setCurrentCwd = (next: Updater<string>) => updateAtom($currentCwd, next)
|
||||
export const setCurrentBranch = (next: Updater<string>) => updateAtom($currentBranch, next)
|
||||
export const setIntroPersonality = (next: Updater<string>) => updateAtom($introPersonality, next)
|
||||
|
||||
Reference in New Issue
Block a user