Files
Kazuki YamadaandClaude Opus 4.7 fa06e5059c fix(website): Address PR review feedback on siteverify metric
Six items from gemini, claude initial review, and claude follow-up:

- turnstile.ts: Update misleading comment that claimed the metric filters
  on `event=turnstile_siteverify` and `outcome=success`. The actual
  Cloud Monitoring metrics in `monitoring/metrics/` filter on
  `siteverifyDurationMs` field presence, which uniformly captures both
  the parallel success log (event=turnstile_siteverify) and the four
  rejectAndLog failure paths (event=pack_completed). The comment
  contradicted README and YAML and would mislead future readers.
- turnstile.ts: Wrap rejectAndLog in a local `rejectWithDuration` helper
  so every post-siteverify branch automatically carries
  `siteverifyDurationMs`. Prevents drift if a fifth reject reason gets
  added later.
- client.ts: Split the wire-protocol `PackProgressStage` (server-emitted
  SSE values) from the display-only `DisplayProgressStage` superset that
  adds `verifying`. Keeping the synthetic stage out of the wire type
  prevents silent divergence with the server's `PackProgressStage`.
- usePackRequest.ts, TryItLoading.vue, TryItResult.vue: Switch the
  display-side type to `DisplayProgressStage`. `onProgress` callbacks
  still take the wire `PackProgressStage`.
- usePackRequest.ts: Clear `progressStage` on token-acquisition failure
  branches (aborted / error). Functionally invisible since loading=false
  hides the loading UI, but prevents the next submit's verifying flash
  from briefly showing the previous run's stale state.
- monitoring/metrics/turnstile_siteverify_duration.yaml: Retune the
  exponential bucket layout for the 100ms-1s SLO band where decisions
  get made. Doubling buckets only placed ~3 boundaries between 100ms
  and 1s; growthFactor=1.5 with scale=10 places ~8 boundaries there.
  18 finite buckets cover 10ms to ~9.85s, comfortably above the 5s
  siteverify timeout so timeouts don't land in overflow.
- monitoring/README.md: Document that pre-network rejections
  (secret_missing, missing_token, token_too_long) intentionally don't
  carry siteverifyDurationMs, so they're excluded from both metrics
  but still appear in the existing pack_requests metric.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 21:42:21 +09:00

147 lines
3.7 KiB
Vue

<script setup lang="ts">
import { computed, ref } from 'vue';
import type { PackOptions } from '../../composables/usePackOptions';
import type { TabType } from '../../types/ui';
import type { DisplayProgressStage, FileInfo, PackResult } from '../api/client';
import SupportMessage from './SupportMessage.vue';
import TryItFileSelection from './TryItFileSelection.vue';
import TryItLoading from './TryItLoading.vue';
import TryItResultContent from './TryItResultContent.vue';
import TryItResultErrorContent from './TryItResultErrorContent.vue';
interface Props {
result?: PackResult | null;
loading?: boolean;
error?: string | null;
errorType?: 'error' | 'warning';
repositoryUrl?: string;
packOptions?: PackOptions;
progressStage?: DisplayProgressStage | null;
progressMessage?: string | null;
}
interface Emits {
(e: 'repack', selectedFiles: FileInfo[]): void;
(e: 'repack-completed'): void;
}
const props = defineProps<Props>();
const emit = defineEmits<Emits>();
// Tab management
const activeTab = ref<TabType>('result');
const hasFileSelection = computed(() => props.result?.metadata?.allFiles && props.result.metadata.allFiles.length > 0);
const handleTabClick = (tab: TabType) => {
activeTab.value = tab;
};
const handleRepack = (selectedFiles: FileInfo[]) => {
// Only proceed if we have selected files
if (!selectedFiles || selectedFiles.length === 0) {
return;
}
// Switch to result tab immediately when re-pack starts
activeTab.value = 'result';
emit('repack', selectedFiles);
};
</script>
<template>
<div class="result-viewer">
<template v-if="loading && !result">
<TryItLoading :stage="progressStage" :message="progressMessage" />
<SupportMessage />
</template>
<TryItResultErrorContent
v-else-if="error"
:message="error"
:error-type="errorType"
:repository-url="repositoryUrl"
:pack-options="packOptions"
/>
<div v-else-if="result" class="result-content">
<!-- Tab Navigation -->
<div v-if="hasFileSelection" class="tab-navigation">
<button
type="button"
class="tab-button"
:class="{ active: activeTab === 'result' }"
@click="handleTabClick('result')"
>
Result
</button>
<button
type="button"
class="tab-button"
:class="{ active: activeTab === 'files' }"
@click="handleTabClick('files')"
>
File Selection
</button>
</div>
<!-- Tab Content -->
<div v-show="activeTab === 'result' || !hasFileSelection">
<TryItResultContent :result="result" :pack-options="packOptions" />
</div>
<div v-show="activeTab === 'files' && hasFileSelection">
<TryItFileSelection
v-if="hasFileSelection"
:all-files="result.metadata!.allFiles!"
:loading="loading"
@repack="handleRepack"
/>
</div>
</div>
</div>
</template>
<style scoped>
.result-viewer {
margin-top: 24px;
border: 1px solid var(--vp-c-border);
border-radius: 8px;
overflow: hidden;
}
.result-content {
display: flex;
flex-direction: column;
}
.tab-navigation {
display: flex;
border-bottom: 1px solid var(--vp-c-border);
background: var(--vp-c-bg-soft);
}
.tab-button {
flex: 1;
padding: 12px 16px;
border: none;
background: transparent;
color: var(--vp-c-text-2);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
border-bottom: 2px solid transparent;
}
.tab-button:hover {
background: var(--vp-c-bg-alt);
color: var(--vp-c-text-1);
}
.tab-button.active {
color: var(--vp-c-brand-1);
border-bottom-color: var(--vp-c-brand-1);
background: var(--vp-c-bg);
}
</style>