Use real IDE authoring session
This commit is contained in:
@@ -39,6 +39,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import {
|
||||
applyAuthoringChangeSet,
|
||||
ensureAuthoringSession,
|
||||
getAuthoringSemanticDiffPreview,
|
||||
applyAuthoringMetadataObject,
|
||||
applyAuthoringRollback,
|
||||
@@ -2048,8 +2049,7 @@ function EditorPanel({
|
||||
routine_name: data.editorSelectedRoutine ?? data.authoringPreview?.context.routine?.name ?? null,
|
||||
original_text: data.editorSourceText,
|
||||
proposed_text: nextProposedText,
|
||||
task_id: "task.preview",
|
||||
session_id: "session.preview"
|
||||
...(await ensureAuthoringSession(data.projectId, data.apiUrl))
|
||||
},
|
||||
data.apiUrl
|
||||
);
|
||||
@@ -2175,6 +2175,7 @@ function EditorPanel({
|
||||
const apiUrl =
|
||||
data.apiUrl ??
|
||||
(typeof window === "undefined" ? resolveApiUrl() : resolveApiUrl(window.location.host));
|
||||
const authoringSession = await ensureAuthoringSession(data.projectId, apiUrl);
|
||||
const response = await applyAuthoringChangeSet(
|
||||
data.projectId,
|
||||
{
|
||||
@@ -2182,12 +2183,12 @@ function EditorPanel({
|
||||
routine_name: data.editorSelectedRoutine ?? data.authoringPreview?.context.routine?.name ?? null,
|
||||
original_text: data.editorSourceText ?? sourceText,
|
||||
proposed_text: proposedText ?? sourceText,
|
||||
task_id: null,
|
||||
session_id: "session.ide",
|
||||
user_id: "current-user",
|
||||
task_id: authoringSession.task_id,
|
||||
session_id: authoringSession.session_id,
|
||||
user_id: authoringSession.user_id,
|
||||
estimated_tokens: 2550,
|
||||
expected_next_version_id: versionPreview.next_version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.guardedApplyNote,
|
||||
apply_to_production: false
|
||||
},
|
||||
@@ -2200,7 +2201,7 @@ function EditorPanel({
|
||||
status: response.status,
|
||||
target: response.preview.target,
|
||||
version_id: response.version.version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.guardedApplyNote,
|
||||
task_id: response.version.task_id,
|
||||
session_id: response.version.session_id,
|
||||
@@ -3261,10 +3262,7 @@ function MetadataDesignerPanel({
|
||||
.map((command) => ({
|
||||
name: command.name.trim(),
|
||||
handler: command.handler.trim() || null
|
||||
})),
|
||||
task_id: null,
|
||||
session_id: "session.ide.metadata",
|
||||
user_id: "current-user"
|
||||
}))
|
||||
};
|
||||
const [draftState, setDraftState] = useState<"idle" | "previewing" | "applying" | "applied" | "error">("idle");
|
||||
const [draftMessage, setDraftMessage] = useState("");
|
||||
@@ -3311,15 +3309,17 @@ function MetadataDesignerPanel({
|
||||
const apiUrl =
|
||||
data.apiUrl ??
|
||||
(typeof window === "undefined" ? resolveApiUrl() : resolveApiUrl(window.location.host));
|
||||
const preview = await getAuthoringMetadataObjectPreview(data.projectId, metadataDraft, apiUrl);
|
||||
const authoringSession = await ensureAuthoringSession(data.projectId, apiUrl);
|
||||
const sessionDraft = { ...metadataDraft, ...authoringSession };
|
||||
const preview = await getAuthoringMetadataObjectPreview(data.projectId, sessionDraft, apiUrl);
|
||||
setDraftDiff(preview.semantic_diff);
|
||||
setDraftState("applying");
|
||||
const response = await applyAuthoringMetadataObject(
|
||||
data.projectId,
|
||||
{
|
||||
...metadataDraft,
|
||||
...sessionDraft,
|
||||
expected_next_version_id: preview.version_preview.next_version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.metadataDraftDescription,
|
||||
apply_to_production: false
|
||||
},
|
||||
@@ -3332,7 +3332,7 @@ function MetadataDesignerPanel({
|
||||
status: response.status,
|
||||
target: response.preview.target,
|
||||
version_id: response.version.version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.metadataDraftDescription,
|
||||
task_id: response.version.task_id,
|
||||
session_id: response.version.session_id,
|
||||
@@ -4469,15 +4469,16 @@ function HistoryPanel({
|
||||
setRollbackState("applying");
|
||||
setRollbackMessage("");
|
||||
try {
|
||||
const authoringSession = await ensureAuthoringSession(data.projectId, data.apiUrl);
|
||||
const response = await applyAuthoringRollback(
|
||||
data.projectId,
|
||||
rollbackPreview.change_id,
|
||||
{
|
||||
expected_rollback_version_id: rollbackPreview.rollback_version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.rollbackApplyNote,
|
||||
task_id: null,
|
||||
session_id: "session.ide.rollback",
|
||||
task_id: authoringSession.task_id,
|
||||
session_id: authoringSession.session_id,
|
||||
apply_to_production: false
|
||||
},
|
||||
data.apiUrl
|
||||
@@ -4489,7 +4490,7 @@ function HistoryPanel({
|
||||
status: response.status,
|
||||
target: response.preview.target,
|
||||
version_id: response.version.version_id,
|
||||
approved_by: "current-user",
|
||||
approved_by: authoringSession.user_id,
|
||||
approval_note: t.rollbackApplyNote,
|
||||
task_id: response.version.task_id,
|
||||
session_id: response.version.session_id,
|
||||
|
||||
Reference in New Issue
Block a user