mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:20:04 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { getPartner } from "@/lib/partners-api";
|
|
import { getPartnerGroup } from "@/lib/partner-groups-api";
|
|
|
|
/** Read the same per-turn snapshot used for retry, including restored history. */
|
|
export function useConsultationReference(config?: Record<string, unknown>) {
|
|
const groupId = config?.partner_discussion_group_id;
|
|
const partnerId = config?.consult_partner_id;
|
|
const kind = typeof groupId === "string" && groupId ? "partner_group" : "partner";
|
|
const value = kind === "partner_group" ? groupId : partnerId;
|
|
const id = typeof value === "string" ? value : "";
|
|
const key = `${kind}:${id}`;
|
|
const [resolved, setResolved] = useState({ key: "", name: "" });
|
|
|
|
useEffect(() => {
|
|
if (!id) return;
|
|
let active = true;
|
|
const request = kind === "partner_group" ? getPartnerGroup(id) : getPartner(id);
|
|
void request.then(entity => {
|
|
if (active) setResolved({ key, name: entity.name });
|
|
}).catch(() => {
|
|
// Deleted or unavailable resources still appear by their stored identity.
|
|
});
|
|
return () => { active = false; };
|
|
}, [id, key, kind]);
|
|
|
|
return id ? { id, kind, name: resolved.key === key ? resolved.name : id } : null;
|
|
}
|