chore: pin dev frontend auth fix
This commit is contained in:
@@ -497,16 +497,6 @@ fn preview(text: &str, max_chars: usize) -> String {
|
||||
result
|
||||
}
|
||||
|
||||
fn prefix_preview(text: &str, max_chars: usize) -> String {
|
||||
if text.chars().count() <= max_chars {
|
||||
return text.to_string();
|
||||
}
|
||||
let take = max_chars.saturating_sub(1);
|
||||
let mut result = text.chars().take(take).collect::<String>();
|
||||
result.push('…');
|
||||
result
|
||||
}
|
||||
|
||||
fn strip_after_marker(text: &str, marker: &str) -> Option<String> {
|
||||
text.find(marker).map(|index| text[index + marker.len()..].trim_start().to_string())
|
||||
}
|
||||
@@ -611,6 +601,17 @@ fn final_response(task: &TaskMeta) -> String {
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn text_preview(value: &str, max_chars: usize) -> Value {
|
||||
let chars = value.chars().count();
|
||||
let truncated = chars > max_chars;
|
||||
json!({
|
||||
"text": if truncated { preview(value, max_chars) } else { value.to_string() },
|
||||
"chars": chars,
|
||||
"truncated": truncated,
|
||||
"omittedChars": if truncated { chars.saturating_sub(max_chars.saturating_sub(20)) } else { 0 }
|
||||
})
|
||||
}
|
||||
|
||||
fn text_from_output(item: &Value) -> String {
|
||||
item.get("text").and_then(Value::as_str).unwrap_or("").to_string()
|
||||
}
|
||||
@@ -664,13 +665,17 @@ fn task_list_response(_state: &AppState, task: &TaskMeta, lite: bool) -> Value {
|
||||
};
|
||||
let final_text = final_response(task);
|
||||
let agent_port = code_agent_port(&task.model);
|
||||
let preview_limit = if lite { 360 } else { 2000 };
|
||||
json!({
|
||||
"id": task.id,
|
||||
"queueId": task.queue_id,
|
||||
"queueEnteredAt": task.task_json.as_ref().and_then(|value| value.get("queueEnteredAt")).and_then(Value::as_str).unwrap_or(&task.created_at),
|
||||
"prompt": if lite { prefix_preview(&display_prompt, 360) } else { preview(&task.prompt, 2000) },
|
||||
"basePrompt": if lite { prefix_preview(&task.base_prompt, 360) } else { preview(&task.base_prompt, 2000) },
|
||||
"displayPrompt": if lite { prefix_preview(&display_prompt, 360) } else { preview(&display_prompt, 2000) },
|
||||
"prompt": task.prompt,
|
||||
"basePrompt": task.base_prompt,
|
||||
"displayPrompt": display_prompt,
|
||||
"promptPreview": text_preview(&task.prompt, preview_limit),
|
||||
"basePromptPreview": text_preview(&task.base_prompt, preview_limit),
|
||||
"displayPromptPreview": text_preview(&display_prompt, preview_limit),
|
||||
"promptChars": task.prompt.chars().count(),
|
||||
"basePromptChars": task.base_prompt.chars().count(),
|
||||
"displayPromptChars": display_prompt.chars().count(),
|
||||
@@ -729,8 +734,15 @@ fn task_meta_response(state: &AppState, task: &TaskMeta) -> Value {
|
||||
let map = base.as_object_mut().expect("task response object");
|
||||
let output_count = json_array_len(task.task_json.as_ref(), "output", task.output_count);
|
||||
let prompt_history_count = json_array_len(task.task_json.as_ref(), "promptHistory", 0);
|
||||
let display_prompt = if task.base_prompt.is_empty() {
|
||||
user_prompt_for_display(&task.prompt)
|
||||
} else {
|
||||
task.base_prompt.clone()
|
||||
};
|
||||
map.insert("prompt".to_string(), json!(task.prompt));
|
||||
map.insert("basePrompt".to_string(), json!(task.base_prompt));
|
||||
map.insert("displayPrompt".to_string(), json!(display_prompt));
|
||||
map.insert("initialPrompt".to_string(), json!(task.prompt));
|
||||
map.insert("finalResponse".to_string(), json!(final_response(task)));
|
||||
map.insert(
|
||||
"promptHistory".to_string(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import postgres from "postgres";
|
||||
import { createHourlyJsonlWriter, logRetentionBytesForService } from "../../../shared/src/rotating-jsonl";
|
||||
import { codeQueuePromptResponseFields, safePreview } from "./prompt-observation";
|
||||
|
||||
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
||||
type JsonRecord = Record<string, JsonValue>;
|
||||
@@ -434,12 +435,6 @@ function timestampMs(value: string | Date | null | undefined): number | null {
|
||||
return Number.isFinite(ms) ? ms : null;
|
||||
}
|
||||
|
||||
function safePreview(value: unknown, maxChars: number): string {
|
||||
const text = String(value ?? "");
|
||||
if (text.length <= maxChars) return text;
|
||||
return `${text.slice(0, Math.max(0, maxChars - 20))}\n...<truncated>`;
|
||||
}
|
||||
|
||||
function prefixPreview(value: unknown, maxChars: number): string {
|
||||
const text = String(value ?? "");
|
||||
return text.length <= maxChars ? text : `${text.slice(0, Math.max(0, maxChars - 1))}…`;
|
||||
@@ -1635,17 +1630,12 @@ function taskStatisticsSummary(tasks: QueueTask[], days = 14): JsonRecord {
|
||||
}
|
||||
|
||||
function taskListResponse(task: QueueTask, lite = true): JsonRecord {
|
||||
const displayPrompt = task.basePrompt || userPromptForDisplay(task.prompt);
|
||||
const promptFields = codeQueuePromptResponseFields(task, { lite, userPromptForDisplay });
|
||||
return {
|
||||
id: task.id,
|
||||
queueId: queueIdOf(task),
|
||||
queueEnteredAt: task.queueEnteredAt,
|
||||
prompt: lite ? prefixPreview(displayPrompt, 360) : safePreview(displayPrompt, 2000),
|
||||
basePrompt: lite ? prefixPreview(task.basePrompt, 360) : safePreview(task.basePrompt, 2000),
|
||||
displayPrompt: lite ? prefixPreview(displayPrompt, 360) : safePreview(displayPrompt, 2000),
|
||||
promptChars: task.prompt.length,
|
||||
basePromptChars: task.basePrompt.length,
|
||||
displayPromptChars: displayPrompt.length,
|
||||
...promptFields,
|
||||
promptEditable: queuedTaskPromptEditable(task),
|
||||
finalResponseChars: task.finalResponse.length,
|
||||
stepCount: numberField(task.stepCount ?? task.llmStepCount, 0),
|
||||
@@ -1695,6 +1685,8 @@ function taskMetaResponse(task: QueueTask): JsonRecord {
|
||||
...taskListResponse(task, false),
|
||||
prompt: task.prompt,
|
||||
basePrompt: task.basePrompt,
|
||||
displayPrompt: task.basePrompt || userPromptForDisplay(task.prompt),
|
||||
initialPrompt: task.prompt,
|
||||
finalResponse: task.finalResponse,
|
||||
promptHistory: toJsonValue(task.promptHistory),
|
||||
attempts: toJsonValue(task.attempts),
|
||||
|
||||
Reference in New Issue
Block a user