@rigkit/provider-freestyle 0.2.2 → 0.2.4

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.
@@ -22,8 +22,8 @@ describe("Freestyle terminal session", () => {
22
22
  expect(html).toContain("@wterm/dom");
23
23
  expect(html).toContain("@wterm/ghostty");
24
24
  expect(html).toContain("terminal-window");
25
- expect(html).toContain("light red");
26
- expect(html).toContain("Finished");
25
+ expect(html).toContain("freestyle.sh");
26
+ expect(html).toContain("Complete task");
27
27
  expect(html).toContain("document.addEventListener(\"keydown\"");
28
28
  expect(html).toContain("{ capture: true }");
29
29
  expect(html).toContain("terminalEl.contains(target)");
@@ -102,6 +102,46 @@ describe("Freestyle terminal session", () => {
102
102
  }
103
103
  });
104
104
 
105
+ test("can allow finishing while the terminal process is still running", async () => {
106
+ const session = createFreestyleTerminalSession({
107
+ nodePath: "login",
108
+ title: "Keep-open command",
109
+ command: "sleep 5",
110
+ displayCommand: "sleep 5",
111
+ canFinishWhileRunning: true,
112
+ });
113
+
114
+ let resolved = false;
115
+ session.completed.then(() => {
116
+ resolved = true;
117
+ });
118
+
119
+ try {
120
+ const messages: unknown[] = [];
121
+ const socketUrl = new URL(session.url.replace("/?", "/terminal?"));
122
+ socketUrl.protocol = "ws:";
123
+ const socket = new WebSocket(socketUrl);
124
+ socket.addEventListener("message", (event) => {
125
+ messages.push(JSON.parse(String(event.data)));
126
+ });
127
+
128
+ await waitForSocketOpen(socket);
129
+ await waitFor(() =>
130
+ messages.some((message) =>
131
+ isMessage(message, "status") && Boolean(message.canFinish)
132
+ ),
133
+ );
134
+ await new Promise((resolve) => setTimeout(resolve, 25));
135
+ expect(resolved).toBe(false);
136
+
137
+ socket.send(JSON.stringify({ type: "finish" }));
138
+ await expect(session.completed).resolves.toEqual({ finished: true });
139
+ socket.close();
140
+ } finally {
141
+ session.stop();
142
+ }
143
+ });
144
+
105
145
  test("answers cursor position reports for terminal UI prompts", async () => {
106
146
  const session = createFreestyleTerminalSession({
107
147
  nodePath: "prompt",