fix: prerelease fixes (#5793)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { injectModrinthServerContext, ServersManageOverviewPage } from '@modrinth/ui'
|
||||
|
||||
const { server } = injectModrinthServerContext()
|
||||
const flags = useFeatureFlags()
|
||||
|
||||
useHead({
|
||||
title: computed(() => `Overview - ${server.value?.name ?? 'Server'} - Modrinth`),
|
||||
@@ -9,5 +10,5 @@ useHead({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ServersManageOverviewPage />
|
||||
<ServersManageOverviewPage :show-advanced-debug-info="flags.advancedDebugInfo" />
|
||||
</template>
|
||||
|
||||
@@ -1,54 +1,71 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
:style="`${mouseX !== -1 ? `--_mouse-x: ${mouseX};` : ''} ${mouseY !== -1 ? `--_mouse-y: ${mouseY};` : ''}`"
|
||||
>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
:class="{ shown: visible }"
|
||||
class="tauri-overlay"
|
||||
data-tauri-drag-region
|
||||
@click="() => (closeOnClickOutside && closable ? hide() : {})"
|
||||
/>
|
||||
<div
|
||||
:class="[
|
||||
'modal-overlay',
|
||||
{
|
||||
shown: visible,
|
||||
noblur: effectiveNoblur,
|
||||
},
|
||||
computedFade,
|
||||
]"
|
||||
@click="() => (closeOnClickOutside && closable ? hide() : {})"
|
||||
/>
|
||||
<div
|
||||
class="modal-container experimental-styles-within"
|
||||
:class="{ shown: visible }"
|
||||
:style="{
|
||||
'--_max-width': maxWidth,
|
||||
'--_width': width,
|
||||
}"
|
||||
v-if="open"
|
||||
:style="`${mouseX !== -1 ? `--_mouse-x: ${mouseX};` : ''} ${mouseY !== -1 ? `--_mouse-y: ${mouseY};` : ''}`"
|
||||
>
|
||||
<div
|
||||
ref="modalBodyRef"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-labelledby="headerId"
|
||||
class="modal-body flex flex-col bg-bg-raised rounded-2xl border border-solid border-surface-5"
|
||||
@keydown="handleKeyDown"
|
||||
:class="{ shown: visible }"
|
||||
class="tauri-overlay"
|
||||
data-tauri-drag-region
|
||||
@click="() => (closeOnClickOutside && closable ? hide() : {})"
|
||||
/>
|
||||
<div
|
||||
:class="[
|
||||
'modal-overlay',
|
||||
{
|
||||
shown: visible,
|
||||
noblur: effectiveNoblur,
|
||||
},
|
||||
computedFade,
|
||||
]"
|
||||
@click="() => (closeOnClickOutside && closable ? hide() : {})"
|
||||
/>
|
||||
<div
|
||||
class="modal-container experimental-styles-within"
|
||||
:class="{ shown: visible }"
|
||||
:style="{
|
||||
'--_max-width': maxWidth,
|
||||
'--_width': width,
|
||||
}"
|
||||
>
|
||||
<div
|
||||
v-if="!hideHeader"
|
||||
data-tauri-drag-region
|
||||
class="grid grid-cols-[auto_min-content] items-center gap-4 p-6 border-solid border-0 border-b-[1px] border-surface-5 max-w-full"
|
||||
ref="modalBodyRef"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-labelledby="headerId"
|
||||
class="modal-body flex flex-col bg-bg-raised rounded-2xl border border-solid border-surface-5"
|
||||
@keydown="handleKeyDown"
|
||||
>
|
||||
<div class="flex text-wrap break-words items-center gap-3 min-w-0">
|
||||
<slot name="title">
|
||||
<span v-if="header" :id="headerId" class="text-2xl font-semibold text-contrast">
|
||||
{{ header }}
|
||||
</span>
|
||||
</slot>
|
||||
<div
|
||||
v-if="!hideHeader"
|
||||
data-tauri-drag-region
|
||||
class="grid grid-cols-[auto_min-content] items-center gap-4 p-6 border-solid border-0 border-b-[1px] border-surface-5 max-w-full"
|
||||
>
|
||||
<div class="flex text-wrap break-words items-center gap-3 min-w-0">
|
||||
<slot name="title">
|
||||
<span v-if="header" :id="headerId" class="text-2xl font-semibold text-contrast">
|
||||
{{ header }}
|
||||
</span>
|
||||
</slot>
|
||||
</div>
|
||||
<ButtonStyled v-if="closable" circular>
|
||||
<button
|
||||
v-tooltip="closeLabel"
|
||||
:aria-label="closeLabel"
|
||||
:disabled="disableClose"
|
||||
@click="hide"
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
</div>
|
||||
<ButtonStyled v-if="closable" circular>
|
||||
|
||||
<ButtonStyled
|
||||
v-if="props.mergeHeader && closable"
|
||||
class="absolute top-4 right-4 z-10"
|
||||
circular
|
||||
>
|
||||
<button
|
||||
v-tooltip="closeLabel"
|
||||
:aria-label="closeLabel"
|
||||
@@ -58,82 +75,67 @@
|
||||
<XIcon aria-hidden="true" />
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
</div>
|
||||
|
||||
<ButtonStyled
|
||||
v-if="props.mergeHeader && closable"
|
||||
class="absolute top-4 right-4 z-10"
|
||||
circular
|
||||
>
|
||||
<button
|
||||
v-tooltip="closeLabel"
|
||||
:aria-label="closeLabel"
|
||||
:disabled="disableClose"
|
||||
@click="hide"
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
<div v-if="scrollable" class="relative flex-1 min-h-0 flex flex-col">
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-200 ease-out"
|
||||
enter-from-class="opacity-0 max-h-0"
|
||||
enter-to-class="opacity-100 max-h-6"
|
||||
leave-active-class="transition-all duration-200 ease-in"
|
||||
leave-from-class="opacity-100 max-h-6"
|
||||
leave-to-class="opacity-0 max-h-0"
|
||||
>
|
||||
<div
|
||||
v-if="showTopFade"
|
||||
class="pointer-events-none absolute left-0 right-0 top-0 z-10 h-6 bg-gradient-to-b from-bg-raised to-transparent"
|
||||
/>
|
||||
</Transition>
|
||||
|
||||
<div v-if="scrollable" class="relative flex-1 min-h-0 flex flex-col">
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-200 ease-out"
|
||||
enter-from-class="opacity-0 max-h-0"
|
||||
enter-to-class="opacity-100 max-h-6"
|
||||
leave-active-class="transition-all duration-200 ease-in"
|
||||
leave-from-class="opacity-100 max-h-6"
|
||||
leave-to-class="opacity-0 max-h-0"
|
||||
>
|
||||
<div
|
||||
v-if="showTopFade"
|
||||
class="pointer-events-none absolute left-0 right-0 top-0 z-10 h-6 bg-gradient-to-b from-bg-raised to-transparent"
|
||||
/>
|
||||
</Transition>
|
||||
ref="scrollContainer"
|
||||
:class="[
|
||||
'flex-1 min-h-0',
|
||||
props.noPadding ? '' : 'overflow-y-auto p-6 !pb-1 sm:pb-6',
|
||||
{ 'pt-12': props.mergeHeader && closable && !props.noPadding },
|
||||
]"
|
||||
:style="props.noPadding ? {} : { maxHeight: maxContentHeight }"
|
||||
@scroll="checkScrollState"
|
||||
>
|
||||
<slot> You just lost the game.</slot>
|
||||
</div>
|
||||
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-200 ease-out"
|
||||
enter-from-class="opacity-0 max-h-0"
|
||||
enter-to-class="opacity-100 max-h-6"
|
||||
leave-active-class="transition-all duration-200 ease-in"
|
||||
leave-from-class="opacity-100 max-h-6"
|
||||
leave-to-class="opacity-0 max-h-0"
|
||||
>
|
||||
<div
|
||||
v-if="showBottomFade"
|
||||
class="pointer-events-none absolute bottom-0 left-0 right-0 z-10 h-6 bg-gradient-to-t from-bg-raised to-transparent"
|
||||
/>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
<div
|
||||
ref="scrollContainer"
|
||||
v-else
|
||||
:class="[
|
||||
'flex-1 min-h-0',
|
||||
props.noPadding ? '' : 'overflow-y-auto p-6 !pb-1 sm:pb-6',
|
||||
props.noPadding ? '' : 'overflow-y-auto p-6',
|
||||
{ 'pt-12': props.mergeHeader && closable && !props.noPadding },
|
||||
]"
|
||||
:style="props.noPadding ? {} : { maxHeight: maxContentHeight }"
|
||||
@scroll="checkScrollState"
|
||||
>
|
||||
<slot> You just lost the game.</slot>
|
||||
</div>
|
||||
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-200 ease-out"
|
||||
enter-from-class="opacity-0 max-h-0"
|
||||
enter-to-class="opacity-100 max-h-6"
|
||||
leave-active-class="transition-all duration-200 ease-in"
|
||||
leave-from-class="opacity-100 max-h-6"
|
||||
leave-to-class="opacity-0 max-h-0"
|
||||
>
|
||||
<div
|
||||
v-if="showBottomFade"
|
||||
class="pointer-events-none absolute bottom-0 left-0 right-0 z-10 h-6 bg-gradient-to-t from-bg-raised to-transparent"
|
||||
/>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else
|
||||
:class="[
|
||||
props.noPadding ? '' : 'overflow-y-auto p-6',
|
||||
{ 'pt-12': props.mergeHeader && closable && !props.noPadding },
|
||||
]"
|
||||
>
|
||||
<slot> You just lost the game.</slot>
|
||||
</div>
|
||||
|
||||
<div v-if="$slots.actions" class="p-4 pt-0">
|
||||
<slot name="actions" />
|
||||
<div v-if="$slots.actions" class="p-4 pt-0">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
@@ -23,7 +23,6 @@ export function useServerPowerAction(options?: { disabled?: Ref<boolean> }) {
|
||||
const showStopButton = computed(() => isRunning.value || isStarting.value)
|
||||
|
||||
const busyTooltip = computed(() => {
|
||||
if (isStopping.value) return 'Server is currently stopping'
|
||||
if (isStarting.value) return 'Your server is starting'
|
||||
return busyReasons.value.length > 0 ? formatMessage(busyReasons.value[0].reason) : undefined
|
||||
})
|
||||
@@ -37,6 +36,8 @@ export function useServerPowerAction(options?: { disabled?: Ref<boolean> }) {
|
||||
case 'running':
|
||||
case 'starting':
|
||||
return 'Restart'
|
||||
case 'stopping':
|
||||
return 'Stopping'
|
||||
default:
|
||||
return 'Start'
|
||||
}
|
||||
|
||||
@@ -194,16 +194,16 @@ function formatLog4jLines(event: Log4jEvent): LogLine[] {
|
||||
const message = event.message?.trim() ?? ''
|
||||
|
||||
const prefix = time ? `${time} [${thread}/${levelStr}]: ` : `[${thread}/${levelStr}]: `
|
||||
const messageLines = message.split(/\r?\n/)
|
||||
const messageLines = message.split(/[\r\n]+/)
|
||||
const lines: LogLine[] = [{ text: prefix + messageLines[0], level }]
|
||||
for (let i = 1; i < messageLines.length; i++) {
|
||||
if (!messageLines[i].trim()) continue
|
||||
if (!messageLines[i]) continue
|
||||
lines.push({ text: messageLines[i], level })
|
||||
}
|
||||
|
||||
if (event.throwable) {
|
||||
for (const line of event.throwable.split(/\r?\n/)) {
|
||||
if (!line.trim()) continue
|
||||
for (const line of event.throwable.split(/[\r\n]+/)) {
|
||||
if (!line) continue
|
||||
lines.push({ text: line, level: 'error' })
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,9 @@ function textToLogLine(text: string): LogLine {
|
||||
export function createConsoleState() {
|
||||
const archive = new ColumnarRingBuffer(ARCHIVE_CAPACITY)
|
||||
const output: Ref<LogLine[]> = shallowRef<LogLine[]>([])
|
||||
const WS_EVENT_HISTORY_MAX = 25000
|
||||
const wsEventHistory: unknown[] = []
|
||||
let wsEventCaptureEnabled = false
|
||||
|
||||
let lineBuffer: LogLine[] = []
|
||||
let batchTimer: NodeJS.Timeout | null = null
|
||||
@@ -283,10 +286,25 @@ export function createConsoleState() {
|
||||
addLines(formatLog4jLines(event))
|
||||
}
|
||||
|
||||
const recordWsEvent = (event: unknown): void => {
|
||||
if (!wsEventCaptureEnabled) return
|
||||
wsEventHistory.push(event)
|
||||
if (wsEventHistory.length > WS_EVENT_HISTORY_MAX) {
|
||||
wsEventHistory.splice(0, wsEventHistory.length - WS_EVENT_HISTORY_MAX)
|
||||
}
|
||||
}
|
||||
|
||||
const getWsEventHistory = (): unknown[] => wsEventHistory.slice()
|
||||
|
||||
const setWsEventCaptureEnabled = (enabled: boolean): void => {
|
||||
wsEventCaptureEnabled = enabled
|
||||
if (!enabled) wsEventHistory.length = 0
|
||||
}
|
||||
|
||||
const addLegacyLog = (message: string): void => {
|
||||
const logLines = message
|
||||
.split('\n')
|
||||
.filter((l) => l.trim())
|
||||
.split(/[\r\n]+/)
|
||||
.filter((l) => l)
|
||||
.map(textToLogLine)
|
||||
|
||||
let parentLevel: LogLevel | null = null
|
||||
@@ -306,6 +324,7 @@ export function createConsoleState() {
|
||||
archive.clear()
|
||||
output.value = []
|
||||
lineBuffer = []
|
||||
wsEventHistory.length = 0
|
||||
wrapCount = 0
|
||||
if (batchTimer) {
|
||||
clearTimeout(batchTimer)
|
||||
@@ -343,6 +362,9 @@ export function createConsoleState() {
|
||||
addLines,
|
||||
addLog4jEvent,
|
||||
addLegacyLog,
|
||||
recordWsEvent,
|
||||
getWsEventHistory,
|
||||
setWsEventCaptureEnabled,
|
||||
clear,
|
||||
__debugStats,
|
||||
}
|
||||
|
||||
@@ -198,11 +198,13 @@ export function useServerManageCoreRuntime(options: UseServerManageCoreRuntimeOp
|
||||
|
||||
const handleLog = (data: Archon.Websocket.v0.WSLogEvent) => {
|
||||
if (!shouldProcessEvent()) return
|
||||
modrinthServersConsole.recordWsEvent({ event: 'log', ...data })
|
||||
modrinthServersConsole.addLegacyLog(data.message)
|
||||
}
|
||||
|
||||
const handleLog4j = (data: Archon.Websocket.v0.WSLog4jEvent) => {
|
||||
if (!shouldProcessEvent()) return
|
||||
modrinthServersConsole.recordWsEvent({ event: 'log4j', ...data })
|
||||
modrinthServersConsole.addLog4jEvent(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,14 @@
|
||||
page. (WebSocket Authentication Failed)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="showAdvancedDebugInfo"
|
||||
class="self-start rounded-lg bg-surface-3 px-3 py-1 text-sm text-contrast hover:brightness-125"
|
||||
@click="downloadLog4jDebug"
|
||||
>
|
||||
Download WS debug JSON
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -37,6 +45,15 @@ import { injectModrinthClient, injectModrinthServerContext } from '#ui/providers
|
||||
|
||||
import ServerManageStats from './components/ServerManageStats.vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
showAdvancedDebugInfo?: boolean
|
||||
}>(),
|
||||
{
|
||||
showAdvancedDebugInfo: false,
|
||||
},
|
||||
)
|
||||
|
||||
const client = injectModrinthClient()
|
||||
const {
|
||||
server: _serverData,
|
||||
@@ -49,6 +66,14 @@ const {
|
||||
} = injectModrinthServerContext()
|
||||
const modrinthServersConsole = useModrinthServersConsole()
|
||||
|
||||
watch(
|
||||
() => props.showAdvancedDebugInfo,
|
||||
(enabled) => {
|
||||
modrinthServersConsole.setWsEventCaptureEnabled(enabled)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const crashAnalysis = ref<Mclogs.Insights.v1.InsightsResponse | null>(null)
|
||||
const DISMISS_DURATION_MS = 30 * 60 * 1000
|
||||
const dismissedUntil = useStorage(`modrinth-crash-dismissed-${serverId}`, 0)
|
||||
@@ -120,4 +145,17 @@ watch(
|
||||
if (serverPowerState.value === 'crashed') {
|
||||
void inspectError()
|
||||
}
|
||||
|
||||
const downloadLog4jDebug = () => {
|
||||
const events = modrinthServersConsole.getWsEventHistory()
|
||||
const blob = new Blob([JSON.stringify(events, null, 2)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `ws-debug-${serverId}-${Date.now()}.json`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user