Fix dead Unreal plugin actions, sync toast flood, Team Relay theming
- ue bridge: Launch / Build now read live refs. They captured startBuild / launchUE from the render where plugins loaded — before the async .uproject and .sln detection had resolved — so both saw empty paths forever. hasProject used the live ref, so the menu items showed up and then did nothing. - Get Latest / Sync to revision: summarise `p4 sync` stdout (syncSummary) instead of dumping every depot path into the toast. flash() caps length and .toast caps height so no raw output can blow up the bubble again. - Team Relay: use the real theme tokens — --txt / --add / --del, not --text / --ok / --err, which don't exist and silently fell back to a near-white hardcode, invisible on the light theme. Bumped to 1.0.1. - Plugin dock panels get a status-bar button next to Terminal / Log; the tabs were otherwise only reachable from the Actions menu. - PLUGINS.md documents the theme token names. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
45
src/App.tsx
45
src/App.tsx
@ -9,7 +9,7 @@ import ModelViewer from "./ModelViewer";
|
||||
import CodeView from "./CodeView";
|
||||
import { useUpdater } from "./Updater";
|
||||
import "./App.css";
|
||||
import { p4, statusOf, splitPath, kindOf, isCodeFile, fmtTime, describeFiles, filelogRevs, humanSize, leaf, saveSession, loadSession, clearSession, saveScope, loadScope, recentScopes, pushRecentScope, fileBytes, getEditor, setEditorPref, P4Info, OpenedFile, Client, Change, Session, Describe, Dir, User, Editor, FileRev, FsEntry, PluginInfo } from "./p4";
|
||||
import { p4, statusOf, splitPath, kindOf, isCodeFile, fmtTime, describeFiles, filelogRevs, humanSize, leaf, syncSummary, saveSession, loadSession, clearSession, saveScope, loadScope, recentScopes, pushRecentScope, fileBytes, getEditor, setEditorPref, P4Info, OpenedFile, Client, Change, Session, Describe, Dir, User, Editor, FileRev, FsEntry, PluginInfo } from "./p4";
|
||||
import { t, LANG, LANGS, setLangGlobal, Lang } from "./i18n";
|
||||
import { Theme, THEME_TOKENS, BUILTIN_THEMES, allThemes, loadCustomThemes, saveCustomThemes, loadActiveId, saveActiveId, resolveTheme, applyTheme, tokenValue, newCustomId, exportTheme, importTheme } from "./themes";
|
||||
import { loadPlugins, getRegistry, subscribeRegistry, runSubmitHooks, PluginView, PluginDock, fetchRegistry, installFromRegistry, RegistryEntry } from "./plugins";
|
||||
@ -401,6 +401,7 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
const [uproject, setUproject] = useState(""); // local .uproject path when the scope is a UE project
|
||||
const uprojectRef = useRef(""); // live mirror for the plugin ue-bridge closures
|
||||
const [slnPath, setSlnPath] = useState(""); // local .sln path in the scope (for building)
|
||||
const slnPathRef = useRef(""); // live mirror for the plugin ue-bridge closures
|
||||
const [editors, setEditors] = useState<Editor[]>([]); // code editors installed on this machine
|
||||
const [editorId, setEditorId] = useState(getEditor()); // chosen editor id ("" → auto-pick)
|
||||
const [others, setOthers] = useState<Map<string, { user: string; locked: boolean }>>(new Map()); // files opened/locked by OTHER users
|
||||
@ -483,8 +484,12 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
document.body.classList.add("resizing-v");
|
||||
}
|
||||
|
||||
// A toast is one line of feedback, never a report: cap it so a raw p4 dump or a
|
||||
// long server error can't grow the bubble over the whole window. Full output
|
||||
// always stays available in the Log dock.
|
||||
function flash(text: string, err = false) {
|
||||
setToast({ text, err });
|
||||
const one = (text || "").trim();
|
||||
setToast({ text: one.length > 220 ? one.slice(0, 220).trimEnd() + "…" : one, err });
|
||||
setTimeout(() => setToast(null), 4500);
|
||||
}
|
||||
function confirm(opts: { title: string; body: string; confirm: string; danger?: boolean }): Promise<boolean> {
|
||||
@ -653,7 +658,11 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
setPluginVer((v) => v + 1);
|
||||
return res;
|
||||
}
|
||||
useEffect(() => { uprojectRef.current = uproject; }, [uproject]); // keep the ue-bridge mirror live
|
||||
// keep the ue-bridge mirrors live: the bridge closures are built once (plugins
|
||||
// load as soon as we have a workspace) but the paths are detected later, per
|
||||
// working folder — so the bridge must read refs, never captured state.
|
||||
useEffect(() => { uprojectRef.current = uproject; }, [uproject]);
|
||||
useEffect(() => { slnPathRef.current = slnPath; }, [slnPath]);
|
||||
useEffect(() => {
|
||||
if (pluginsLoaded.current || !info?.clientName) return;
|
||||
pluginsLoaded.current = true;
|
||||
@ -952,7 +961,7 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
|
||||
async function getLatest() {
|
||||
setBusy(true);
|
||||
try { flash(t("Get Latest: {msg}", { msg: await p4.sync(activePath) })); await refresh(); await loadHistory(); behindRef.current = 0; setBehind(null); } // sync may pull new submitted changelists → refresh History too
|
||||
try { flash(t("Get Latest: {msg}", { msg: syncSummary(await p4.sync(activePath)) })); await refresh(); await loadHistory(); behindRef.current = 0; setBehind(null); } // sync may pull new submitted changelists → refresh History too
|
||||
catch (e) { flash(String(e), true); setBusy(false); }
|
||||
}
|
||||
// check whether the server has newer content than my workspace (files behind)
|
||||
@ -976,7 +985,7 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
if (!r) return;
|
||||
if (!(await confirm({ title: t("Sync workspace to {rev}?", { rev: r }), body: t("Your synced files change to match {rev}. Un-submitted (opened) work is not touched. You can Get Latest to return to head.", { rev: r }), confirm: t("Sync") }))) return;
|
||||
setBusy(true);
|
||||
try { flash(t("Synced to {rev}: {msg}", { rev: r, msg: await p4.syncTo(activePath, r) })); await refresh(); await loadHistory(); }
|
||||
try { flash(t("Synced to {rev}: {msg}", { rev: r, msg: syncSummary(await p4.syncTo(activePath, r)) })); await refresh(); await loadHistory(); }
|
||||
catch (e) { flash(String(e), true); setBusy(false); }
|
||||
}
|
||||
function promptSyncTo() {
|
||||
@ -1036,25 +1045,29 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
|
||||
function openCtx(e: ReactMouseEvent, items: CtxItem[]) { e.preventDefault(); e.stopPropagation(); setCtx({ x: e.clientX, y: e.clientY, items }); }
|
||||
|
||||
// launch Unreal by opening the detected .uproject (file association starts UE)
|
||||
// launch Unreal by opening the detected .uproject (file association starts UE).
|
||||
// Reads the ref, not the state: the plugin ue-bridge calls this through a
|
||||
// closure captured before the project was detected.
|
||||
async function launchUE() {
|
||||
if (!uproject) return;
|
||||
try { await p4.launchFile(uproject); flash(t("Launching Unreal…")); }
|
||||
const up = uprojectRef.current;
|
||||
if (!up) { flash(t("No Unreal project in the working folder. Choose the project folder first."), true); return; }
|
||||
try { await p4.launchFile(up); flash(t("Launching Unreal…")); }
|
||||
catch (e) { flash(String(e), true); }
|
||||
}
|
||||
|
||||
// open the configuration picker (Development / Shipping / …) before building
|
||||
function startBuild() {
|
||||
if (!slnPath && !uproject) { flash(t("No .sln found in the working folder. Choose the project folder first."), true); return; }
|
||||
if (!slnPathRef.current && !uprojectRef.current) { flash(t("No .sln found in the working folder. Choose the project folder first."), true); return; }
|
||||
setBuildPick(true);
|
||||
}
|
||||
// build with the chosen UE configuration, live output. For a real UE project we
|
||||
// pass the .uproject so the backend builds the game module via UnrealBuildTool.
|
||||
async function buildSln(config: string) {
|
||||
setBuildPick(false);
|
||||
if (!slnPath && !uproject) return;
|
||||
const sln = slnPathRef.current, up = uprojectRef.current;
|
||||
if (!sln && !up) return;
|
||||
setBuildLog([]); setBuildOk(null); setBuilding(true); setBuildOpen(true); setBuildMin(false);
|
||||
try { await p4.buildSln(slnPath, config, uproject); }
|
||||
try { await p4.buildSln(sln, config, up); }
|
||||
catch { /* the overlay already shows the failure line */ }
|
||||
}
|
||||
|
||||
@ -1719,6 +1732,16 @@ function Workbench({ info, session, light, toggleTheme, themeId, setThemeId, lan
|
||||
<span className="stlast">{logs.length ? `${logs[logs.length - 1].cmd} ${logCount(logs[logs.length - 1])}` : "p4 — ready"}</span>
|
||||
</span>
|
||||
<span className="stspace" />
|
||||
{/* Plugin dock panels get a status-bar button too — a dock tab you can't
|
||||
open from anywhere is just a hidden tab. Listed before the built-ins so
|
||||
Terminal/Log keep their place as plugins come and go. */}
|
||||
{getRegistry().docks.map((d) => (
|
||||
<button key={`${d.pluginId}:${d.id}`} className="stlog"
|
||||
onClick={() => openDock(`plugin:${d.id}`)}
|
||||
title={t("From plugin: {p}", { p: d.pluginId })}>
|
||||
{pluginIcon(d.icon)}<span>{d.title}</span>
|
||||
</button>
|
||||
))}
|
||||
<button className="stlog" onClick={() => openDock("terminal")} title="Ctrl+`">{I.terminal}<span>{t("Terminal")}</span></button>
|
||||
<button className="stlog" onClick={() => openDock("log")} title="Ctrl+L">{I.log}<span>Log</span></button>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user