newpr 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newpr",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AI-powered large PR review tool - understand PRs with 1000+ lines of changes",
5
5
  "module": "src/cli/index.ts",
6
6
  "type": "module",
@@ -16,7 +16,7 @@ import { chatWithTools, createLlmClient, type ChatTool, type ChatStreamEvent } f
16
16
  import { detectAgents, runAgent } from "../../workspace/agent.ts";
17
17
  import { randomBytes } from "node:crypto";
18
18
  import { publishStack } from "../../stack/publish.ts";
19
- import { startStack, getStackState, cancelStack, subscribeStack } from "./stack-manager.ts";
19
+ import { startStack, getStackState, cancelStack, subscribeStack, restoreCompletedStacks } from "./stack-manager.ts";
20
20
 
21
21
  function json(data: unknown, status = 200): Response {
22
22
  return new Response(JSON.stringify(data), {
@@ -1719,10 +1719,14 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
1719
1719
  }
1720
1720
  },
1721
1721
 
1722
- "GET /api/stack/:id": (req: Request) => {
1722
+ "GET /api/stack/:id": async (req: Request) => {
1723
1723
  const url = new URL(req.url);
1724
1724
  const id = url.pathname.split("/").pop()!;
1725
- const state = getStackState(id);
1725
+ let state = getStackState(id);
1726
+ if (!state) {
1727
+ await restoreCompletedStacks([id]);
1728
+ state = getStackState(id);
1729
+ }
1726
1730
  if (!state) return json({ state: null });
1727
1731
  return json({ state });
1728
1732
  },
@@ -1794,7 +1798,11 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
1794
1798
  const body = await req.json() as { sessionId: string };
1795
1799
  if (!body.sessionId) return json({ error: "Missing sessionId" }, 400);
1796
1800
 
1797
- const state = getStackState(body.sessionId);
1801
+ let state = getStackState(body.sessionId);
1802
+ if (!state) {
1803
+ await restoreCompletedStacks([body.sessionId]);
1804
+ state = getStackState(body.sessionId);
1805
+ }
1798
1806
  if (!state) return json({ error: "No stack state found" }, 404);
1799
1807
  if (!state.execResult) return json({ error: "Stack not executed yet" }, 400);
1800
1808
  if (!state.context) return json({ error: "Missing context" }, 400);