Skip to content

Commit

Permalink
fix: load thread dir env var after server start
Browse files Browse the repository at this point in the history
Since the THREADS_DIR environment variable is retrieved on package
import, changes that dependents make to it before startAppServer is
called are ignored. To fix this, load the environment variable
immediately before it's used instead.

Signed-off-by: Nick Hale <[email protected]>
  • Loading branch information
njhale committed Jul 23, 2024
1 parent 67a41e8 commit 9b50bdd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const AGENT = 1;
const USER = 2;
const STATE_FILE = "state.json";
const DISABLE_CACHE = process.env.DISABLE_CACHE === "true";
let THREADS_DIR = process.env.THREADS_DIR || "";
let runningScript = null;
let serverRunning = false;

Expand Down Expand Up @@ -85,6 +84,7 @@ const mount = async (file, tool, args, workspace, socket, threadID, gptscript) =

let state = {};
let statePath = '';
let THREADS_DIR = process.env.THREADS_DIR
if (!THREADS_DIR) THREADS_DIR = path.join(workspace, "threads");
if (threadID) statePath = path.join(THREADS_DIR, threadID, STATE_FILE);
try {
Expand Down

0 comments on commit 9b50bdd

Please sign in to comment.