aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/zenserverprocess.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-04-20 15:53:22 +0200
committerGitHub Enterprise <[email protected]>2026-04-20 15:53:22 +0200
commit28a61b12d302e9e0d37d52bf1aa5d19069f3411b (patch)
tree07cd367f4933364781ea69c350025b1b6b703174 /src/zenutil/zenserverprocess.cpp
parentzen-test: add CLI integration harness + TestArtifactProvider + CI host stats ... (diff)
downloadarchived-zen-28a61b12d302e9e0d37d52bf1aa5d19069f3411b.tar.xz
archived-zen-28a61b12d302e9e0d37d52bf1aa5d19069f3411b.zip
zen history command (#987)
- Feature: Per-user invocation history for `zen` and `zenserver`; each startup appends a record to a JSONL file capped at the most recent 100 entries. Location: `%LOCALAPPDATA%\Epic\Zen\History\invocations.jsonl` on Windows, `~/.zen/History/invocations.jsonl` on POSIX - `zen history` opens an interactive picker; selecting a zen row re-runs it inline and forwards the exit code, selecting a zenserver row spawns it detached - `zen history --list` (`-l`) prints the table to stdout instead of showing the picker - `zen history --filter zen|zenserver` restricts the listing to one executable - `zen history --print` prints the reconstructed command line of the selected row instead of launching it - `--enable-execution-history` global option on both binaries (default `true`) to opt out per invocation - The history file is attached to Sentry crash reports (alongside the existing zenserver log)
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
-rw-r--r--src/zenutil/zenserverprocess.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp
index e1ffeeb3e..2d4334ffa 100644
--- a/src/zenutil/zenserverprocess.cpp
+++ b/src/zenutil/zenserverprocess.cpp
@@ -1113,8 +1113,23 @@ ZenServerInstance::SpawnServerInternal(int ChildId, std::string_view ServerArgs,
ChildEventName << "Zen_Child_" << ChildId;
NamedEvent ChildEvent{ChildEventName};
+ const std::filesystem::path BaseDir = m_Env.ProgramBaseDir();
+ const std::filesystem::path Executable =
+ m_ServerExecutablePath.empty() ? (BaseDir / "zenserver" ZEN_EXE_SUFFIX_LITERAL) : m_ServerExecutablePath;
+
ExtendableStringBuilder<512> CommandLine;
- CommandLine << "zenserver" ZEN_EXE_SUFFIX_LITERAL; // see CreateProc() call for actual binary path
+ {
+ const std::string ExeUtf8 = PathToUtf8(Executable);
+ constexpr AsciiSet QuoteChars = " \t\"";
+ if (AsciiSet::HasAny(ExeUtf8.c_str(), QuoteChars))
+ {
+ CommandLine << '"' << ExeUtf8 << '"';
+ }
+ else
+ {
+ CommandLine << ExeUtf8;
+ }
+ }
if (m_ServerMode == ServerMode::kHubServer)
{
@@ -1127,6 +1142,11 @@ ZenServerInstance::SpawnServerInternal(int ChildId, std::string_view ServerArgs,
CommandLine << " --child-id " << ChildEventName;
+ if (!m_EnableExecutionHistory)
+ {
+ CommandLine << " --enable-execution-history=false";
+ }
+
if (!ServerArgs.empty())
{
CommandLine << " " << ServerArgs;
@@ -1141,10 +1161,6 @@ ZenServerInstance::SpawnServerInternal(int ChildId, std::string_view ServerArgs,
{
CreationFlags |= CreateProcOptions::Flag_NewConsole;
}
-
- const std::filesystem::path BaseDir = m_Env.ProgramBaseDir();
- const std::filesystem::path Executable =
- m_ServerExecutablePath.empty() ? (BaseDir / "zenserver" ZEN_EXE_SUFFIX_LITERAL) : m_ServerExecutablePath;
const std::filesystem::path OutputPath = (OpenConsole || m_Env.IsPassthroughOutput())
? std::filesystem::path{}
: std::filesystem::temp_directory_path() / ("zenserver_" + m_Name + ".log");
@@ -1647,6 +1663,7 @@ StartupZenServer(LoggerRef LogRef, const StartupZenServerOptions& Options)
ZenServerEnvironment ServerEnvironment;
ServerEnvironment.Initialize(ProgramBaseDir);
ZenServerInstance Server(ServerEnvironment, Options.Mode);
+ Server.SetEnableExecutionHistory(Options.EnableExecutionHistory);
std::string ServerArguments(Options.ExtraArgs);
if ((Options.Port != 0) && (ServerArguments.find("--port") == std::string::npos))