@qablehq/atto 0.0.5 → 0.0.7

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/out/main/index.js CHANGED
@@ -3133,7 +3133,9 @@ function asProjects(value) {
3133
3133
  id: row.id,
3134
3134
  key: typeof row.key === "string" ? row.key : "",
3135
3135
  name: row.name,
3136
- role: typeof row.role === "string" ? row.role : "member"
3136
+ role: typeof row.role === "string" ? row.role : "member",
3137
+ clientName: typeof row.clientName === "string" ? row.clientName : void 0,
3138
+ userName: typeof row.userName === "string" ? row.userName : void 0
3137
3139
  });
3138
3140
  }
3139
3141
  return projects;
@@ -3145,15 +3147,22 @@ async function loadAccount(link) {
3145
3147
  return disconnected(await errorMessage(response));
3146
3148
  }
3147
3149
  if (!response.ok) throw new Error(await errorMessage(response));
3150
+ const projects = asProjects(await response.json());
3148
3151
  return {
3149
3152
  connected: true,
3150
3153
  baseUrl: link.baseUrl,
3151
- user: null,
3154
+ user: signedInUser(projects),
3152
3155
  workspaces: [],
3153
- projects: asProjects(await response.json()),
3156
+ projects,
3154
3157
  error: null
3155
3158
  };
3156
3159
  }
3160
+ function signedInUser(projects) {
3161
+ const project = projects.find((item) => item.userName || item.clientName);
3162
+ if (!project) return null;
3163
+ const name = [project.userName, project.clientName].filter(Boolean).join(" · ");
3164
+ return { userId: project.userName || project.clientName || "", email: null, name: name || null };
3165
+ }
3157
3166
  async function tesboStatus() {
3158
3167
  const link = readLink();
3159
3168
  if (!link) return disconnected();
@@ -3174,12 +3183,13 @@ async function tesboLogin(cmd) {
3174
3183
  });
3175
3184
  if (!response.ok) throw new Error(await errorMessage(response));
3176
3185
  writeLink(link);
3186
+ const projects = asProjects(await response.json());
3177
3187
  return {
3178
3188
  connected: true,
3179
3189
  baseUrl: link.baseUrl,
3180
- user: null,
3190
+ user: signedInUser(projects),
3181
3191
  workspaces: [],
3182
- projects: asProjects(await response.json()),
3192
+ projects,
3183
3193
  error: null
3184
3194
  };
3185
3195
  }
@@ -12067,7 +12077,85 @@ function updateFeedUrl() {
12067
12077
  if (process.platform === "linux") return LINUX_FEED;
12068
12078
  return WINDOWS_FEED;
12069
12079
  }
12080
+ function readPackageName() {
12081
+ const require2 = node_module.createRequire(__filename);
12082
+ const pkg = require2(node_path.join(__dirname, "../../package.json"));
12083
+ return pkg.name ?? "@qablehq/atto";
12084
+ }
12085
+ function isNewerVersion(latest, current) {
12086
+ const parse = (value) => value.split(".").map((part) => Number.parseInt(part, 10) || 0);
12087
+ const next = parse(latest);
12088
+ const now = parse(current);
12089
+ for (let i = 0; i < 3; i += 1) {
12090
+ const a = next[i] ?? 0;
12091
+ const b = now[i] ?? 0;
12092
+ if (a > b) return true;
12093
+ if (a < b) return false;
12094
+ }
12095
+ return false;
12096
+ }
12097
+ function registryLatestUrl(name) {
12098
+ if (name.startsWith("@")) {
12099
+ return `https://registry.npmjs.org/${name.replace("/", "%2f")}/latest`;
12100
+ }
12101
+ return `https://registry.npmjs.org/${name}/latest`;
12102
+ }
12103
+ function detectNpmPrefix() {
12104
+ const packageRoot = node_path.join(__dirname, "../..");
12105
+ const needle = `${node_path.sep}node_modules${node_path.sep}`;
12106
+ const index = packageRoot.lastIndexOf(needle);
12107
+ if (index < 0) return void 0;
12108
+ const beforeModules = packageRoot.slice(0, index);
12109
+ const libSuffix = `${node_path.sep}lib`;
12110
+ if (beforeModules.endsWith(libSuffix)) {
12111
+ return beforeModules.slice(0, -libSuffix.length);
12112
+ }
12113
+ return beforeModules;
12114
+ }
12115
+ function setupNpmUpdater() {
12116
+ const name = readPackageName();
12117
+ let pending = null;
12118
+ const prefix = detectNpmPrefix();
12119
+ electron.app.on("before-quit", () => {
12120
+ if (!pending) return;
12121
+ const version = pending;
12122
+ pending = null;
12123
+ const npm = process.platform === "win32" ? "npm.cmd" : "npm";
12124
+ const args = ["install", "-g", `${name}@${version}`];
12125
+ if (prefix) args.push("--prefix", prefix);
12126
+ console.log(
12127
+ `[npm-updater] installing ${name}@${version}${prefix ? ` --prefix ${prefix}` : ""} after quit`
12128
+ );
12129
+ const child = node_child_process.spawn(npm, args, {
12130
+ detached: true,
12131
+ stdio: "ignore",
12132
+ windowsHide: true
12133
+ });
12134
+ child.unref();
12135
+ });
12136
+ const current = electron.app.getVersion();
12137
+ void (async () => {
12138
+ const controller = new AbortController();
12139
+ const timer = setTimeout(() => controller.abort(), 15e3);
12140
+ try {
12141
+ const response = await fetch(registryLatestUrl(name), { signal: controller.signal });
12142
+ if (!response.ok) return;
12143
+ const body = await response.json();
12144
+ if (!body.version || !isNewerVersion(body.version, current)) return;
12145
+ pending = body.version;
12146
+ console.log(`[npm-updater] ${body.version} will install quietly on quit`);
12147
+ } catch (error) {
12148
+ console.error("[npm-updater] check failed", error);
12149
+ } finally {
12150
+ clearTimeout(timer);
12151
+ }
12152
+ })();
12153
+ }
12070
12154
  function setupAutoUpdater() {
12155
+ if (process.env.ATTO_NPM_PACKAGE === "1") {
12156
+ setupNpmUpdater();
12157
+ return;
12158
+ }
12071
12159
  if (!electron.app.isPackaged) {
12072
12160
  return;
12073
12161
  }
@@ -33024,6 +33024,7 @@ function CreateProjectDialog({ open, onOpenChange, onCreated }) {
33024
33024
  }
33025
33025
  );
33026
33026
  }
33027
+ const REFRESH_MS = 5e3;
33027
33028
  const STATUS_LABEL$1 = {
33028
33029
  active: "Active",
33029
33030
  inactive: "Inactive",
@@ -33036,16 +33037,33 @@ function TesboPanel() {
33036
33037
  const [formError, setFormError] = reactExports.useState(null);
33037
33038
  const [projectId, setProjectId] = reactExports.useState("");
33038
33039
  const [agents, setAgents] = reactExports.useState(null);
33040
+ const statusRef = reactExports.useRef(null);
33041
+ const refreshGeneration = reactExports.useRef(0);
33039
33042
  reactExports.useEffect(() => {
33040
33043
  let cancelled = false;
33041
- void window.taa.tesbo.status().then((next) => {
33042
- if (cancelled) return;
33044
+ const apply = (next, stamp) => {
33045
+ if (cancelled || stamp !== refreshGeneration.current) return;
33046
+ const offline = !next.connected && next.error === "Could not reach Tesbo.";
33047
+ if (offline && statusRef.current?.connected) return;
33048
+ statusRef.current = next;
33043
33049
  setStatus(next);
33044
- setProjectId(next.projects[0]?.id ?? "");
33050
+ setProjectId(
33051
+ (current) => next.projects.some((project) => project.id === current) ? current : next.projects[0]?.id ?? ""
33052
+ );
33053
+ if (!next.connected) setAgents(null);
33045
33054
  if (next.error) setFormError(next.error);
33046
- });
33055
+ };
33056
+ const refresh = () => {
33057
+ const stamp = refreshGeneration.current;
33058
+ void window.taa.tesbo.status().then((next) => apply(next, stamp));
33059
+ };
33060
+ refresh();
33061
+ const timer = window.setInterval(refresh, REFRESH_MS);
33062
+ window.addEventListener("focus", refresh);
33047
33063
  return () => {
33048
33064
  cancelled = true;
33065
+ window.clearInterval(timer);
33066
+ window.removeEventListener("focus", refresh);
33049
33067
  };
33050
33068
  }, []);
33051
33069
  reactExports.useEffect(() => {
@@ -33069,7 +33087,9 @@ function TesboPanel() {
33069
33087
  setBusy(true);
33070
33088
  setFormError(null);
33071
33089
  try {
33090
+ refreshGeneration.current += 1;
33072
33091
  const next = await window.taa.tesbo.login({ code });
33092
+ statusRef.current = next;
33073
33093
  setStatus(next);
33074
33094
  setCode("");
33075
33095
  setProjectId(next.projects[0]?.id ?? "");
@@ -33084,7 +33104,9 @@ function TesboPanel() {
33084
33104
  setBusy(true);
33085
33105
  setFormError(null);
33086
33106
  try {
33107
+ refreshGeneration.current += 1;
33087
33108
  const next = await window.taa.tesbo.logout();
33109
+ statusRef.current = next;
33088
33110
  setStatus(next);
33089
33111
  setAgents(null);
33090
33112
  setProjectId("");
@@ -33096,7 +33118,8 @@ function TesboPanel() {
33096
33118
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
33097
33119
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33098
33120
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-sm font-semibold", children: "Tesbo projects" }),
33099
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Paste the access code from your QAble contact. Atto does not open the Tesbo website." })
33121
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Paste the access code from your QAble contact. Atto does not open the Tesbo website." }),
33122
+ status?.connected && status.user?.name && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-sm text-foreground", children: status.user.name })
33100
33123
  ] }),
33101
33124
  status?.connected && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", variant: "outline", onClick: () => void disconnect(), disabled: busy, children: "Disconnect" })
33102
33125
  ] }),
@@ -33126,7 +33149,7 @@ function TesboPanel() {
33126
33149
  ]
33127
33150
  }
33128
33151
  ) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 grid gap-3", children: [
33129
- status.projects.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "No project is turned on for this code. It will appear here the next time Atto opens after it is turned on." }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "grid max-w-md gap-1 text-xs text-muted-foreground", children: [
33152
+ status.projects.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "No project is turned on for this code. It appears here when the project is turned on." }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "grid max-w-md gap-1 text-xs text-muted-foreground", children: [
33130
33153
  "Project",
33131
33154
  /* @__PURE__ */ jsxRuntimeExports.jsx(
33132
33155
  "select",
@@ -8,7 +8,7 @@
8
8
  />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Tesbo Automate</title>
11
- <script type="module" crossorigin src="./assets/index-Dbnqlx4f.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-CWoTAmL0.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-CKtSvvUQ.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Atto — AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {