reflet-sdk 0.7.0 → 0.7.1

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/dist/feedback.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { n as Reflet } from "./client-oFFfRxAM.js";
3
- import { A as SquareIcon, C as ChevronDownIcon, D as MoreIcon, E as HighlightIcon, F as UndoIcon, H as MAX_SELECTION_COMMENT_LENGTH, I as isDegenerate, J as maskSecrets, L as normalizeRect, M as TargetIcon, N as TextIcon, O as PencilIcon, P as TrashIcon, R as DEFAULT_WIDGET_LABELS, S as CheckIcon, T as GripIcon, U as buildElementSelection, V as collectPageContext, _ as matchesHotkey, b as CameraIcon, c as useFloatingPosition, d as drawAnnotations, et as WIDGET_MARKER, f as listenOnPageAndWidget, g as isSubmitEnter, h as stopClicksAtHost, i as submitWidgetFeedback, it as releaseCapture, k as SpotlightIcon, n as createFeedbackTransport, o as ElementPicker, p as listenToKeydown, rt as capturedViewportSize, t as attachPreparedScreenshots, tt as captureViewport, v as ArrowIcon, w as CloseIcon, x as ChatIcon, y as BlurIcon, z as SDK_VERSION } from "./submit-CahCBj1P.js";
3
+ import { A as SquareIcon, C as ChevronDownIcon, D as MoreIcon, E as HighlightIcon, F as UndoIcon, H as MAX_SELECTION_COMMENT_LENGTH, I as isDegenerate, J as maskSecrets, L as normalizeRect, M as TargetIcon, N as TextIcon, O as PencilIcon, P as TrashIcon, R as DEFAULT_WIDGET_LABELS, S as CheckIcon, T as GripIcon, U as buildElementSelection, V as collectPageContext, _ as matchesHotkey, b as CameraIcon, c as useFloatingPosition, d as drawAnnotations, et as WIDGET_MARKER, f as listenOnPageAndWidget, g as isSubmitEnter, h as stopClicksAtHost, i as submitWidgetFeedback, it as releaseCapture, k as SpotlightIcon, n as createFeedbackTransport, o as ElementPicker, p as listenToKeydown, rt as capturedViewportSize, t as attachPreparedScreenshots, tt as captureViewport, v as ArrowIcon, w as CloseIcon, x as ChatIcon, y as BlurIcon, z as SDK_VERSION } from "./submit-DBy9TCSq.js";
4
4
  import { t as RefletContext } from "./react-context-Kazo_JCz.js";
5
5
  import { t as hasTeamActivation } from "./team-activation-DCqh71bl.js";
6
6
  import { t as SelectionOutline } from "./selection-outline-NzAAAZXR.js";
@@ -2303,7 +2303,7 @@ function useWidgetState(props) {
2303
2303
  setStep("compose");
2304
2304
  return submission.submit({
2305
2305
  context: {
2306
- ...activeScreenshot?.context ?? collectPageContext({ sdkVersion: "0.7.0" }),
2306
+ ...activeScreenshot?.context ?? collectPageContext({ sdkVersion: "0.7.1" }),
2307
2307
  consoleEvents: consoleRef.current?.events(),
2308
2308
  metadata: props.metadata,
2309
2309
  selections
@@ -2369,8 +2369,8 @@ function useWidgetState(props) {
2369
2369
  }
2370
2370
  //#endregion
2371
2371
  //#region src/feedback/widget.tsx
2372
- const DevtoolsLayer = process.env.NODE_ENV === "development" ? lazy(() => import("./devtools-layer-C3rMV03Q.js").then((module) => ({ default: module.DevtoolsLayer }))) : null;
2373
- const TeamLayer = lazy(() => import("./team-layer-gMWcOdCd.js").then((module) => ({ default: module.TeamLayer })));
2372
+ const DevtoolsLayer = process.env.NODE_ENV === "development" ? lazy(() => import("./devtools-layer-BI_hut0i.js").then((module) => ({ default: module.DevtoolsLayer }))) : null;
2373
+ const TeamLayer = lazy(() => import("./team-layer-D-6Il66z.js").then((module) => ({ default: module.TeamLayer })));
2374
2374
  const DEFAULT_APP_URL = "https://www.reflet.app";
2375
2375
  const ignoreChanges = () => () => void 0;
2376
2376
  /** Activation reads the URL and storage, which only exist in the browser: the server renders without team tools. */
@@ -1,5 +1,5 @@
1
1
  import { a as EDITORS, n as DEVTOOLS_REQUEST_HEADER, r as DEVTOOLS_ROUTE_BASE, t as DEVTOOLS_ENDPOINTS } from "./protocol-cJVVwnPe.js";
2
- import { B as clip, D as MoreIcon, G as describeElement, K as getElementRect, M as TargetIcon, R as DEFAULT_WIDGET_LABELS, T as GripIcon, W as buildSelector, Y as redactUrl, Z as inspectReactElement, _ as matchesHotkey, a as uploadBlob, c as useFloatingPosition, g as isSubmitEnter, it as releaseCapture, j as Svg, l as onViewportChange, m as startsInWidget, o as ElementPicker, p as listenToKeydown, q as REDACT_ATTRIBUTE, tt as captureViewport, u as visibleViewport, w as CloseIcon } from "./submit-CahCBj1P.js";
2
+ import { B as clip, D as MoreIcon, G as describeElement, K as getElementRect, M as TargetIcon, R as DEFAULT_WIDGET_LABELS, T as GripIcon, W as buildSelector, Y as redactUrl, Z as inspectReactElement, _ as matchesHotkey, a as uploadBlob, c as useFloatingPosition, g as isSubmitEnter, it as releaseCapture, j as Svg, l as onViewportChange, m as startsInWidget, o as ElementPicker, p as listenToKeydown, q as REDACT_ATTRIBUTE, tt as captureViewport, u as visibleViewport, w as CloseIcon } from "./submit-DBy9TCSq.js";
3
3
  import { t as REFLET_Z_INDEX } from "./z-index-CwokqVq_.js";
4
4
  import { z } from "zod";
5
5
  import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
@@ -2218,7 +2218,7 @@ async function openVoice() {
2218
2218
  };
2219
2219
  }
2220
2220
  }
2221
- function startCollectionRun(options) {
2221
+ function startCollectionRun$1(options) {
2222
2222
  let { voice } = options;
2223
2223
  voice?.attach({
2224
2224
  maxSegmentMs: options.maxSegmentMs,
@@ -2316,32 +2316,44 @@ function evidenceBase(trigger, request, options) {
2316
2316
  trigger
2317
2317
  };
2318
2318
  }
2319
+ function startCollectionRun() {
2320
+ let hasStopped = false;
2321
+ let markStopped = () => void 0;
2322
+ return {
2323
+ hasStopped: () => hasStopped,
2324
+ stop: () => {
2325
+ hasStopped = true;
2326
+ markStopped();
2327
+ },
2328
+ stopped: new Promise((resolve) => {
2329
+ markStopped = resolve;
2330
+ })
2331
+ };
2332
+ }
2319
2333
  function createEvidenceScheduler(options) {
2320
2334
  const { limits } = options;
2321
2335
  let captured = 0;
2322
2336
  let lastCaptureAtMs = Number.NEGATIVE_INFINITY;
2323
2337
  let navigationTimer;
2324
2338
  let previousCapture = Promise.resolve();
2325
- let collectionRun = 0;
2339
+ let collectionRun = startCollectionRun();
2326
2340
  const take = (trigger, request) => {
2327
2341
  if (captured >= limits.maxEvidence) return null;
2328
2342
  captured += 1;
2329
2343
  const base = evidenceBase(trigger, request, options);
2330
2344
  lastCaptureAtMs = base.atMs;
2331
- const takenInRun = collectionRun;
2332
- const isCurrent = () => takenInRun === collectionRun;
2345
+ const run = collectionRun;
2333
2346
  const stopped = withoutImage(base, STOPPED_BEFORE_CAPTURE);
2334
- const captureUnlessStopped = async () => {
2335
- const evidence = isCurrent() ? await shoot(base, options) : stopped;
2336
- return isCurrent() ? evidence : stopped;
2337
- };
2338
- previousCapture = previousCapture.then(captureUnlessStopped).then(options.onEvidence);
2347
+ const rendered = previousCapture.then(() => run.hasStopped() ? stopped : shoot(base, options));
2348
+ const reported = Promise.race([rendered, run.stopped.then(() => stopped)]).then((evidence) => options.onEvidence(run.hasStopped() ? stopped : evidence));
2349
+ previousCapture = Promise.all([rendered, reported]);
2339
2350
  return base.clientKey;
2340
2351
  };
2341
2352
  return {
2342
2353
  cancelPending: () => {
2343
2354
  window.clearTimeout(navigationTimer);
2344
- collectionRun += 1;
2355
+ collectionRun.stop();
2356
+ collectionRun = startCollectionRun();
2345
2357
  },
2346
2358
  capture: (request) => take(request.trigger, request),
2347
2359
  navigated: () => {
@@ -2628,7 +2640,7 @@ var LiveSession = class {
2628
2640
  const { limits } = this.options;
2629
2641
  const hasVoiceRoom = this.hasVoiceRoom();
2630
2642
  if (!hasVoiceRoom) voice.stop();
2631
- this.run = startCollectionRun({
2643
+ this.run = startCollectionRun$1({
2632
2644
  atMs: this.clock.atMs,
2633
2645
  collectEvents: !this.quota.stopped.has("events"),
2634
2646
  includeSource: this.options.includeSource,
@@ -4895,6 +4907,19 @@ function failedState(error, current) {
4895
4907
  message: failureMessage(error)
4896
4908
  };
4897
4909
  }
4910
+ function useLandedUploadTick() {
4911
+ const { account } = useSessionWorkspace();
4912
+ const { pendingOperations } = useSyncStatus(account.key);
4913
+ const [seen, setSeen] = useState({
4914
+ pending: pendingOperations,
4915
+ tick: 0
4916
+ });
4917
+ if (seen.pending !== pendingOperations) setSeen({
4918
+ pending: pendingOperations,
4919
+ tick: pendingOperations < seen.pending ? seen.tick + 1 : seen.tick
4920
+ });
4921
+ return seen.tick;
4922
+ }
4898
4923
  function useSessionDetail(sessionId) {
4899
4924
  const { api, onUnauthorized } = useSessionWorkspace();
4900
4925
  const [state, setState] = useState({ kind: "loading" });
@@ -4903,6 +4928,7 @@ function useSessionDetail(sessionId) {
4903
4928
  sessionId
4904
4929
  });
4905
4930
  const pollTick = usePollTick(state);
4931
+ const uploadTick = useLandedUploadTick();
4906
4932
  useEffect(() => {
4907
4933
  let isCurrent = true;
4908
4934
  api.detail(request.sessionId).then((detail) => isCurrent && setState({
@@ -4914,7 +4940,8 @@ function useSessionDetail(sessionId) {
4914
4940
  return;
4915
4941
  }
4916
4942
  if (isCurrent) setState((current) => failedState(error, current));
4917
- if (isCurrent && request.count + pollTick > 0) reportFailure("The session did not refresh", error);
4943
+ const isRefresh = request.count + pollTick + uploadTick > 0;
4944
+ if (isCurrent && isRefresh) reportFailure("The session did not refresh", error);
4918
4945
  });
4919
4946
  return () => {
4920
4947
  isCurrent = false;
@@ -4923,7 +4950,8 @@ function useSessionDetail(sessionId) {
4923
4950
  api,
4924
4951
  onUnauthorized,
4925
4952
  request,
4926
- pollTick
4953
+ pollTick,
4954
+ uploadTick
4927
4955
  ]);
4928
4956
  return {
4929
4957
  patch: (update) => setState((current) => current.kind === "ready" ? {
@@ -5442,9 +5470,6 @@ function useContributionActions({ context, continuation }) {
5442
5470
  detach: async () => {
5443
5471
  if (await runThenReload("The contribution was not removed", () => api.detachContribution(contributionId))) announce("This session's contribution was removed");
5444
5472
  },
5445
- retry: async () => {
5446
- await runThenReload("The comparison did not restart", () => api.analyze(sessionId));
5447
- },
5448
5473
  verify: async (status, note) => {
5449
5474
  if (intentionId && await runThenReload("The check was not saved", () => api.verifyProposal({
5450
5475
  note,
@@ -5614,40 +5639,16 @@ function ContinuationHeader({ continuation, onOpenSession }) {
5614
5639
  })]
5615
5640
  });
5616
5641
  }
5617
- function ContributionState({ scope }) {
5618
- const { actions, context, continuation } = scope;
5619
- const { contribution } = continuation;
5642
+ function ContributionState({ contribution }) {
5620
5643
  if (contribution.state === "recording") return /* @__PURE__ */ jsx("p", {
5621
5644
  className: "dt-status",
5622
5645
  children: "This session is still recording. What it changes appears once it ends."
5623
5646
  });
5624
- if (contribution.state === "analyzing") return /* @__PURE__ */ jsxs("p", {
5625
- className: "dt-status",
5626
- children: [
5627
- "Comparing with revision ",
5628
- contribution.baseRevision,
5629
- "…"
5630
- ]
5631
- });
5632
5647
  if (contribution.state === "no_change") return /* @__PURE__ */ jsx("p", {
5633
5648
  className: "dt-meta",
5634
5649
  children: "No change to the intention"
5635
5650
  });
5636
- if (contribution.state !== "failed") return null;
5637
- const reason = context.detail.session.analysis.error ?? "Unknown error.";
5638
- return /* @__PURE__ */ jsxs("div", {
5639
- className: "dt-actions",
5640
- role: "alert",
5641
- children: [/* @__PURE__ */ jsxs("p", {
5642
- className: "dt-error",
5643
- children: ["The comparison failed: ", reason]
5644
- }), context.canEdit && /* @__PURE__ */ jsx("button", {
5645
- className: "dt-btn",
5646
- onClick: actions.retry,
5647
- type: "button",
5648
- children: "Try again"
5649
- })]
5650
- });
5651
+ return null;
5651
5652
  }
5652
5653
  function DetachContribution({ scope }) {
5653
5654
  const [isConfirming, setIsConfirming] = useState(false);
@@ -5683,7 +5684,7 @@ function DetachContribution({ scope }) {
5683
5684
  function ContributionBody({ intention, scope }) {
5684
5685
  const { contribution } = scope.continuation;
5685
5686
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5686
- /* @__PURE__ */ jsx(ContributionState, { scope }),
5687
+ /* @__PURE__ */ jsx(ContributionState, { contribution }),
5687
5688
  contribution.stale && /* @__PURE__ */ jsxs("p", {
5688
5689
  className: "dt-ses-banner",
5689
5690
  role: "status",
@@ -7852,16 +7853,24 @@ function transcribingLine(detail) {
7852
7853
  if (busy.length === 0) return null;
7853
7854
  return `Transcribing ${voice.length - busy.length} of ${voice.length}`;
7854
7855
  }
7856
+ function comparedRevision(detail) {
7857
+ const { continuation } = detail;
7858
+ return continuation?.intention && continuation.contribution.detachedAt === null ? continuation.contribution.baseRevision : null;
7859
+ }
7855
7860
  function analysisLine(detail) {
7856
7861
  const { session } = detail;
7862
+ const revision = comparedRevision(detail);
7857
7863
  if (isAnalysisBusy(session)) return {
7858
7864
  action: null,
7859
- text: "Reading the session…"
7860
- };
7861
- if (session.analysis.state === "failed") return {
7862
- action: "Try again",
7863
- text: `Analysis failed: ${session.analysis.error ?? "Unknown error."}`
7865
+ text: revision === null ? "Reading the session…" : `Comparing with revision ${revision}…`
7864
7866
  };
7867
+ if (session.analysis.state === "failed") {
7868
+ const reason = session.analysis.error ?? "Unknown error.";
7869
+ return {
7870
+ action: "Try again",
7871
+ text: `${revision === null ? "Analysis failed" : "The comparison failed"}: ${reason}`
7872
+ };
7873
+ }
7865
7874
  if (isAnalysisOutdated(session)) return {
7866
7875
  action: "Analyze again",
7867
7876
  text: "The transcript changed since the analysis."
@@ -8676,4 +8685,4 @@ function SessionsPanel({ navigation, onStarted, onWriteNote }) {
8676
8685
  //#endregion
8677
8686
  export { Notices as A, searchCode as C, openDatabase as D, describeStorageFailure as E, reportFailure as M, settle as O, probeDevRoute as S, committed as T, teamTransport as _, DevtoolsBar as a, fetchBoardFeedback as b, copyToClipboard as c, PersonIcon as d, SessionWorkspaceProvider as f, devtoolsTransport as g, purgeAccount as h, BarButton as i, announce as j, sessionApiErrorSchema as k, SESSIONS_STYLES as l, useWorkspaceLoader as m, DEVTOOLS_STYLES as n, DevtoolsBarButtons as o, failureMessage as p, DevtoolsSheet as r, SessionsBarButton as s, SessionsPanel as t, RecordingLayer as u, callReflet as v, startBoardConnect as w, fetchSourceFile as x, disconnectBoard as y };
8678
8687
 
8679
- //# sourceMappingURL=sessions-panel-DPhFYhbk.js.map
8688
+ //# sourceMappingURL=sessions-panel-CDrnOEwi.js.map