Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
565106d333 | ||
|
|
9ee21b09ac | ||
|
|
30e6d8838c |
No files matched your search
@@ -9,7 +9,6 @@ body:
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for broken behavior, regressions, crashes, or reliability problems.
|
||||
Feature requests belong in [Discussions](https://github.com/pingdotgg/t3code/discussions/categories/ideas).
|
||||
Search existing issues first and keep the report focused on one problem.
|
||||
|
||||
- type: checkboxes
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Feature request
|
||||
url: https://github.com/pingdotgg/t3code/discussions/categories/ideas
|
||||
about: Suggest an improvement or new capability in Discussions.
|
||||
@@ -0,0 +1,102 @@
|
||||
name: Feature request
|
||||
description: Propose a scoped improvement or new capability.
|
||||
title: "[Feature]: "
|
||||
labels:
|
||||
- enhancement
|
||||
- needs-triage
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for new capabilities or meaningful improvements to existing behavior.
|
||||
This repo is still early. Small, concrete requests that clearly explain the problem and scope are much easier to evaluate.
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Before submitting
|
||||
options:
|
||||
- label: I searched existing issues and did not find a duplicate.
|
||||
required: true
|
||||
- label: I am describing a concrete problem or use case, not just a vague idea.
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Which part of the project would this change affect?
|
||||
options:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- apps/mobile
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem or use case
|
||||
description: What are you trying to do? What is hard, slow, or impossible today?
|
||||
placeholder: I want to reconnect to an existing provider session after a browser refresh without losing the current thread state.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: Describe the behavior, API, or UX you want.
|
||||
placeholder: Persist enough session metadata so the client can discover and reattach to the active provider session on load.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: value
|
||||
attributes:
|
||||
label: Why this matters
|
||||
description: Who benefits, and what outcome does this unlock?
|
||||
placeholder: This would make reconnects predictable during network drops and reduce accidental duplicate sessions.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: scope
|
||||
attributes:
|
||||
label: Smallest useful scope
|
||||
description: What is the narrowest version of this request that would still solve your problem?
|
||||
placeholder: A first pass only needs to support restoring the active session for the current thread.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: Workarounds, prior art, or other approaches you considered.
|
||||
placeholder: I currently work around this by manually restarting the provider session, but that loses in-flight context.
|
||||
|
||||
- type: textarea
|
||||
id: tradeoffs
|
||||
attributes:
|
||||
label: Risks or tradeoffs
|
||||
description: What costs, complexity, or edge cases should be considered?
|
||||
placeholder: This may require careful handling when the underlying provider session has already exited.
|
||||
|
||||
- type: textarea
|
||||
id: references
|
||||
attributes:
|
||||
label: Examples or references
|
||||
description: Links, screenshots, mockups, or comparable tools.
|
||||
|
||||
- type: checkboxes
|
||||
id: contribution
|
||||
attributes:
|
||||
label: Contribution
|
||||
options:
|
||||
- label: I would be open to helping implement this.
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800"><image width="1280" height="800" href="data:image/png;base64,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 truncated
|
||||
|
Before Width: | Height: | Size: 42 KiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800"><image width="1280" height="800" href="data:image/png;base64,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cGlp6a233vbnPx8csz3iiKPuu+/+wmTxqphs8OCPDj/8iJhn/tTHH39y5JF/3XjjzeInpv/0008L07/88ssHH3xIzCeeOvrov+VPTZ48OWby4IMPxvBRR/01hj//fMh3330XA3VZtbD//n867bQzXn/9jUMOOSyascMOO9100y2zZs2q1I0DB74Z8/ziiy+jM2MgeiAfX9MKnnjiSTHZhx9+mP86d+7caECM+eSTT6o2OKsiFnTsscdvscXWMdtY6zhPkY+Pkeeff0EM9OlzRbz24YcfqUsjs/IrwC+7rE+sXcwweu/zzz+v+MKYf8w5ntpvvwOuvfafUYDNahBrdNZZ52y77fb5Vnj77XcKT0VXRNdFN8Z8unU78Nprr4tm5E/VsguNGzcunrr77rtj+Oijyzpk0KD3K23BaHy8MPqh8MLrr78hJhg/fnw8G5svNmLFRt522+3x7OjRo7MadrN46vLLr4idIdbilFNOe+ONNyq+PPa0fG+J7rr55lur7gwFV155dcw8X818QSNGjMh7Mubcu/dZkyZNysoK/rceeODBMfD888/HNOeee37+8lqake+WTz319L77do1mv/XW21V7Kat5P6nLxqrpjVlJrP4111wbS4xmxGPsHvHa/KnY1iec0DMGBgwoW6+qP4Up676DAUCaVIBhnolIGY/bb79dpfFLLLH4xx9/WPg1joBPP73s5nNRX/ruu28jyTz22BP33nvPoosuOnPmjJhJHLbG8fpWW225zDJLDx48uHv3Ix944L5VVll5+vTpcVz+t78d3aRJk8KsYvo11lg9hnv3Pvv++x9YbLHFNtlkkzj+fv75FyZPnnLwwQdm5eE5JjvssO7FxTM322yzhRde6LPPPouD5niqa9c/Tpky5bHHHo/pn3ji0eWWWy4/gG7RovlGG2303Xejn332ufjp3/+xaN7yyy8f84wQstRSHdu0WbBp06bFxSUx54033uhHVy1GRpAeMeKLaOQ666y9wQbrv/nmW5GQmzZtcsAB+1fsrlh0LCjvzBgo3J+jphWMl0d0Oe20Xg88cG9RUVEk1QjhBx74544dO1ZtcKVNEz0T0SsGYhUaNSqKPPbaa69fcslFO++801JLLfXtt9/GhmjffrGYz4ILLliXRobLL79ywoTx0Xux6Oi6d9997+GHH1xkkXZZ+QmLnj1Pzvt26NChMeWHH3505ZV9GjVqVKlhsYH23vuPMbDuuuvEs/lWuOaaK6NjI+FHYItZLbzwwrE133tvUPTkoEGDrr76ylj9WnahJZZYotAhSy+9dOvWrZs1W6DSFoycGa+NFm677TZfffV1vHDJJZeMXsqjaWTOaFjFdo4ZMyZePnNmcbW7WaSvQw/tHqcAVl999dhLH3zwofj517/ujB0gpn/nnXfj2RiInSEeL7zwomhtVoMoycbMZ80qLSwoXltU1GjDDX83YMCACPzjxn1/1VVXtGvXNlZt2LBhTZsuECvbvn37mL72ZnxaLnatWNNodpTEq/ZSLftJ7Rur9jdmJSeffGq8E6NVf/5ztzhPFLtHbIK///28rPxvS+yHMdCqVauKH+afOnVqzDC2V74H1n0HA4BkCcAwz3z44eB4rPYgvvBByq+++ioiYkSXRx55sF27slCUh8Yzzzzr2muvzqeJ6BJxJb/vzj//eX2fPpdHqItf99hj90sv7TNw4MA4TI+nxo4dF8kngspCCy0UkS8OsnfYYftLL724/MLO6V277h+JYsstN49Mm882jt3jYDq/iW5Uw7KyctmNefLJ5xxH5zFxFMfWWmvNCy/8x9JLl90W+M4774oy2ssvv9Kt258uuugfMRxjTj75xPwovGKBty6rFoXEc845K/88ZyzugAO63X1330oBOFJKLChKamPHjo2BfGQtKxitPeKIw6MKGg3bddcu55xzbmyCY475a9Teqza4kogZsbjDDz/097/fNiuPGXFe4PHH+0ew6dHjuKgKHnPMcX/8475VrwGutpG5qMX17/94ZP4IjbH6Dz308DvvvBMtjwgX4SRS1n339W3Tpk1MecYZZ957730xwZ577lFp/ocddkTFDZQ3rE+fskz16KOPRc6JfeCf/7w6DzYx2xgTqxmxv5Zd6JRTToqmRvn0xhtvOuWUk/MdteIWzJNzeQv7xfmCrPxjC3kZvO4q7mZnnXV2xM7TTz8138RDhgz9wx92jQLpq6++FL/+9a/HlC/i1jwAx84c1ey6LyiC4gUXnB87Q9R+t95628icEyZM6NLlD5H9IhJHMwrb5eKLL6mpGXlujN3pjDNO23///fLpq/ZSbKaa9pPaN9YTdXhj5vLzULFSd911R7Qqdp4o+Q4fPnzmzJkV7x2w/vrrVbwQOjJzVvZ27hPnPn7SDgYAyfIRaJhn4iA74l+hPFutPCT37HlCHhHDXnvtGUElyjhz5szJx0SmLdx1drvtyg64v/56ZDzmR9tPLine truncated
|
||||
|
Before Width: | Height: | Size: 30 KiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="1000" viewBox="0 0 1280 1000"><image width="1280" height="1000" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAAPkCAIAAAB5gwQOAAABLGlDQ1BfAAB4nJWQPUsDQRCGH0NA1DSiooXFlWnUJGI+UAsTNWiZKES7y+UIYhKPy4n2af0R1naCjQipbawEKxEbe0Gwje/dFReQFJlhdp59d9jdGYgtIYunoN3x3Eq5aNROTo3JTybkgZlW12G0qer3Lax9XWF8m2rYXUv5W+G5elxXNsTzzZCvfa6HfOPzled44luf3aNKSfwgTjaHuD7EluP69e/irXbr0or+TcLuHFeVa4plylzIm7SwWaPKOWeYohR7FMizrrwj31CkyUgpkNUuRYkiOa059qXkdZZmN2BV+PMMn+x9wHZ/MBg8RdphH+6zMP0YaclNmE3A80ukRTN2TNcMpLgiZhfhZ0Gt3MHcF8z0pC76xyN6Nf71anBAB4tVUUbdpMn+AQyUTdocuQPoAAAQAElEQVR4nOz9B3hUV7rvCe9SFgiRQWSJnDMGTLIBY4NtbGMbnAPO3T7dfbrPmZl7n5nnztz7PTPfnXtudzvnhHMAY3LOOeeco8hBOdb8ai3VZqtKEgIjLKz/73HTpaq9V3hX2O9/vXuvHVVQUOAIIYQQQgghhBC/d6IcIYQQQgghhBCiCiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCi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 truncated
|
||||
|
Before Width: | Height: | Size: 231 KiB |
@@ -1,65 +0,0 @@
|
||||
name: Publish AUR package
|
||||
|
||||
# See packaging/aur/README.md.
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release_tag:
|
||||
required: true
|
||||
type: string
|
||||
pkgrel:
|
||||
required: false
|
||||
default: "1"
|
||||
type: string
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY:
|
||||
required: true
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: "Release tag to publish"
|
||||
required: true
|
||||
type: string
|
||||
pkgrel:
|
||||
description: "Arch package release override"
|
||||
required: false
|
||||
default: "1"
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: publish-aur
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Validate and publish
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
container:
|
||||
image: archlinux:base-devel
|
||||
|
||||
steps:
|
||||
- name: Install Arch packaging tools
|
||||
run: pacman -Syu --noconfirm --needed git github-cli jq namcap openssh sudo
|
||||
|
||||
- name: Checkout packaging sources
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Create unprivileged build user
|
||||
run: |
|
||||
useradd --create-home builder
|
||||
install -Dm0440 /dev/stdin /etc/sudoers.d/builder <<'EOF'
|
||||
builder ALL=(root) NOPASSWD: /usr/bin/pacman
|
||||
EOF
|
||||
|
||||
- name: Validate and publish package sources
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
PKGREL: ${{ inputs.pkgrel || '1' }}
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
run: packaging/aur/scripts/release.sh
|
||||
@@ -856,16 +856,6 @@ jobs:
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ github.token }}
|
||||
|
||||
publish_aur:
|
||||
name: Publish AUR package
|
||||
needs: [preflight, release]
|
||||
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
|
||||
uses: ./.github/workflows/publish-aur.yml
|
||||
with:
|
||||
release_tag: ${{ needs.preflight.outputs.tag }}
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
|
||||
deploy_web:
|
||||
name: Deploy hosted web app
|
||||
needs: [preflight, relay_public_config, release]
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
---
|
||||
title: UI Consistency
|
||||
model: claude-opus-5
|
||||
effort: high
|
||||
input: full_diff
|
||||
tools:
|
||||
- browse_code
|
||||
- git_tools
|
||||
- github_api_read_only
|
||||
- modify_pr
|
||||
include:
|
||||
- "apps/web/src/**/*.ts"
|
||||
- "apps/web/src/**/*.tsx"
|
||||
- "apps/web/src/**/*.css"
|
||||
conclusion: failure
|
||||
showToolCalls: true
|
||||
---
|
||||
|
||||
# UI consistency review
|
||||
|
||||
Review changed web UI code and directly affected call sites for consistency with the shared component system, Tailwind ownership, and the behavioral constraints below. Apply these rules when a pull request creates, moves, or modifies controls or styling. Do not demand unrelated repository-wide cleanup.
|
||||
|
||||
The goal is not to minimize CSS or class counts at any cost. The goal is to put each behavior in the smallest correct owner while preserving interaction, theming, accessibility, layout, and browser behavior.
|
||||
|
||||
## Shared controls and variants
|
||||
|
||||
- Prefer the core UI primitives in `apps/web/src/components/ui` over native controls or locally reconstructed primitives. In ordinary product UI, a raw `<button>` that recreates `Button`, a raw input that recreates `Input` or `InputGroup`, or a local trigger that recreates `Select`, `Toggle`, or `Menu` is a concrete finding.
|
||||
- Do not flag raw elements that intentionally implement a semantic row, tab, resize handle, swatch, image target, editor surface, or another interaction whose behavior or geometry differs from the core primitive.
|
||||
- When multiple call sites repeat the same durable geometry or treatment, prefer a named primitive size or variant. Examples include compact controls, micro icon actions, muted ghost actions, and glass actions. Keep contextual layout, width, and color at the call site.
|
||||
- Flag large call-site class strings that override a primitive's core height, radius, padding, focus ring, cursor, hit target, or base state colors. Prefer extending the primitive contract when the same pattern is genuinely shared.
|
||||
- Preserve accessibility and interaction semantics during migrations: focus-visible rings, disabled behavior, loading state, keyboard behavior, pointer cursor, `aria-*`, Base UI or Radix render/close props, and coarse-pointer hit targets.
|
||||
- Do not require tests for a tiny visual-only class migration. Require focused tests when primitive composition changes behavior, prop forwarding, state transitions, keyboard handling, or width/defaulting logic.
|
||||
|
||||
## CSS and Tailwind ownership
|
||||
|
||||
- Ordinary one-owner presentation belongs in the owning TS or TSX module as static Tailwind classes or owner-level CSS variables. Examples include local geometry, spacing, typography, backgrounds, borders, simple vendor pseudo-elements, and component-only positioning.
|
||||
- Keep global CSS when it is genuinely reusable or behaviorally complex: generated markdown or imperative DOM, custom elements and shadow roots, masks, shared or complex pseudo-elements, animations, glass composition, runtime theme variables, safe-area calculations, scrollbar-lane preservation, Electron drag regions, and browser/vendor integration. Simple owner-local pseudo-elements may still belong in the owning module.
|
||||
- Before calling a selector dead, trace literal, dynamic, generated, imperative, test, custom-element, and shadow-root consumers. Search both the emitted class string and any class-valued field names through their final DOM sink. A helper returning a class is not proof that it is rendered, and a missed downstream property read can make a deletion unsafe.
|
||||
- Flag duplicate declarations only after comparing cascade layer, selector specificity, inheritance, runtime theme scope, media/variant scope, and the final owning element. Textually identical declarations are not necessarily behaviorally redundant.
|
||||
- When moving CSS into Tailwind, preserve selector scope and cascade ownership. A utility at the owner is preferable to a fragile global override that depends on stylesheet order.
|
||||
- Do not request moving complex global behavior into arbitrary Tailwind merely to reduce `index.css`. Do not preserve ordinary one-owner CSS merely because it already exists globally.
|
||||
|
||||
## Themes and generated CSS
|
||||
|
||||
- Use the project variants for theme-only declarations:
|
||||
- dark-only declarations use `@variant dark`;
|
||||
- light-only declarations use `@variant light`;
|
||||
- raw `.dark` should remain only in the `dark` and `light` custom-variant definitions.
|
||||
- Preserve custom themes and runtime token bridges. Removing a variable or selector is safe only when all runtime, inspector, generated, and theme-palette consumers are accounted for.
|
||||
- Inspect emitted production CSS after unusual variants, arbitrary selectors, nested pseudo-elements, or attribute matching. Source syntax that looks valid is insufficient.
|
||||
- Flag malformed or empty emitted selectors such as empty `:is()` or `:not(:is())`, selector branches that can never match their own class attribute, and transformations that silently drop the intended rule.
|
||||
- Prefer source-level logic over clever selectors when behavior depends on consumer-provided class strings. Preserve `MenuPopup`'s current defaulting contract: a string `className` containing a `w-*`, `min-w-*`, or `max-w-*` utility after variant prefixes are stripped suppresses `min-w-32`; a string without one and a functional/non-string `className` keep the default. Arbitrary width values count as width utilities, and the consumer class must be merged last so it retains control. Do not replace this with a raw class-attribute substring selector.
|
||||
- Do not fail solely because a valid emitted selector is verbose or because a source rule uses an intentional custom property.
|
||||
|
||||
## Scroll and virtualized lists
|
||||
|
||||
- `ScrollArea` owns and masks its Base UI viewport. A virtualized list usually owns a native scrolling element and cannot automatically reuse viewport-specific `ScrollArea` behavior.
|
||||
- Repeated native or virtualized overflow fades should use the shared virtualized-scroll-fade contract rather than component-named mask selectors.
|
||||
- Preserve runtime top and bottom overflow state. Do not replace dynamic fades with an always-on static mask.
|
||||
- Preserve fade geometry and keep the native scrollbar lane opaque so the track and thumb stay visible and usable. A visually similar mask that fades the scrollbar is a regression.
|
||||
- Verify actual scroll behavior when changing virtualizers, masks, overflow ownership, or scrollbar selectors. Source-level class comparison is not enough.
|
||||
|
||||
## Visual and layout preservation
|
||||
|
||||
- Preserve responsive geometry, titlebar insets, panel and inline-preview modes, desktop Electron layout, light and dark contrast, clipping, radius, and composable shadows.
|
||||
- For meaningful visual changes, prefer available real-app evidence using the actual component and state. A mock recreation does not validate the real component. Light and dark evidence is useful when theme-sensitive styles change, but missing or inaccessible evidence alone is not a finding; report only a concrete regression supported by the diff, code, or available artifacts.
|
||||
- Do not treat a screenshot as proof of keyboard, overflow, scrollbar, responsive, or runtime-theme behavior. Pair visual evidence with source, computed-style, emitted-CSS, or interaction checks as appropriate.
|
||||
- Be alert to shared primitive color indirection. When a primitive routes icon color through a CSS variable, ensure migrated contextual icons retain their intended tone, including pressed and disabled states.
|
||||
|
||||
## Change discipline
|
||||
|
||||
- Review the pull request's changed scope and directly affected consumers. Do not turn a focused PR into a demand for unrelated legacy cleanup.
|
||||
- Prefer the smallest durable contract over a component-specific workaround or a broad abstraction with one consumer.
|
||||
- Preserve intentional exceptions and comments that explain browser, virtualizer, theme, or Electron constraints.
|
||||
- If a proposed cleanup cannot prove ownership or semantic equivalence, ask for evidence or leave it unchanged rather than guessing.
|
||||
- Select verification gates according to the changed behavior: typecheck or focused tests for typing and interaction contracts, production build and emitted-CSS inspection for Tailwind or selector transformations, and real-app evidence for meaningful visual behavior when available. These gates are complementary when applicable, but do not require every gate for tiny visual-only migrations or fail solely because an artifact the configured tools cannot produce is absent.
|
||||
|
||||
## Reporting
|
||||
|
||||
Report only concrete violations introduced by changed lines or behavior, plus pre-existing behavior that the patch directly makes relevant or worsens. Touching a large file does not make unrelated retained issues reportable. Prefer precise inline comments on the smallest relevant line range. Explain the broken behavior or ownership rule, not merely the preferred syntax, and state the smallest expected fix. A clear consistency or regression risk may fail the check. Do not fail for optional aesthetic preferences, harmless class ordering, or unrelated legacy code.
|
||||
|
||||
This check defaults to failure. When there are no findings, stop immediately and make the entire final response exactly `All clear` on one line. Do not add a title, explanation, punctuation, Markdown, JSON, or trailing analysis, and do not continue reasoning after deciding the review is clean.
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
We are not actively accepting contributions right now.
|
||||
|
||||
You can still report a bug or open a PR, but please do so knowing there is a high chance we close it, defer it forever, or never look at it.
|
||||
|
||||
Feature requests and proposals belong in [Ideas discussions](https://github.com/pingdotgg/t3code/discussions/categories/ideas), not issues.
|
||||
You can still open an issue or PR, but please do so knowing there is a high chance we close it, defer it forever, or never look at it.
|
||||
|
||||
If that sounds annoying, that is because it is. This project is still early and we are trying to keep scope, quality, and direction under control.
|
||||
|
||||
@@ -52,9 +50,9 @@ If the change depends on motion, timing, transitions, or interaction details, in
|
||||
|
||||
If we have to guess what changed, we are much less likely to review it.
|
||||
|
||||
## Discuss Changes First
|
||||
## Issues First
|
||||
|
||||
If you are thinking about a non-trivial change, start a discussion first. Issues are reserved for bug reports.
|
||||
If you are thinking about a non-trivial change, open an issue first.
|
||||
|
||||
That still does not mean we will want the PR, but it gives you a chance to avoid wasting your time.
|
||||
|
||||
|
||||
@@ -51,20 +51,10 @@ brew install --cask t3-code
|
||||
|
||||
#### Arch Linux (AUR)
|
||||
|
||||
Stable:
|
||||
|
||||
```bash
|
||||
yay -S t3code-bin
|
||||
```
|
||||
|
||||
Nightly:
|
||||
|
||||
```bash
|
||||
yay -S t3code-nightly-bin
|
||||
```
|
||||
|
||||
The AUR packaging is maintained in this repository under [`packaging/aur`](./packaging/aur).
|
||||
|
||||
## Some notes
|
||||
|
||||
We are very very early in this project. Expect bugs.
|
||||
@@ -113,8 +103,6 @@ Checkout their getting started guide for more information: https://viteplus.dev/
|
||||
vp i
|
||||
```
|
||||
|
||||
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before reporting a bug or opening a PR.
|
||||
|
||||
Have a feature request? Start an [Ideas discussion](https://github.com/pingdotgg/t3code/discussions/categories/ideas).
|
||||
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before opening an issue or PR.
|
||||
|
||||
Need support? Join the [Discord](https://discord.gg/jn4EGJjrvv).
|
||||
@@ -1,33 +0,0 @@
|
||||
<svg width="1080" height="760" viewBox="0 0 540 380" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="latest-surface" x1="0" y1="0" x2="540" y2="380" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FAFAF9"/>
|
||||
<stop offset="1" stop-color="#F5F5F4"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="latest-light" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(430 0) rotate(152) scale(320 150)">
|
||||
<stop stop-color="#FFFFFF"/>
|
||||
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
|
||||
<rect width="540" height="380" fill="url(#latest-surface)"/>
|
||||
<rect width="540" height="112" fill="#EFEFED"/>
|
||||
<rect width="540" height="112" fill="url(#latest-light)"/>
|
||||
<path d="M0 111.5H540" stroke="#18181B" stroke-opacity="0.08"/>
|
||||
<path d="M32 28H64" stroke="#18181B" stroke-width="2"/>
|
||||
|
||||
<g font-family="-apple-system, BlinkMacSystemFont, sans-serif" fill="#18181B">
|
||||
<text x="32" y="50" font-size="12" font-weight="600" letter-spacing="1.4">T3 CODE</text>
|
||||
<text x="32" y="82" font-size="22" font-weight="600" letter-spacing="-0.45">Desktop</text>
|
||||
<text x="508" y="50" text-anchor="end" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="8.5" font-weight="600" letter-spacing="1.2" fill="#71717A">LATEST RELEASE</text>
|
||||
</g>
|
||||
|
||||
<path d="M196 224C242 239 307 201 362 220" stroke="#71717A" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="1 7" opacity="0.42"/>
|
||||
<circle cx="362" cy="220" r="2" fill="#71717A" opacity="0.55"/>
|
||||
<path d="M176 204V227L182 221L187.5 232L192 229.8L186.5 219H194L176 204Z" fill="#71717A" stroke="#F7F7F5" stroke-width="1.5" stroke-linejoin="round"/>
|
||||
|
||||
<g font-family="-apple-system, BlinkMacSystemFont, sans-serif" text-anchor="middle">
|
||||
<text x="270" y="322" font-size="13" font-weight="600" letter-spacing="-0.1" fill="#18181B">Drag T3 Code to Applications</text>
|
||||
<text x="270" y="345" font-size="9.5" fill="#71717A">Open it from Applications when the copy finishes.</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1,64 +0,0 @@
|
||||
<svg width="1080" height="760" viewBox="0 0 540 380" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="night-sky" x1="28" y1="0" x2="510" y2="112" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#07152F"/>
|
||||
<stop offset="0.52" stop-color="#151443"/>
|
||||
<stop offset="1" stop-color="#32155B"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="night-glow" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(420 18) rotate(157) scale(260 126)">
|
||||
<stop stop-color="#5165D8" stop-opacity="0.42"/>
|
||||
<stop offset="0.55" stop-color="#283075" stop-opacity="0.15"/>
|
||||
<stop offset="1" stop-color="#111635" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<linearGradient id="night-cloud" x1="18" y1="62" x2="260" y2="112" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#4EA4FF" stop-opacity="0.5"/>
|
||||
<stop offset="0.52" stop-color="#696FEA" stop-opacity="0.62"/>
|
||||
<stop offset="1" stop-color="#A85BEA" stop-opacity="0.5"/>
|
||||
</linearGradient>
|
||||
<filter id="night-soft" x="-24" y="35" width="588" height="101" filterUnits="userSpaceOnUse">
|
||||
<feGaussianBlur stdDeviation="4"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<rect width="540" height="380" fill="#F7F7F5"/>
|
||||
<rect width="540" height="112" fill="url(#night-sky)"/>
|
||||
<rect width="540" height="112" fill="url(#night-glow)"/>
|
||||
|
||||
<g fill="#E4EAFF">
|
||||
<circle cx="20" cy="18" r="0.8" opacity="0.82"/>
|
||||
<circle cx="76" cy="27" r="0.55" opacity="0.55"/>
|
||||
<circle cx="133" cy="13" r="0.65" opacity="0.7"/>
|
||||
<circle cx="198" cy="28" r="0.5" opacity="0.5"/>
|
||||
<circle cx="258" cy="15" r="0.75" opacity="0.8"/>
|
||||
<circle cx="326" cy="29" r="0.5" opacity="0.55"/>
|
||||
<circle cx="384" cy="12" r="0.65" opacity="0.72"/>
|
||||
<circle cx="455" cy="26" r="0.55" opacity="0.58"/>
|
||||
<circle cx="517" cy="15" r="0.75" opacity="0.78"/>
|
||||
</g>
|
||||
<g stroke="#EEF2FF" stroke-linecap="round" stroke-width="0.65" opacity="0.68">
|
||||
<path d="M104 30V34M102 32H106"/>
|
||||
<path d="M448 24V28M446 26H450"/>
|
||||
</g>
|
||||
|
||||
<g filter="url(#night-soft)">
|
||||
<path d="M-12 112V101C-12 87 0 76 14 76C18 63 30 54 44 54C58 54 70 62 74 75C79 70 86 67 94 67C110 67 123 79 124 95C132 96 138 101 141 112H-12Z" fill="url(#night-cloud)"/>
|
||||
<path d="M374 112C375 98 387 87 401 87C405 72 418 62 434 62C450 62 463 72 467 87C478 87 488 94 492 104C506 103 518 106 526 112H374Z" fill="url(#night-cloud)" opacity="0.82"/>
|
||||
</g>
|
||||
<path d="M0 111.5H540" stroke="#050A19" stroke-opacity="0.3"/>
|
||||
<path d="M32 28H64" stroke="#FFFFFF" stroke-width="2"/>
|
||||
|
||||
<g font-family="-apple-system, BlinkMacSystemFont, sans-serif" fill="#FFFFFF">
|
||||
<text x="32" y="50" font-size="12" font-weight="600" letter-spacing="1.4">T3 CODE</text>
|
||||
<text x="32" y="82" font-size="22" font-weight="600" letter-spacing="-0.45">Desktop</text>
|
||||
<text x="508" y="50" text-anchor="end" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="8.5" font-weight="600" letter-spacing="1.2" opacity="0.84">NIGHTLY BUILD</text>
|
||||
</g>
|
||||
|
||||
<path d="M196 224C242 239 307 201 362 220" stroke="#71717A" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="1 7" opacity="0.42"/>
|
||||
<circle cx="362" cy="220" r="2" fill="#71717A" opacity="0.55"/>
|
||||
<path d="M176 204V227L182 221L187.5 232L192 229.8L186.5 219H194L176 204Z" fill="#71717A" stroke="#F7F7F5" stroke-width="1.5" stroke-linejoin="round"/>
|
||||
|
||||
<g font-family="-apple-system, BlinkMacSystemFont, sans-serif" text-anchor="middle">
|
||||
<text x="270" y="322" font-size="13" font-weight="600" letter-spacing="-0.1" fill="#18181B">Drag T3 Code to Applications</text>
|
||||
<text x="270" y="345" font-size="9.5" fill="#71717A">Open it from Applications when the copy finishes.</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 279 KiB |
|
After Width: | Height: | Size: 313 KiB |
@@ -20,14 +20,14 @@ export const APP_BUNDLE_ID = isDevelopment
|
||||
? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
|
||||
: "com.t3tools.t3code";
|
||||
const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
|
||||
const LAUNCHER_VERSION = 15;
|
||||
const LAUNCHER_VERSION = 14;
|
||||
const defaultIconPath = NodePath.join(desktopDir, "resources", "icon.icns");
|
||||
const developmentMacIconPngPath = NodePath.join(
|
||||
repoRoot,
|
||||
"assets",
|
||||
"dev",
|
||||
"blueprint-macos-1024.png",
|
||||
);
|
||||
const productionMacIconPngPath = NodePath.join(repoRoot, "assets", "prod", "black-macos-1024.png");
|
||||
// oxlint-disable-next-line t3code/no-global-process-runtime -- Standalone launcher script has no Effect runtime.
|
||||
const hostPlatform = NodeOS.platform();
|
||||
|
||||
@@ -165,22 +165,15 @@ function registerMacLauncherBundle(appBundlePath) {
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveMacLauncherIconPaths(runtimeDir, development = isDevelopment) {
|
||||
return {
|
||||
sourceIconPath: development ? developmentMacIconPngPath : productionMacIconPngPath,
|
||||
generatedIconPath: NodePath.join(runtimeDir, development ? "icon-dev.icns" : "icon-prod.icns"),
|
||||
};
|
||||
}
|
||||
|
||||
function ensureMacIconIcns(runtimeDir) {
|
||||
const { sourceIconPath, generatedIconPath } = resolveMacLauncherIconPaths(runtimeDir);
|
||||
function ensureDevelopmentIconIcns(runtimeDir) {
|
||||
const generatedIconPath = NodePath.join(runtimeDir, "icon-dev.icns");
|
||||
NodeFS.mkdirSync(runtimeDir, { recursive: true });
|
||||
|
||||
if (!NodeFS.existsSync(sourceIconPath)) {
|
||||
throw new Error(`Desktop macOS icon source is missing at ${sourceIconPath}`);
|
||||
if (!NodeFS.existsSync(developmentMacIconPngPath)) {
|
||||
return defaultIconPath;
|
||||
}
|
||||
|
||||
const sourceMtimeMs = NodeFS.statSync(sourceIconPath).mtimeMs;
|
||||
const sourceMtimeMs = NodeFS.statSync(developmentMacIconPngPath).mtimeMs;
|
||||
if (
|
||||
NodeFS.existsSync(generatedIconPath) &&
|
||||
NodeFS.statSync(generatedIconPath).mtimeMs >= sourceMtimeMs
|
||||
@@ -198,7 +191,7 @@ function ensureMacIconIcns(runtimeDir) {
|
||||
"-z",
|
||||
String(size),
|
||||
String(size),
|
||||
sourceIconPath,
|
||||
developmentMacIconPngPath,
|
||||
"--out",
|
||||
NodePath.join(iconsetDir, `icon_${size}x${size}.png`),
|
||||
]);
|
||||
@@ -208,7 +201,7 @@ function ensureMacIconIcns(runtimeDir) {
|
||||
"-z",
|
||||
String(retinaSize),
|
||||
String(retinaSize),
|
||||
sourceIconPath,
|
||||
developmentMacIconPngPath,
|
||||
"--out",
|
||||
NodePath.join(iconsetDir, `icon_${size}x${size}@2x.png`),
|
||||
]);
|
||||
@@ -216,6 +209,12 @@ function ensureMacIconIcns(runtimeDir) {
|
||||
|
||||
runChecked("iconutil", ["-c", "icns", iconsetDir, "-o", generatedIconPath]);
|
||||
return generatedIconPath;
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"[desktop-launcher] Failed to generate dev macOS icon, falling back to default icon.",
|
||||
error,
|
||||
);
|
||||
return defaultIconPath;
|
||||
} finally {
|
||||
NodeFS.rmSync(iconsetRoot, { recursive: true, force: true });
|
||||
}
|
||||
@@ -298,7 +297,7 @@ function buildMacLauncher(electronBinaryPath) {
|
||||
const launcherBinaryPath = isDevelopment
|
||||
? developmentPaths.launcherBinaryPath
|
||||
: runtimeElectronBinaryPath;
|
||||
const iconPath = ensureMacIconIcns(runtimeDir);
|
||||
const iconPath = isDevelopment ? ensureDevelopmentIconIcns(runtimeDir) : defaultIconPath;
|
||||
const metadataPath = NodePath.join(runtimeDir, "metadata.json");
|
||||
|
||||
NodeFS.mkdirSync(runtimeDir, { recursive: true });
|
||||
|
||||
@@ -3,7 +3,6 @@ import { assert, describe, it } from "vite-plus/test";
|
||||
import {
|
||||
makeDevelopmentLauncherScript,
|
||||
resolveElectronBinaryPath,
|
||||
resolveMacLauncherIconPaths,
|
||||
resolveMacLauncherPaths,
|
||||
} from "./electron-launcher.mjs";
|
||||
|
||||
@@ -79,14 +78,4 @@ describe("electron development launcher", () => {
|
||||
);
|
||||
assert.notInclude(script, "node_modules/electron");
|
||||
});
|
||||
|
||||
it("derives launcher icons from canonical development and production assets", () => {
|
||||
const development = resolveMacLauncherIconPaths("/runtime", true);
|
||||
const production = resolveMacLauncherIconPaths("/runtime", false);
|
||||
|
||||
assert.match(development.sourceIconPath, /assets\/dev\/blueprint-macos-1024\.png$/);
|
||||
assert.equal(development.generatedIconPath, "/runtime/icon-dev.icns");
|
||||
assert.match(production.sourceIconPath, /assets\/prod\/black-macos-1024\.png$/);
|
||||
assert.equal(production.generatedIconPath, "/runtime/icon-prod.icns");
|
||||
});
|
||||
});
|
||||
@@ -40,7 +40,6 @@ const makeElectronAppLayer = (calls: ElectronAppCalls) =>
|
||||
Layer.succeed(ElectronApp.ElectronApp, {
|
||||
metadata: Effect.die("unexpected metadata read"),
|
||||
name: Effect.succeed("T3 Code"),
|
||||
systemLocale: Effect.succeed("en-US"),
|
||||
whenReady: Effect.void,
|
||||
quit: Effect.void,
|
||||
exit: () => Effect.void,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { assert, describe, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
|
||||
import * as DesktopAssets from "./DesktopAssets.ts";
|
||||
@@ -23,45 +22,6 @@ const environmentLayer = DesktopEnvironment.layer({
|
||||
}).pipe(Layer.provide(Layer.mergeAll(NodeServices.layer, DesktopConfig.layerTest({}))));
|
||||
|
||||
describe("DesktopAssets", () => {
|
||||
it.effect("uses canonical source-tree icons for unpackaged development", () =>
|
||||
Effect.gen(function* () {
|
||||
const developmentEnvironmentLayer = DesktopEnvironment.layer({
|
||||
dirname: "/repo/apps/desktop/dist-electron",
|
||||
homeDirectory: "/Users/alice",
|
||||
platform: "linux",
|
||||
processArch: "x64",
|
||||
appVersion: "1.2.3",
|
||||
appPath: "/repo",
|
||||
isPackaged: false,
|
||||
resourcesPath: "/repo/apps/desktop/resources",
|
||||
runningUnderArm64Translation: false,
|
||||
}).pipe(
|
||||
Layer.provide(
|
||||
Layer.mergeAll(
|
||||
NodeServices.layer,
|
||||
DesktopConfig.layerTest({ VITE_DEV_SERVER_URL: "http://localhost:5733" }),
|
||||
),
|
||||
),
|
||||
);
|
||||
const fileSystemLayer = FileSystem.layerNoop({
|
||||
exists: (path) => Effect.succeed(String(path).includes("/assets/dev/")),
|
||||
});
|
||||
const assets = yield* DesktopAssets.DesktopAssets.pipe(
|
||||
Effect.provide(
|
||||
DesktopAssets.layer.pipe(
|
||||
Layer.provide(Layer.merge(fileSystemLayer, developmentEnvironmentLayer)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const icons = yield* assets.iconPaths;
|
||||
|
||||
assert.match(Option.getOrThrow(icons.ico), /assets\/dev\/blueprint-windows\.ico$/);
|
||||
assert.match(Option.getOrThrow(icons.png), /assets\/dev\/blueprint-universal-1024\.png$/);
|
||||
assert.isTrue(Option.isNone(icons.icns));
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("preserves the failed asset candidate and filesystem cause", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileName = "custom.bin";
|
||||
|
||||
@@ -61,35 +61,6 @@ const resolveResourcePath = Effect.fn("desktop.assets.resolveResourcePath")(func
|
||||
return Option.none<string>();
|
||||
});
|
||||
|
||||
const sourceTreeIconFileNames = {
|
||||
dev: {
|
||||
ico: "blueprint-windows.ico",
|
||||
macPng: "blueprint-macos-1024.png",
|
||||
universalPng: "blueprint-universal-1024.png",
|
||||
},
|
||||
prod: {
|
||||
ico: "t3-black-windows.ico",
|
||||
macPng: "black-macos-1024.png",
|
||||
universalPng: "black-universal-1024.png",
|
||||
},
|
||||
} as const;
|
||||
|
||||
function resolveSourceTreeIconPath(
|
||||
environment: DesktopEnvironment.DesktopEnvironment["Service"],
|
||||
ext: keyof DesktopIconPaths,
|
||||
): string | undefined {
|
||||
if (environment.isPackaged || ext === "icns") return undefined;
|
||||
const brand = environment.isDevelopment ? "dev" : "prod";
|
||||
const fileNames = sourceTreeIconFileNames[brand];
|
||||
const fileName =
|
||||
ext === "ico"
|
||||
? fileNames.ico
|
||||
: environment.platform === "darwin"
|
||||
? fileNames.macPng
|
||||
: fileNames.universalPng;
|
||||
return environment.path.join(environment.rootDir, "assets", brand, fileName);
|
||||
}
|
||||
|
||||
const resolveIconPath = Effect.fn("desktop.assets.resolveIconPath")(function* (
|
||||
ext: keyof DesktopIconPaths,
|
||||
): Effect.fn.Return<
|
||||
@@ -99,20 +70,20 @@ const resolveIconPath = Effect.fn("desktop.assets.resolveIconPath")(function* (
|
||||
> {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const sourceTreeIconPath = resolveSourceTreeIconPath(environment, ext);
|
||||
if (sourceTreeIconPath !== undefined) {
|
||||
const sourceTreeIconExists = yield* fileSystem.exists(sourceTreeIconPath).pipe(
|
||||
if (environment.isDevelopment && environment.platform === "darwin" && ext === "png") {
|
||||
const developmentDockIconPath = environment.developmentDockIconPath;
|
||||
const developmentDockIconExists = yield* fileSystem.exists(developmentDockIconPath).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new DesktopAssetProbeError({
|
||||
fileName: `icon.${ext}`,
|
||||
candidatePath: sourceTreeIconPath,
|
||||
fileName: "icon.png",
|
||||
candidatePath: developmentDockIconPath,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
if (sourceTreeIconExists) {
|
||||
return Option.some(sourceTreeIconPath);
|
||||
if (developmentDockIconExists) {
|
||||
return Option.some(developmentDockIconPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ export class DesktopEnvironment extends Context.Service<
|
||||
readonly runtimeInfo: DesktopRuntimeInfo;
|
||||
readonly resolvePickFolderDefaultPath: (rawOptions: unknown) => Option.Option<string>;
|
||||
readonly resolveResourcePathCandidates: (fileName: string) => readonly string[];
|
||||
readonly developmentDockIconPath: string;
|
||||
}
|
||||
>()("@t3tools/desktop/app/DesktopEnvironment") {}
|
||||
|
||||
@@ -269,6 +270,7 @@ const make = Effect.fn("desktop.environment.make")(function* (
|
||||
path.join(resourcesPath, "resources", fileName),
|
||||
path.join(resourcesPath, fileName),
|
||||
],
|
||||
developmentDockIconPath: path.join(rootDir, "assets", "dev", "blueprint-macos-1024.png"),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ describe("DesktopLifecycle", () => {
|
||||
const electronAppLayer = Layer.succeed(ElectronApp.ElectronApp, {
|
||||
metadata: Effect.die("unexpected metadata read"),
|
||||
name: Effect.succeed("T3 Code"),
|
||||
systemLocale: Effect.succeed("en-US"),
|
||||
whenReady: Effect.void,
|
||||
quit: Effect.void,
|
||||
exit: () => Effect.void,
|
||||
|
||||
@@ -701,84 +701,6 @@ describe("DesktopBackendManager", () => {
|
||||
),
|
||||
);
|
||||
|
||||
it.effect(
|
||||
"re-probes readiness after the first budget expires while the backend is still alive",
|
||||
() =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const requestUrls: Array<string> = [];
|
||||
let requestCount = 0;
|
||||
let readyCount = 0;
|
||||
let readinessTimeoutCount = 0;
|
||||
const firstProbe = yield* Deferred.make<void>();
|
||||
const childExit = yield* Deferred.make<void>();
|
||||
|
||||
const spawnerLayer = Layer.succeed(
|
||||
ChildProcessSpawner.ChildProcessSpawner,
|
||||
ChildProcessSpawner.make(() =>
|
||||
Effect.succeed(
|
||||
makeProcess({
|
||||
exitCode: Deferred.await(childExit).pipe(
|
||||
Effect.as(ChildProcessSpawner.ExitCode(0)),
|
||||
),
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// The backend stays 503 through the first *two* readiness budgets
|
||||
// and only becomes healthy (200) for the third round, i.e. it comes
|
||||
// up well after the initial 50ms budget has expired.
|
||||
const httpLayer = httpClientLayer((request) =>
|
||||
Effect.gen(function* () {
|
||||
requestCount += 1;
|
||||
requestUrls.push(request.url);
|
||||
yield* Deferred.succeed(firstProbe, void 0);
|
||||
return responseForRequest(request, requestCount <= 2 ? 503 : 200);
|
||||
}),
|
||||
);
|
||||
|
||||
const runFiber = yield* DesktopBackendManager.runBackendProcess({
|
||||
...baseConfig,
|
||||
desktopTelemetryStream: Stream.empty,
|
||||
readinessTimeout: Duration.millis(50),
|
||||
onReady: () =>
|
||||
Effect.sync(() => {
|
||||
readyCount += 1;
|
||||
}),
|
||||
onReadinessFailure: () =>
|
||||
Effect.sync(() => {
|
||||
readinessTimeoutCount += 1;
|
||||
}),
|
||||
}).pipe(Effect.provide(Layer.merge(spawnerLayer, httpLayer)), Effect.forkChild);
|
||||
|
||||
yield* Deferred.await(firstProbe);
|
||||
assert.equal(readyCount, 0);
|
||||
assert.equal(readinessTimeoutCount, 0);
|
||||
|
||||
// The first 50ms readiness budget expires while the backend still
|
||||
// answers 503. The child is alive and may yet become healthy, so the
|
||||
// probe must start a fresh round instead of stopping permanently —
|
||||
// the pre-fix behavior left the app stuck on "Connecting to WSL…"
|
||||
// forever even though the backend kept running.
|
||||
yield* TestClock.adjust(Duration.millis(50));
|
||||
assert.equal(readinessTimeoutCount, 1);
|
||||
assert.equal(readyCount, 0);
|
||||
|
||||
// The second budget also expires (backend still 503), then the third
|
||||
// round connects. The point is the probe persisted across budgets
|
||||
// while the process was alive instead of giving up after the first.
|
||||
yield* TestClock.adjust(Duration.millis(100));
|
||||
assert.equal(readinessTimeoutCount, 2);
|
||||
assert.equal(readyCount, 1);
|
||||
assert.equal(requestUrls.length, 3);
|
||||
|
||||
yield* Deferred.succeed(childExit, void 0);
|
||||
assert.equal((yield* Fiber.join(runFiber)).code.pipe(Option.getOrUndefined), 0);
|
||||
}).pipe(Effect.provide(TestClock.layer())),
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("starts the configured backend and closes the scoped process on stop", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -563,33 +563,20 @@ export const runBackendProcess = Effect.fn("runBackendProcess")(function* (
|
||||
).pipe(Effect.forkScoped),
|
||||
);
|
||||
}
|
||||
// Probe readiness in a loop while the backend process is still alive
|
||||
// instead of giving up after the first budget. A slow cold boot (the
|
||||
// WSL bundle loading across /mnt/c, or a first launch right after an
|
||||
// update) can exceed the initial readiness budget while the backend is
|
||||
// about to come up moments later; a one-shot probe left the app stuck
|
||||
// on "Connecting to WSL…" forever even though the backend kept running
|
||||
// and became healthy. Each round gets a fresh budget, and the forked
|
||||
// loop is torn down with the run scope once the child exits.
|
||||
const probeReadiness = Effect.fn("desktop.backendProcess.probeReadiness")(() =>
|
||||
waitForHttpReady({
|
||||
executablePath: options.executablePath,
|
||||
entryPath: options.entryPath,
|
||||
cwd: options.cwd,
|
||||
httpBaseUrl: options.httpBaseUrl,
|
||||
timeout: options.readinessTimeout ?? DEFAULT_BACKEND_READINESS_TIMEOUT,
|
||||
}).pipe(
|
||||
Effect.flatMap(() => options.onReady?.() ?? Effect.void),
|
||||
Effect.as(true),
|
||||
Effect.catchTags({
|
||||
BackendReadinessTimeoutError: (error) =>
|
||||
(options.onReadinessFailure?.(error) ?? Effect.void).pipe(Effect.as(false)),
|
||||
}),
|
||||
),
|
||||
yield* waitForHttpReady({
|
||||
executablePath: options.executablePath,
|
||||
entryPath: options.entryPath,
|
||||
cwd: options.cwd,
|
||||
httpBaseUrl: options.httpBaseUrl,
|
||||
timeout: options.readinessTimeout ?? DEFAULT_BACKEND_READINESS_TIMEOUT,
|
||||
}).pipe(
|
||||
Effect.tap(() => options.onReady?.() ?? Effect.void),
|
||||
Effect.catchTags({
|
||||
BackendReadinessTimeoutError: (error) => options.onReadinessFailure?.(error) ?? Effect.void,
|
||||
}),
|
||||
Effect.forkScoped,
|
||||
);
|
||||
|
||||
yield* probeReadiness().pipe(Effect.repeat({ while: (ready) => !ready }), Effect.forkScoped);
|
||||
|
||||
const exit = yield* handle.exitCode.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
|
||||
@@ -8,7 +8,6 @@ const {
|
||||
autoUpdaterRemoveListenerMock,
|
||||
exitMock,
|
||||
getAppPathMock,
|
||||
getSystemLocaleMock,
|
||||
getVersionMock,
|
||||
isDefaultProtocolClientMock,
|
||||
onMock,
|
||||
@@ -30,7 +29,6 @@ const {
|
||||
autoUpdaterRemoveListenerMock: vi.fn(),
|
||||
exitMock: vi.fn(),
|
||||
getAppPathMock: vi.fn(() => "/app"),
|
||||
getSystemLocaleMock: vi.fn(() => "en-GB"),
|
||||
getVersionMock: vi.fn(() => "1.2.3"),
|
||||
isDefaultProtocolClientMock: vi.fn(() => false),
|
||||
onMock: vi.fn(),
|
||||
@@ -62,7 +60,6 @@ vi.mock("electron", () => ({
|
||||
setIcon: setDockIconMock,
|
||||
},
|
||||
getAppPath: getAppPathMock,
|
||||
getSystemLocale: getSystemLocaleMock,
|
||||
getVersion: getVersionMock,
|
||||
isDefaultProtocolClient: isDefaultProtocolClientMock,
|
||||
isPackaged: true,
|
||||
@@ -114,23 +111,6 @@ describe("ElectronApp", () => {
|
||||
}).pipe(Effect.provide(ElectronApp.layer)),
|
||||
);
|
||||
|
||||
it.effect("reads the OS locale through the service", () =>
|
||||
Effect.gen(function* () {
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
|
||||
assert.strictEqual(yield* electronApp.systemLocale, "en-GB");
|
||||
}).pipe(Effect.provide(ElectronApp.layer)),
|
||||
);
|
||||
|
||||
it.effect("normalizes POSIX-style locale identifiers that Intl rejects", () =>
|
||||
Effect.gen(function* () {
|
||||
getSystemLocaleMock.mockImplementationOnce(() => "en_GB");
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
|
||||
assert.strictEqual(yield* electronApp.systemLocale, "en-GB");
|
||||
}).pipe(Effect.provide(ElectronApp.layer)),
|
||||
);
|
||||
|
||||
it.effect("reports which app metadata property failed", () =>
|
||||
Effect.gen(function* () {
|
||||
const cause = new Error("version unavailable");
|
||||
|
||||
@@ -43,13 +43,6 @@ export class ElectronApp extends Context.Service<
|
||||
{
|
||||
readonly metadata: Effect.Effect<ElectronAppMetadata, ElectronAppMetadataReadError>;
|
||||
readonly name: Effect.Effect<string>;
|
||||
/**
|
||||
* The OS locale, read from the operating system rather than from Chromium's
|
||||
* resolved application locale — the packaged app ships only the `en-US`
|
||||
* locale pak, so `app.getLocale()` and the renderer's `Intl` default are
|
||||
* pinned to `en-US` however the machine is configured.
|
||||
*/
|
||||
readonly systemLocale: Effect.Effect<string>;
|
||||
readonly whenReady: Effect.Effect<void, ElectronAppWhenReadyError>;
|
||||
readonly quit: Effect.Effect<void>;
|
||||
readonly exit: (code: number) => Effect.Effect<void>;
|
||||
@@ -126,10 +119,6 @@ export const make = ElectronApp.of({
|
||||
};
|
||||
}),
|
||||
name: Effect.sync(() => Electron.app.name),
|
||||
// macOS derives this from NSLocale, which uses POSIX-style identifiers
|
||||
// (`en_GB`). `Intl` rejects those outright rather than normalizing them, so
|
||||
// the tag is normalized here rather than in the renderer that consumes it.
|
||||
systemLocale: Effect.sync(() => Electron.app.getSystemLocale().replace(/_/g, "-")),
|
||||
whenReady: Effect.gen(function* () {
|
||||
const isPackaged = Electron.app.isPackaged;
|
||||
yield* Effect.tryPromise({
|
||||
|
||||
@@ -98,10 +98,7 @@ describe("ElectronMenu", () => {
|
||||
const electronMenu = yield* ElectronMenu.ElectronMenu;
|
||||
const selectedItemId = yield* electronMenu.showContextMenu({
|
||||
window: makeWindow(2),
|
||||
items: [
|
||||
{ id: "copy", label: "Copy" },
|
||||
{ id: "delete", label: "Delete", destructive: true, separatorBefore: true },
|
||||
],
|
||||
items: [{ id: "copy", label: "Copy" }],
|
||||
position: Option.some({ x: 10.8, y: 20.2 }),
|
||||
});
|
||||
|
||||
@@ -113,38 +110,6 @@ describe("ElectronMenu", () => {
|
||||
enabled: true,
|
||||
click: buildFromTemplateMock.mock.calls[0]?.[0][0].click,
|
||||
});
|
||||
assert.deepEqual(
|
||||
buildFromTemplateMock.mock.calls[0]?.[0].map(
|
||||
(item: Electron.MenuItemConstructorOptions) => item.type ?? item.label,
|
||||
),
|
||||
["Copy", "separator", "Delete"],
|
||||
);
|
||||
}).pipe(Effect.provide(TestLayer)),
|
||||
);
|
||||
|
||||
it.effect("keeps a preceding non-destructive action in the destructive section", () =>
|
||||
Effect.gen(function* () {
|
||||
buildFromTemplateMock.mockImplementation(() => ({
|
||||
popup: (options: Electron.PopupOptions) => options.callback?.(),
|
||||
}));
|
||||
|
||||
const electronMenu = yield* ElectronMenu.ElectronMenu;
|
||||
yield* electronMenu.showContextMenu({
|
||||
window: makeWindow(),
|
||||
items: [
|
||||
{ id: "copy", label: "Copy" },
|
||||
{ id: "archive", label: "Archive", separatorBefore: true },
|
||||
{ id: "delete", label: "Delete", destructive: true },
|
||||
],
|
||||
position: Option.none(),
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
buildFromTemplateMock.mock.calls[0]?.[0].map(
|
||||
(item: Electron.MenuItemConstructorOptions) => item.type ?? item.label,
|
||||
),
|
||||
["Copy", "separator", "Archive", "Delete"],
|
||||
);
|
||||
}).pipe(Effect.provide(TestLayer)),
|
||||
);
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ function normalizeContextMenuItems(source: readonly ContextMenuItem[]): ContextM
|
||||
label: sourceItem.label,
|
||||
destructive: sourceItem.destructive === true,
|
||||
disabled: sourceItem.disabled === true,
|
||||
...(sourceItem.separatorBefore === true ? { separatorBefore: true } : {}),
|
||||
};
|
||||
|
||||
if (sourceItem.children) {
|
||||
@@ -142,24 +141,10 @@ export const make = Effect.gen(function* () {
|
||||
): Electron.MenuItemConstructorOptions[] => {
|
||||
const template: Electron.MenuItemConstructorOptions[] = [];
|
||||
let hasInsertedDestructiveSeparator = false;
|
||||
let sectionStartedByExplicitSeparator = false;
|
||||
const appendSeparator = () => {
|
||||
if (template.length === 0 || template.at(-1)?.type === "separator") return;
|
||||
template.push({ type: "separator" });
|
||||
};
|
||||
|
||||
for (const item of entries) {
|
||||
if (item.separatorBefore) {
|
||||
appendSeparator();
|
||||
sectionStartedByExplicitSeparator = true;
|
||||
}
|
||||
if (
|
||||
item.destructive &&
|
||||
!hasInsertedDestructiveSeparator &&
|
||||
!sectionStartedByExplicitSeparator &&
|
||||
template.length > 0
|
||||
) {
|
||||
appendSeparator();
|
||||
if (item.destructive && !hasInsertedDestructiveSeparator && template.length > 0) {
|
||||
template.push({ type: "separator" });
|
||||
hasInsertedDestructiveSeparator = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { REMOTE_CAPABLE_EDITOR_IDS, remoteSchemeForEditor } from "@t3tools/contracts";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
@@ -6,16 +5,7 @@ import * as Option from "effect/Option";
|
||||
|
||||
import * as Electron from "electron";
|
||||
|
||||
// Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`)
|
||||
// must reach the OS handler; every other non-web scheme stays blocked.
|
||||
const SAFE_EXTERNAL_PROTOCOLS = new Set([
|
||||
"http:",
|
||||
"https:",
|
||||
...REMOTE_CAPABLE_EDITOR_IDS.flatMap((id) => {
|
||||
const scheme = remoteSchemeForEditor(id);
|
||||
return scheme === undefined ? [] : [`${scheme}:`];
|
||||
}),
|
||||
]);
|
||||
const SAFE_EXTERNAL_PROTOCOLS = new Set(["http:", "https:"]);
|
||||
|
||||
export function parseSafeExternalUrl(rawUrl: unknown): Option.Option<string> {
|
||||
if (typeof rawUrl !== "string") {
|
||||
|
||||
@@ -34,10 +34,8 @@ import {
|
||||
getAppBranding,
|
||||
getLocalEnvironmentBootstraps,
|
||||
getLocalEnvironmentBearerToken,
|
||||
getSystemLocale,
|
||||
getWindowFullscreenState,
|
||||
openExternal,
|
||||
probeRemoteEditors,
|
||||
pickFolder,
|
||||
pickThemeFiles,
|
||||
setTheme,
|
||||
@@ -51,7 +49,6 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
|
||||
yield* PreviewIpc.installPreviewEventForwarding();
|
||||
|
||||
yield* ipc.handleSync(getAppBranding);
|
||||
yield* ipc.handleSync(getSystemLocale);
|
||||
yield* ipc.handleSync(getWindowFullscreenState);
|
||||
yield* ipc.handleSync(getLocalEnvironmentBootstraps);
|
||||
yield* ipc.handle(getLocalEnvironmentBearerToken);
|
||||
@@ -86,7 +83,6 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
|
||||
yield* ipc.handle(setTheme);
|
||||
yield* ipc.handle(showContextMenu);
|
||||
yield* ipc.handle(openExternal);
|
||||
yield* ipc.handle(probeRemoteEditors);
|
||||
yield* ipc.handle(getUpdateState);
|
||||
yield* ipc.handle(setUpdateChannel);
|
||||
yield* ipc.handle(downloadUpdate);
|
||||
|
||||
@@ -3,9 +3,7 @@ export const PICK_THEME_FILES_CHANNEL = "desktop:pick-theme-files";
|
||||
export const SET_THEME_CHANNEL = "desktop:set-theme";
|
||||
export const CONTEXT_MENU_CHANNEL = "desktop:context-menu";
|
||||
export const OPEN_EXTERNAL_CHANNEL = "desktop:open-external";
|
||||
export const PROBE_REMOTE_EDITORS_CHANNEL = "desktop:probe-remote-editors";
|
||||
export const MENU_ACTION_CHANNEL = "desktop:menu-action";
|
||||
export const QUIT_SHORTCUT_CHANNEL = "desktop:quit-shortcut";
|
||||
export const GET_WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:get-window-fullscreen-state";
|
||||
export const WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:window-fullscreen-state";
|
||||
export const UPDATE_STATE_CHANNEL = "desktop:update-state";
|
||||
@@ -15,7 +13,6 @@ export const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
|
||||
export const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
|
||||
export const UPDATE_CHECK_CHANNEL = "desktop:update-check";
|
||||
export const GET_APP_BRANDING_CHANNEL = "desktop:get-app-branding";
|
||||
export const GET_SYSTEM_LOCALE_CHANNEL = "desktop:get-system-locale";
|
||||
export const GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL = "desktop:get-local-environment-bootstraps";
|
||||
export const GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL =
|
||||
"desktop:get-local-environment-bearer-token";
|
||||
|
||||
@@ -3,16 +3,12 @@ import {
|
||||
DesktopAppBrandingSchema,
|
||||
DesktopEnvironmentBootstrapSchema,
|
||||
DesktopThemeSchema,
|
||||
EDITORS,
|
||||
EditorId,
|
||||
PickedThemeFileSchema,
|
||||
PickFolderOptionsSchema,
|
||||
PRIMARY_LOCAL_ENVIRONMENT_ID,
|
||||
REMOTE_CAPABLE_EDITOR_IDS,
|
||||
type DesktopEnvironmentBootstrap,
|
||||
type PickedThemeFile,
|
||||
} from "@t3tools/contracts";
|
||||
import { isCommandAvailable } from "@t3tools/shared/shell";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -26,7 +22,6 @@ import * as DesktopEnvironment from "../../app/DesktopEnvironment.ts";
|
||||
import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopWslBackend from "../../wsl/DesktopWslBackend.ts";
|
||||
import * as DesktopWslEnvironment from "../../wsl/DesktopWslEnvironment.ts";
|
||||
import * as ElectronApp from "../../electron/ElectronApp.ts";
|
||||
import * as ElectronDialog from "../../electron/ElectronDialog.ts";
|
||||
import * as ElectronMenu from "../../electron/ElectronMenu.ts";
|
||||
import * as ElectronShell from "../../electron/ElectronShell.ts";
|
||||
@@ -65,15 +60,6 @@ export const getAppBranding = DesktopIpc.makeSyncIpcMethod({
|
||||
}),
|
||||
});
|
||||
|
||||
export const getSystemLocale = DesktopIpc.makeSyncIpcMethod({
|
||||
channel: IpcChannels.GET_SYSTEM_LOCALE_CHANNEL,
|
||||
result: Schema.String,
|
||||
handler: Effect.fn("desktop.ipc.window.getSystemLocale")(function* () {
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
return yield* electronApp.systemLocale;
|
||||
}),
|
||||
});
|
||||
|
||||
export const getWindowFullscreenState = DesktopIpc.makeSyncIpcMethod({
|
||||
channel: IpcChannels.GET_WINDOW_FULLSCREEN_STATE_CHANNEL,
|
||||
result: Schema.Boolean,
|
||||
@@ -275,30 +261,6 @@ export const openExternal = DesktopIpc.makeIpcMethod({
|
||||
}),
|
||||
});
|
||||
|
||||
export const probeRemoteEditors = DesktopIpc.makeIpcMethod({
|
||||
channel: IpcChannels.PROBE_REMOTE_EDITORS_CHANNEL,
|
||||
payload: Schema.Undefined,
|
||||
result: Schema.Array(EditorId),
|
||||
// Probes THIS machine (where the renderer runs) for remote-capable editor
|
||||
// CLIs, unlike the server's probe which walks the environment host's PATH.
|
||||
// A Finder-launched app can miss PATH entries; an empty result makes the
|
||||
// renderer fall back to VS Code only, so that fails soft.
|
||||
handler: Effect.fn("desktop.ipc.window.probeRemoteEditors")(function* () {
|
||||
const available: Array<EditorId> = [];
|
||||
for (const editorId of REMOTE_CAPABLE_EDITOR_IDS) {
|
||||
const commands = EDITORS.find((editor) => editor.id === editorId)?.commands;
|
||||
if (!commands) continue;
|
||||
for (const command of commands) {
|
||||
if (yield* isCommandAvailable(command, { env: process.env })) {
|
||||
available.push(editorId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return available;
|
||||
}),
|
||||
});
|
||||
|
||||
/** Theme files are a few KB; anything larger returns empty text and lets the
|
||||
* renderer reject it by size without the contents ever crossing the bridge. */
|
||||
const PICKED_THEME_FILE_MAX_BYTES = 256 * 1024;
|
||||
|
||||
@@ -10,11 +10,8 @@ import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts";
|
||||
import * as DesktopShutdown from "../../app/DesktopShutdown.ts";
|
||||
import * as DesktopState from "../../app/DesktopState.ts";
|
||||
import * as ElectronApp from "../../electron/ElectronApp.ts";
|
||||
import * as ElectronDialog from "../../electron/ElectronDialog.ts";
|
||||
import * as ElectronTheme from "../../electron/ElectronTheme.ts";
|
||||
import * as ElectronWindow from "../../electron/ElectronWindow.ts";
|
||||
import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";
|
||||
import * as DesktopWindow from "../../window/DesktopWindow.ts";
|
||||
import * as DesktopWslBackend from "../../wsl/DesktopWslBackend.ts";
|
||||
import * as DesktopWslEnvironment from "../../wsl/DesktopWslEnvironment.ts";
|
||||
@@ -73,15 +70,6 @@ const unusedLifecycleRuntimeLayer = Layer.mergeAll(
|
||||
ElectronTheme.ElectronTheme,
|
||||
ElectronTheme.ElectronTheme.of({} as ElectronTheme.ElectronTheme["Service"]),
|
||||
),
|
||||
Layer.succeed(
|
||||
ElectronDialog.ElectronDialog,
|
||||
ElectronDialog.ElectronDialog.of({} as ElectronDialog.ElectronDialog["Service"]),
|
||||
),
|
||||
Layer.succeed(
|
||||
ElectronWindow.ElectronWindow,
|
||||
ElectronWindow.ElectronWindow.of({} as ElectronWindow.ElectronWindow["Service"]),
|
||||
),
|
||||
DesktopClientSettings.layerTest(),
|
||||
);
|
||||
|
||||
describe("WSL IPC", () => {
|
||||
|
||||
@@ -35,10 +35,6 @@ contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
}
|
||||
return result as ReturnType<DesktopBridge["getAppBranding"]>;
|
||||
},
|
||||
getSystemLocale: () => {
|
||||
const result = ipcRenderer.sendSync(IpcChannels.GET_SYSTEM_LOCALE_CHANNEL);
|
||||
return typeof result === "string" ? result : null;
|
||||
},
|
||||
getLocalEnvironmentBootstraps: () => {
|
||||
const result = ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL);
|
||||
if (!Array.isArray(result)) {
|
||||
@@ -109,7 +105,6 @@ contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
...(position === undefined ? {} : { position }),
|
||||
}),
|
||||
openExternal: (url: string) => ipcRenderer.invoke(IpcChannels.OPEN_EXTERNAL_CHANNEL, url),
|
||||
probeRemoteEditors: () => ipcRenderer.invoke(IpcChannels.PROBE_REMOTE_EDITORS_CHANNEL, undefined),
|
||||
onMenuAction: (listener) => {
|
||||
const wrappedListener = (_event: Electron.IpcRendererEvent, action: unknown) => {
|
||||
if (typeof action !== "string") return;
|
||||
@@ -121,17 +116,6 @@ contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
ipcRenderer.removeListener(IpcChannels.MENU_ACTION_CHANNEL, wrappedListener);
|
||||
};
|
||||
},
|
||||
onQuitShortcut: (listener) => {
|
||||
const wrappedListener = (_event: Electron.IpcRendererEvent, state: unknown) => {
|
||||
if (state !== "down" && state !== "up") return;
|
||||
listener(state);
|
||||
};
|
||||
|
||||
ipcRenderer.on(IpcChannels.QUIT_SHORTCUT_CHANNEL, wrappedListener);
|
||||
return () => {
|
||||
ipcRenderer.removeListener(IpcChannels.QUIT_SHORTCUT_CHANNEL, wrappedListener);
|
||||
};
|
||||
},
|
||||
getWindowFullscreenState: () =>
|
||||
ipcRenderer.sendSync(IpcChannels.GET_WINDOW_FULLSCREEN_STATE_CHANNEL) === true,
|
||||
onWindowFullscreenStateChange: (listener) => {
|
||||
|
||||
@@ -4,4 +4,3 @@ export const ELEMENT_PICKED_CHANNEL = "preview:element-picked";
|
||||
export const ANNOTATION_CAPTURED_CHANNEL = "preview:annotation-captured";
|
||||
export const ANNOTATION_THEME_CHANNEL = "preview:annotation-theme";
|
||||
export const HUMAN_INPUT_CHANNEL = "preview:human-input";
|
||||
export const MOUSE_NAVIGATE_CHANNEL = "preview:mouse-navigate";
|
||||
@@ -979,10 +979,7 @@ describe("PreviewManager", () => {
|
||||
),
|
||||
);
|
||||
|
||||
// The guest reports whatever zoom level Chromium handed it from the app
|
||||
// window, so the tab's own zoom is the source of truth in both directions:
|
||||
// asserted onto every guest, never read back off one.
|
||||
effectIt.effect("keeps the tab's own zoom instead of the guest's reported zoom", () =>
|
||||
effectIt.effect("mirrors Electron's effective zoom across registration and navigation", () =>
|
||||
withManager((manager) =>
|
||||
Effect.gen(function* () {
|
||||
let effectiveZoom = 0.9;
|
||||
@@ -1028,13 +1025,18 @@ describe("PreviewManager", () => {
|
||||
yield* manager.createTab("tab_zoom");
|
||||
yield* manager.registerWebview("tab_zoom", 42);
|
||||
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1);
|
||||
expect(setZoomFactor).toHaveBeenCalledWith(1);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(0.9);
|
||||
expect(setZoomFactor).not.toHaveBeenCalled();
|
||||
|
||||
// An app zoom leaves the guest reporting the inherited level. Navigating
|
||||
// must not adopt it as the preview's zoom.
|
||||
effectiveZoom = 0.8;
|
||||
url = "https://example.com/after-app-zoom";
|
||||
effectiveZoom = 1.25;
|
||||
listeners.get("did-navigate")?.();
|
||||
yield* Effect.yieldNow;
|
||||
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.25);
|
||||
expect(setZoomFactor).not.toHaveBeenCalled();
|
||||
|
||||
zoomReadable = false;
|
||||
url = "https://example.com/after-zoom-read-failed";
|
||||
listeners.get("did-navigate")?.();
|
||||
yield* Effect.yieldNow;
|
||||
|
||||
@@ -1043,18 +1045,7 @@ describe("PreviewManager", () => {
|
||||
url,
|
||||
title: "Example",
|
||||
});
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1);
|
||||
|
||||
// Only the preview's own zoom controls move it.
|
||||
yield* manager.zoomIn("tab_zoom");
|
||||
expect(setZoomFactor).toHaveBeenCalledWith(1.1);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.1);
|
||||
|
||||
zoomReadable = false;
|
||||
listeners.get("did-navigate")?.();
|
||||
yield* Effect.yieldNow;
|
||||
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.1);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.25);
|
||||
|
||||
const replacementSetZoomFactor = vi.fn();
|
||||
fromId.mockReturnValue({
|
||||
@@ -1083,103 +1074,8 @@ describe("PreviewManager", () => {
|
||||
|
||||
yield* manager.registerWebview("tab_zoom", 43);
|
||||
|
||||
expect(replacementSetZoomFactor).toHaveBeenCalledWith(1.1);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.1);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
// Zooming the app UI pushes the window's zoom level onto every guest, so the
|
||||
// preview has to be put back at the zoom the user gave it.
|
||||
effectIt.effect("re-applies each tab's own zoom when the app window zooms", () =>
|
||||
withManager((manager) =>
|
||||
Effect.gen(function* () {
|
||||
const setZoomFactor = vi.fn();
|
||||
fromId.mockReturnValue({
|
||||
id: 42,
|
||||
isDestroyed: () => false,
|
||||
getType: () => "webview",
|
||||
getURL: () => "https://example.com",
|
||||
getTitle: () => "Example",
|
||||
isLoading: () => false,
|
||||
getZoomFactor: () => 1,
|
||||
setZoomFactor,
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
ipc: { on: vi.fn(), off: vi.fn() },
|
||||
send: webviewSend,
|
||||
navigationHistory: { canGoBack: () => false, canGoForward: () => false },
|
||||
setWindowOpenHandler: vi.fn(),
|
||||
debugger: {
|
||||
isAttached: () => false,
|
||||
attach: vi.fn(),
|
||||
sendCommand: vi.fn(async () => undefined),
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
},
|
||||
} as never);
|
||||
|
||||
yield* manager.createTab("tab_reapply");
|
||||
yield* manager.registerWebview("tab_reapply", 42);
|
||||
yield* manager.zoomIn("tab_reapply");
|
||||
setZoomFactor.mockClear();
|
||||
|
||||
yield* manager.reapplyZoom();
|
||||
|
||||
expect(setZoomFactor).toHaveBeenCalledTimes(1);
|
||||
expect(setZoomFactor).toHaveBeenCalledWith(1.1);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
// did-attach and dom-ready both re-register the guest that is already
|
||||
// attached, and a guest that just inherited the app window's zoom needs its
|
||||
// own back — without that round trip republishing tab state.
|
||||
effectIt.effect("re-asserts the tab's zoom when the active guest registers again", () =>
|
||||
withManager((manager) =>
|
||||
Effect.gen(function* () {
|
||||
const setZoomFactor = vi.fn();
|
||||
fromId.mockReturnValue({
|
||||
id: 42,
|
||||
isDestroyed: () => false,
|
||||
getType: () => "webview",
|
||||
getURL: () => "https://example.com",
|
||||
getTitle: () => "Example",
|
||||
isLoading: () => false,
|
||||
getZoomFactor: () => 1,
|
||||
setZoomFactor,
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
ipc: { on: vi.fn(), off: vi.fn() },
|
||||
send: webviewSend,
|
||||
navigationHistory: { canGoBack: () => false, canGoForward: () => false },
|
||||
setWindowOpenHandler: vi.fn(),
|
||||
debugger: {
|
||||
isAttached: () => false,
|
||||
attach: vi.fn(),
|
||||
sendCommand: vi.fn(async () => undefined),
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
},
|
||||
} as never);
|
||||
const states: PreviewManager.PreviewTabState[] = [];
|
||||
yield* manager.subscribeStateChanges((_tabId, state) =>
|
||||
Effect.sync(() => {
|
||||
states.push(state);
|
||||
}),
|
||||
);
|
||||
|
||||
yield* manager.createTab("tab_reregister_zoom");
|
||||
yield* manager.registerWebview("tab_reregister_zoom", 42);
|
||||
yield* manager.zoomIn("tab_reregister_zoom");
|
||||
setZoomFactor.mockClear();
|
||||
const publishedBefore = states.length;
|
||||
|
||||
yield* manager.registerWebview("tab_reregister_zoom", 42);
|
||||
|
||||
expect(setZoomFactor).toHaveBeenCalledWith(1.1);
|
||||
expect(states.length).toBe(publishedBefore);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.1);
|
||||
expect(replacementSetZoomFactor).toHaveBeenCalledWith(1.25);
|
||||
expect(states.at(-1)?.zoomFactor).toBe(1.25);
|
||||
}),
|
||||
),
|
||||
);
|
||||
@@ -2239,69 +2135,6 @@ describe("PreviewManager", () => {
|
||||
),
|
||||
);
|
||||
|
||||
effectIt.effect("navigates the guest history when the thumb-button ipc fires", () =>
|
||||
withManager((manager) =>
|
||||
Effect.gen(function* () {
|
||||
let mouseNavigate: ((event: unknown, payload: unknown) => void) | undefined;
|
||||
const goBack = vi.fn();
|
||||
const goForward = vi.fn();
|
||||
let canGoBack = true;
|
||||
fromId.mockReturnValue({
|
||||
id: 42,
|
||||
isDestroyed: () => false,
|
||||
getType: () => "webview",
|
||||
getURL: () => "https://example.com",
|
||||
getTitle: () => "Example",
|
||||
isLoading: () => false,
|
||||
getZoomFactor: () => 1,
|
||||
setZoomFactor: vi.fn(),
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
ipc: {
|
||||
on: vi.fn((channel: string, listener: typeof mouseNavigate) => {
|
||||
if (channel === "preview:mouse-navigate") mouseNavigate = listener;
|
||||
}),
|
||||
off: vi.fn(),
|
||||
},
|
||||
send: webviewSend,
|
||||
navigationHistory: {
|
||||
canGoBack: () => canGoBack,
|
||||
canGoForward: () => true,
|
||||
goBack,
|
||||
goForward,
|
||||
},
|
||||
setWindowOpenHandler: vi.fn(),
|
||||
debugger: {
|
||||
isAttached: () => false,
|
||||
attach: vi.fn(),
|
||||
sendCommand: vi.fn(async () => undefined),
|
||||
on: vi.fn(),
|
||||
off: vi.fn(),
|
||||
},
|
||||
} as never);
|
||||
|
||||
yield* manager.createTab("tab_nav");
|
||||
yield* manager.registerWebview("tab_nav", 42);
|
||||
expect(mouseNavigate).toBeDefined();
|
||||
|
||||
mouseNavigate?.({}, { direction: "back" });
|
||||
yield* Effect.yieldNow;
|
||||
expect(goBack).toHaveBeenCalledOnce();
|
||||
|
||||
mouseNavigate?.({}, { direction: "forward" });
|
||||
yield* Effect.yieldNow;
|
||||
expect(goForward).toHaveBeenCalledOnce();
|
||||
|
||||
// Ignores unknown payloads and never navigates when history is exhausted.
|
||||
mouseNavigate?.({}, { direction: "sideways" });
|
||||
canGoBack = false;
|
||||
mouseNavigate?.({}, { direction: "back" });
|
||||
yield* Effect.yieldNow;
|
||||
expect(goBack).toHaveBeenCalledOnce();
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
effectIt.effect("reveals only files inside the configured browser artifact directory", () =>
|
||||
withManager((manager) =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -58,7 +58,6 @@ import {
|
||||
CANCEL_PICK_CHANNEL,
|
||||
ELEMENT_PICKED_CHANNEL,
|
||||
HUMAN_INPUT_CHANNEL,
|
||||
MOUSE_NAVIGATE_CHANNEL,
|
||||
START_PICK_CHANNEL,
|
||||
} from "./GuestProtocol.ts";
|
||||
import { isPreviewAnnotationPayload } from "./PickedElementPayload.ts";
|
||||
@@ -648,22 +647,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
if (Option.isSome(next)) yield* emit(tabId, next.value);
|
||||
});
|
||||
|
||||
/**
|
||||
* Pushes a tab's zoom factor onto whichever guest it currently owns, reading
|
||||
* both at call time. Anything that applies zoom after an await goes through
|
||||
* here: a snapshot taken before the await can be older than a zoom action that
|
||||
* landed in between, and re-applying it would roll that action back.
|
||||
*/
|
||||
const assertTabZoom = Effect.fn("PreviewManager.assertTabZoom")(function* (tabId: string) {
|
||||
const tab = (yield* SynchronizedRef.get(tabsRef)).get(tabId);
|
||||
if (!tab || tab.webContentsId == null) return;
|
||||
const wc = webContents.fromId(tab.webContentsId);
|
||||
if (!wc || wc.isDestroyed()) return;
|
||||
yield* attempt({ operation: "assertTabZoom", tabId, webContentsId: wc.id }, () =>
|
||||
wc.setZoomFactor(tab.zoomFactor),
|
||||
).pipe(Effect.ignore);
|
||||
});
|
||||
|
||||
const requireWebContents = Effect.fn("PreviewManager.requireWebContents")(function* (
|
||||
tabId: string,
|
||||
) {
|
||||
@@ -1322,6 +1305,10 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
confirmedNavigation = false,
|
||||
) {
|
||||
if (wc.isDestroyed()) return;
|
||||
const zoomFactor = yield* attempt(
|
||||
{ operation: "syncWebContentsState.getZoomFactor", tabId, webContentsId: wc.id },
|
||||
() => wc.getZoomFactor(),
|
||||
).pipe(Effect.option);
|
||||
const computedNavStatus = computeNavStatus(wc);
|
||||
const canGoBack = wc.navigationHistory.canGoBack();
|
||||
const canGoForward = wc.navigationHistory.canGoForward();
|
||||
@@ -1351,9 +1338,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
navStatus,
|
||||
canGoBack,
|
||||
canGoForward,
|
||||
// zoomFactor is deliberately not read back from the guest: Chromium
|
||||
// reports the level it inherited from the app window, so mirroring it
|
||||
// would turn an app zoom into the preview's own zoom.
|
||||
...(Option.isSome(zoomFactor) ? { zoomFactor: zoomFactor.value } : {}),
|
||||
updatedAt,
|
||||
};
|
||||
return [
|
||||
@@ -1507,22 +1492,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
const humanInput = (_event: unknown, rawSignal?: unknown): void => {
|
||||
runFork(handleHumanInput(rawSignal));
|
||||
};
|
||||
const mouseNavigate = (_event: unknown, payload?: unknown): void => {
|
||||
const direction =
|
||||
typeof payload === "object" && payload !== null && "direction" in payload
|
||||
? (payload as { direction?: unknown }).direction
|
||||
: undefined;
|
||||
if (direction !== "back" && direction !== "forward") return;
|
||||
runFork(
|
||||
attempt({ operation: "mouseNavigate", tabId, webContentsId: wc.id }, () => {
|
||||
if (direction === "back") {
|
||||
if (wc.navigationHistory.canGoBack()) wc.navigationHistory.goBack();
|
||||
} else if (wc.navigationHistory.canGoForward()) {
|
||||
wc.navigationHistory.goForward();
|
||||
}
|
||||
}).pipe(Effect.ignore),
|
||||
);
|
||||
};
|
||||
const forwardShortcut = Effect.fn("PreviewManager.forwardShortcut")(function* (
|
||||
event: Electron.Event,
|
||||
input: Electron.Input,
|
||||
@@ -1569,7 +1538,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
wc.off("did-fail-load", failed as never);
|
||||
wc.off("before-input-event", beforeInput);
|
||||
wc.ipc.off(HUMAN_INPUT_CHANNEL, humanInput);
|
||||
wc.ipc.off(MOUSE_NAVIGATE_CHANNEL, mouseNavigate);
|
||||
}).pipe(Effect.ignore),
|
||||
);
|
||||
const install = Effect.fn("PreviewManager.installWebContentsListeners")(function* () {
|
||||
@@ -1583,7 +1551,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
wc.on("did-stop-loading", sync);
|
||||
wc.on("did-fail-load", failed as never);
|
||||
wc.ipc.on(HUMAN_INPUT_CHANNEL, humanInput);
|
||||
wc.ipc.on(MOUSE_NAVIGATE_CHANNEL, mouseNavigate);
|
||||
wc.setWindowOpenHandler(({ url }) => {
|
||||
runFork(
|
||||
attemptPromise({ operation: "openPreviewWindow", tabId, webContentsId: wc.id }, () =>
|
||||
@@ -1749,10 +1716,11 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
const annotationTheme = yield* Ref.get(annotationThemeRef);
|
||||
const currentAttachment = attached.get(webContentsId);
|
||||
if (tab.webContentsId === webContentsId && currentAttachment?.webContents === wc) {
|
||||
// The guest we already own re-announced itself, so nothing about the tab
|
||||
// changed. Only push its zoom back down — Chromium may have just handed
|
||||
// this guest the app window's zoom level.
|
||||
yield* assertTabZoom(tabId);
|
||||
const zoomFactor = yield* attempt(
|
||||
{ operation: "registerWebview.getZoomFactor", tabId, webContentsId },
|
||||
() => wc.getZoomFactor(),
|
||||
);
|
||||
yield* update(tabId, { zoomFactor });
|
||||
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () =>
|
||||
wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme),
|
||||
);
|
||||
@@ -1781,13 +1749,18 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
) {
|
||||
return yield* new PreviewTabNotFoundError({ tabId });
|
||||
}
|
||||
// Always assert the tab's own zoom rather than reading the guest's: a guest
|
||||
// attaching while the app UI is zoomed starts at the embedder's inherited
|
||||
// zoom level, which is not the preview's zoom. Done before the guest is
|
||||
// published so it never paints a frame at the inherited zoom.
|
||||
yield* attempt({ operation: "registerWebview.restoreZoomFactor", tabId, webContentsId }, () =>
|
||||
wc.setZoomFactor(currentTab.zoomFactor),
|
||||
);
|
||||
const zoomFactor =
|
||||
replacedWebContentsId !== null
|
||||
? yield* attempt(
|
||||
{ operation: "registerWebview.restoreZoomFactor", tabId, webContentsId },
|
||||
() => {
|
||||
wc.setZoomFactor(currentTab.zoomFactor);
|
||||
return currentTab.zoomFactor;
|
||||
},
|
||||
)
|
||||
: yield* attempt({ operation: "registerWebview.getZoomFactor", tabId, webContentsId }, () =>
|
||||
wc.getZoomFactor(),
|
||||
);
|
||||
yield* attachListeners(tabId, wc);
|
||||
const registeredAt = yield* currentIso;
|
||||
const registration = yield* SynchronizedRef.modifyEffect(tabsRef, (tabs) =>
|
||||
@@ -1811,6 +1784,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
navStatus: pendingUrl === null ? computeNavStatus(wc) : current.navStatus,
|
||||
canGoBack: wc.navigationHistory.canGoBack(),
|
||||
canGoForward: wc.navigationHistory.canGoForward(),
|
||||
zoomFactor,
|
||||
updatedAt: registeredAt,
|
||||
};
|
||||
return [
|
||||
@@ -1832,9 +1806,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
return yield* new PreviewTabNotFoundError({ tabId });
|
||||
}
|
||||
const { state: registered, pendingUrl } = registration.value;
|
||||
// A zoom action that landed while this attach was in flight addressed the
|
||||
// guest this one replaced, so settle the new guest on the committed factor.
|
||||
yield* assertTabZoom(tabId);
|
||||
runFork(restoreControlSession(tabId, wc));
|
||||
yield* emit(tabId, registered);
|
||||
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () =>
|
||||
@@ -2128,17 +2099,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Chromium hands every guest `<webview>` the embedder's zoom level, so zooming
|
||||
* the app UI drags the previewed page along with it. The preview browser owns
|
||||
* its own zoom factor, so re-assert it on each attached guest whenever the main
|
||||
* window's zoom changes (see DesktopWindow.zoomMain).
|
||||
*/
|
||||
const reapplyZoom = Effect.fn("PreviewManager.reapplyZoom")(function* () {
|
||||
const tabIds = Array.from((yield* SynchronizedRef.get(tabsRef)).keys());
|
||||
yield* Effect.forEach(tabIds, assertTabZoom, { discard: true });
|
||||
});
|
||||
|
||||
const applyZoom = Effect.fn("PreviewManager.applyZoom")(function* (
|
||||
tabId: string,
|
||||
transform: (current: number) => number,
|
||||
@@ -3516,7 +3476,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
|
||||
openPictureInPicture,
|
||||
openDevTools,
|
||||
pickElement,
|
||||
reapplyZoom,
|
||||
refresh,
|
||||
registerWebview,
|
||||
resetZoom: (tabId: string) => applyZoom(tabId, () => DEFAULT_ZOOM_FACTOR),
|
||||
@@ -3815,9 +3774,6 @@ export class PreviewManager extends Context.Service<
|
||||
readonly zoomIn: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
|
||||
readonly zoomOut: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
|
||||
readonly resetZoom: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
|
||||
// Re-applies every attached guest's own zoom factor, undoing the zoom level
|
||||
// Chromium inherits from the embedder when the app UI zooms.
|
||||
readonly reapplyZoom: () => Effect.Effect<void>;
|
||||
readonly hardReload: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
|
||||
readonly setColorScheme: (
|
||||
tabId: string,
|
||||
@@ -3918,7 +3874,6 @@ export const make = Effect.gen(function* PreviewManagerMake() {
|
||||
zoomIn: operations.zoomIn,
|
||||
zoomOut: operations.zoomOut,
|
||||
resetZoom: operations.resetZoom,
|
||||
reapplyZoom: operations.reapplyZoom,
|
||||
hardReload: operations.hardReload,
|
||||
setColorScheme: operations.setColorScheme,
|
||||
openDevTools: operations.openDevTools,
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
CANCEL_PICK_CHANNEL,
|
||||
ELEMENT_PICKED_CHANNEL,
|
||||
HUMAN_INPUT_CHANNEL,
|
||||
MOUSE_NAVIGATE_CHANNEL,
|
||||
START_PICK_CHANNEL,
|
||||
} from "./GuestProtocol.ts";
|
||||
const OVERLAY_ATTRIBUTE = "data-t3code-annotation-ui";
|
||||
@@ -103,40 +102,6 @@ const reportHumanKeyInput = (event: KeyboardEvent): void => {
|
||||
window.addEventListener("pointerdown", reportHumanPointerInput, true);
|
||||
window.addEventListener("keydown", reportHumanKeyInput, true);
|
||||
|
||||
// Mouse thumb buttons: `button === 3` is Back, `button === 4` is Forward.
|
||||
const MOUSE_BUTTON_BACK = 3;
|
||||
const MOUSE_BUTTON_FORWARD = 4;
|
||||
|
||||
const navigationDirectionForButton = (button: number): "back" | "forward" | null => {
|
||||
if (button === MOUSE_BUTTON_BACK) return "back";
|
||||
if (button === MOUSE_BUTTON_FORWARD) return "forward";
|
||||
return null;
|
||||
};
|
||||
|
||||
// Chromium routes thumb-button history navigation to the *focused* WebContents,
|
||||
// so hovering this guest without focusing it sends the host app's router back
|
||||
// instead of the preview. Suppress Chromium's default here and drive this tab's
|
||||
// history explicitly so the buttons always navigate the browser the pointer is
|
||||
// over — never the host app.
|
||||
const suppressNavigationButton = (event: MouseEvent): void => {
|
||||
if (!event.isTrusted || navigationDirectionForButton(event.button) === null) return;
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
};
|
||||
|
||||
const requestNavigationForButton = (event: MouseEvent): void => {
|
||||
if (!event.isTrusted) return;
|
||||
const direction = navigationDirectionForButton(event.button);
|
||||
if (direction === null) return;
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
ipcRenderer.send(MOUSE_NAVIGATE_CHANNEL, { direction });
|
||||
};
|
||||
|
||||
window.addEventListener("mousedown", suppressNavigationButton, true);
|
||||
window.addEventListener("mouseup", requestNavigationForButton, true);
|
||||
window.addEventListener("auxclick", suppressNavigationButton, true);
|
||||
|
||||
const nextId = (prefix: string): string => {
|
||||
idSequence += 1;
|
||||
return `${prefix}_${idSequence.toString(36)}`;
|
||||
|
||||
@@ -13,7 +13,6 @@ import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
|
||||
import * as DesktopClientSettings from "./DesktopClientSettings.ts";
|
||||
|
||||
const clientSettings: ClientSettings = {
|
||||
confirmQuit: true,
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
dismissedProviderUpdateNotificationKeys: [],
|
||||
|
||||
@@ -152,108 +152,6 @@ describe("DesktopShellEnvironment", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("hydrates the locale from the login shell on macOS", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
|
||||
yield* runShellEnvironment({
|
||||
env,
|
||||
platform: "darwin",
|
||||
handler: () =>
|
||||
envOutput({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
LANG: "de_DE.UTF-8",
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(env.LANG, "de_DE.UTF-8");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("preserves an inherited locale over the login shell on macOS", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
LANG: "en_US.UTF-8",
|
||||
};
|
||||
|
||||
yield* runShellEnvironment({
|
||||
env,
|
||||
platform: "darwin",
|
||||
handler: () =>
|
||||
envOutput({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
LANG: "de_DE.UTF-8",
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(env.LANG, "en_US.UTF-8");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("does not mix login-shell locale categories into an inherited locale", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
LANG: "en_US.UTF-8",
|
||||
};
|
||||
|
||||
yield* runShellEnvironment({
|
||||
env,
|
||||
platform: "darwin",
|
||||
handler: () =>
|
||||
envOutput({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
LC_ALL: "de_DE.UTF-8",
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(env.LANG, "en_US.UTF-8");
|
||||
assert.equal(env.LC_ALL, undefined);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("falls back to a UTF-8 LC_CTYPE when no locale is available on macOS", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
|
||||
yield* runShellEnvironment({
|
||||
env,
|
||||
platform: "darwin",
|
||||
handler: () => envOutput({ PATH: "/opt/homebrew/bin:/usr/bin" }),
|
||||
});
|
||||
|
||||
assert.equal(env.LANG, undefined);
|
||||
assert.equal(env.LC_ALL, undefined);
|
||||
assert.equal(env.LC_CTYPE, "en_US.UTF-8");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("does not apply the locale fallback on linux", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
|
||||
yield* runShellEnvironment({
|
||||
env,
|
||||
platform: "linux",
|
||||
handler: () => envOutput({ PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin" }),
|
||||
});
|
||||
|
||||
assert.equal(env.LANG, undefined);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("hydrates PATH and missing SSH_AUTH_SOCK from the login shell on linux", () =>
|
||||
Effect.gen(function* () {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
|
||||
@@ -71,9 +71,6 @@ const LOGIN_SHELL_ENV_NAMES = [
|
||||
"PATH",
|
||||
"DBUS_SESSION_BUS_ADDRESS",
|
||||
"DISPLAY",
|
||||
"LANG",
|
||||
"LC_ALL",
|
||||
"LC_CTYPE",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
@@ -87,8 +84,6 @@ const LOGIN_SHELL_ENV_NAMES = [
|
||||
"WAYLAND_DISPLAY",
|
||||
] as const;
|
||||
const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
|
||||
const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
|
||||
const FALLBACK_LC_CTYPE = "en_US.UTF-8";
|
||||
const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"] as const;
|
||||
const LOGIN_SHELL_TIMEOUT = Duration.seconds(5);
|
||||
const LAUNCHCTL_TIMEOUT = Duration.seconds(2);
|
||||
@@ -477,29 +472,6 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
|
||||
}
|
||||
}
|
||||
|
||||
// Locale variables form one precedence group: LC_ALL can override an inherited
|
||||
// LANG or LC_CTYPE, so only hydrate the group when the process has none of them.
|
||||
if (
|
||||
config.platform === "darwin" &&
|
||||
LOCALE_ENV_NAMES.every((name) => Option.isNone(trimNonEmpty(config.env[name])))
|
||||
) {
|
||||
for (const name of LOCALE_ENV_NAMES) {
|
||||
const value = trimNonEmpty(shellEnvironment[name]);
|
||||
if (Option.isSome(value)) {
|
||||
config.env[name] = value.value;
|
||||
}
|
||||
}
|
||||
|
||||
// GUI launches inherit no locale from launchd, so spawned agents land in the C
|
||||
// locale and pbcopy decodes their UTF-8 output as MacRoman. Older supported
|
||||
// macOS releases do not provide C.UTF-8, so set only LC_CTYPE to a UTF-8 locale
|
||||
// available on those releases. Leaving LANG unset keeps C-stable collation and
|
||||
// formatting, so output parsing is unaffected.
|
||||
if (LOCALE_ENV_NAMES.every((name) => Option.isNone(trimNonEmpty(config.env[name])))) {
|
||||
config.env.LC_CTYPE = FALLBACK_LC_CTYPE;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
config.platform === "linux" &&
|
||||
Option.isNone(trimNonEmpty(config.env.DBUS_SESSION_BUS_ADDRESS))
|
||||
|
||||
@@ -26,7 +26,6 @@ function makeElectronAppLayer(
|
||||
return Layer.succeed(ElectronApp.ElectronApp, {
|
||||
metadata: Effect.die("unexpected metadata read"),
|
||||
name: Effect.succeed("T3 Code"),
|
||||
systemLocale: Effect.succeed("en-US"),
|
||||
whenReady: Effect.void,
|
||||
quit: Effect.void,
|
||||
exit: () => Effect.void,
|
||||
|
||||
@@ -31,7 +31,6 @@ const environmentInput = {
|
||||
const electronAppLayer = Layer.succeed(ElectronApp.ElectronApp, {
|
||||
metadata: Effect.die("unexpected metadata read"),
|
||||
name: Effect.succeed("T3 Code"),
|
||||
systemLocale: Effect.succeed("en-US"),
|
||||
whenReady: Effect.void,
|
||||
quit: Effect.void,
|
||||
exit: () => Effect.void,
|
||||
|
||||
@@ -37,8 +37,6 @@ import * as DesktopConfig from "../app/DesktopConfig.ts";
|
||||
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
|
||||
import * as DesktopState from "../app/DesktopState.ts";
|
||||
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopClientSettings from "../settings/DesktopClientSettings.ts";
|
||||
import * as ElectronApp from "../electron/ElectronApp.ts";
|
||||
import * as ElectronMenu from "../electron/ElectronMenu.ts";
|
||||
import * as ElectronShell from "../electron/ElectronShell.ts";
|
||||
import * as ElectronTheme from "../electron/ElectronTheme.ts";
|
||||
@@ -63,14 +61,9 @@ const environmentInput = {
|
||||
function makeFakeBrowserWindow() {
|
||||
const windowListeners = new Map<string, (...args: readonly unknown[]) => void>();
|
||||
const webContentsListeners = new Map<string, (...args: readonly unknown[]) => void>();
|
||||
let zoomLevel = 0;
|
||||
const webContents = {
|
||||
copyImageAt: vi.fn(),
|
||||
getURL: vi.fn(() => "t3code-dev://app/"),
|
||||
getZoomLevel: vi.fn(() => zoomLevel),
|
||||
setZoomLevel: vi.fn((level: number) => {
|
||||
zoomLevel = level;
|
||||
}),
|
||||
isLoadingMainFrame: vi.fn(() => false),
|
||||
on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
|
||||
webContentsListeners.set(eventName, listener);
|
||||
@@ -123,21 +116,12 @@ function makeFakeBrowserWindow() {
|
||||
openDevTools: webContents.openDevTools,
|
||||
reload: webContents.reload,
|
||||
send: webContents.send,
|
||||
setZoomLevel: webContents.setZoomLevel,
|
||||
setAutoHideCursor: window.setAutoHideCursor,
|
||||
webContentsListeners,
|
||||
windowListeners,
|
||||
};
|
||||
}
|
||||
|
||||
const desktopClientSettingsLayer = Layer.mock(DesktopClientSettings.DesktopClientSettings)({
|
||||
get: Effect.succeed(Option.none()),
|
||||
});
|
||||
|
||||
const electronAppLayer = Layer.mock(ElectronApp.ElectronApp)({
|
||||
quit: Effect.void,
|
||||
});
|
||||
|
||||
const desktopAssetsLayer = Layer.succeed(DesktopAssets.DesktopAssets, {
|
||||
iconPaths: Effect.succeed({
|
||||
ico: Option.none<string>(),
|
||||
@@ -202,7 +186,6 @@ function makeTestLayer(input: {
|
||||
bounds: DesktopAppSettings.DesktopWindowBounds,
|
||||
) => Effect.Effect<void>;
|
||||
readonly openedExternalUrls?: unknown[];
|
||||
readonly previewZoomReapplies?: number[];
|
||||
}) {
|
||||
let desktopSettings = input.desktopSettings ?? DesktopAppSettings.DEFAULT_DESKTOP_SETTINGS;
|
||||
const desktopAppSettingsLayer = Layer.succeed(DesktopAppSettings.DesktopAppSettings, {
|
||||
@@ -263,10 +246,8 @@ function makeTestLayer(input: {
|
||||
desktopAssetsLayer,
|
||||
desktopEnvironmentLayer,
|
||||
desktopAppSettingsLayer,
|
||||
desktopClientSettingsLayer,
|
||||
desktopServerExposureLayer,
|
||||
DesktopState.layer,
|
||||
electronAppLayer,
|
||||
electronMenuLayer,
|
||||
Layer.succeed(ElectronShell.ElectronShell, {
|
||||
openExternal: (url) =>
|
||||
@@ -283,10 +264,6 @@ function makeTestLayer(input: {
|
||||
setMainWindow: () => Effect.void,
|
||||
isBrowserPartition: (partition) => partition.startsWith("persist:t3code-preview-"),
|
||||
getBrowserPartition: () => Effect.succeed("persist:t3code-preview-test"),
|
||||
reapplyZoom: () =>
|
||||
Effect.sync(() => {
|
||||
input.previewZoomReapplies?.push(input.window.webContents.getZoomLevel());
|
||||
}),
|
||||
}),
|
||||
),
|
||||
),
|
||||
@@ -368,9 +345,7 @@ const makeSplashScenario = (createOutcomes: readonly (Electron.BrowserWindow | n
|
||||
desktopAssetsLayer,
|
||||
desktopEnvironmentLayer,
|
||||
DesktopAppSettings.layerTest(),
|
||||
desktopClientSettingsLayer,
|
||||
desktopServerExposureLayer,
|
||||
electronAppLayer,
|
||||
electronMenuLayer,
|
||||
Layer.succeed(ElectronShell.ElectronShell, {
|
||||
openExternal: () => Effect.succeed(true),
|
||||
@@ -508,42 +483,6 @@ describe("DesktopWindow", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
// Chromium hands the main window's zoom level down to embedded preview
|
||||
// guests, so every app zoom has to put the preview browser back at its own
|
||||
// zoom or zooming the UI drags the previewed page with it.
|
||||
it.effect("restores the preview browser's own zoom after zooming the app", () =>
|
||||
Effect.gen(function* () {
|
||||
const fakeWindow = makeFakeBrowserWindow();
|
||||
const createCount = yield* Ref.make(0);
|
||||
const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
|
||||
const previewZoomReapplies: number[] = [];
|
||||
const layer = makeTestLayer({
|
||||
window: fakeWindow.window,
|
||||
createCount,
|
||||
mainWindow,
|
||||
previewZoomReapplies,
|
||||
});
|
||||
|
||||
yield* Effect.gen(function* () {
|
||||
const desktopWindow = yield* DesktopWindow.DesktopWindow;
|
||||
yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
|
||||
|
||||
yield* desktopWindow.zoomMain("out");
|
||||
yield* desktopWindow.zoomMain("out");
|
||||
yield* desktopWindow.zoomMain("in");
|
||||
yield* desktopWindow.zoomMain("reset");
|
||||
|
||||
assert.deepEqual(
|
||||
fakeWindow.setZoomLevel.mock.calls.map(([level]) => level),
|
||||
[-0.5, -1, -0.5, 0],
|
||||
);
|
||||
// Recorded after the window level moved, so the preview is put back at
|
||||
// its own zoom on every step rather than left on the inherited one.
|
||||
assert.deepEqual(previewZoomReapplies, [-0.5, -1, -0.5, 0]);
|
||||
}).pipe(Effect.provide(layer));
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("uses the persisted main window bounds when opening the window", () =>
|
||||
Effect.gen(function* () {
|
||||
const fakeWindow = makeFakeBrowserWindow();
|
||||
|
||||
@@ -8,8 +8,6 @@ import * as Ref from "effect/Ref";
|
||||
|
||||
import * as Electron from "electron";
|
||||
|
||||
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts";
|
||||
|
||||
import * as DesktopAssets from "../app/DesktopAssets.ts";
|
||||
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
|
||||
import { makeComponentLogger } from "../app/DesktopObservability.ts";
|
||||
@@ -18,16 +16,9 @@ import { getDesktopUrl } from "../electron/ElectronProtocol.ts";
|
||||
import * as ElectronShell from "../electron/ElectronShell.ts";
|
||||
import * as ElectronTheme from "../electron/ElectronTheme.ts";
|
||||
import * as ElectronWindow from "../electron/ElectronWindow.ts";
|
||||
import {
|
||||
MENU_ACTION_CHANNEL,
|
||||
QUIT_SHORTCUT_CHANNEL,
|
||||
WINDOW_FULLSCREEN_STATE_CHANNEL,
|
||||
} from "../ipc/channels.ts";
|
||||
import { MENU_ACTION_CHANNEL, WINDOW_FULLSCREEN_STATE_CHANNEL } from "../ipc/channels.ts";
|
||||
import * as PreviewManager from "../preview/Manager.ts";
|
||||
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopClientSettings from "../settings/DesktopClientSettings.ts";
|
||||
import * as ElectronApp from "../electron/ElectronApp.ts";
|
||||
import { makeQuitHoldHandler } from "./QuitHold.ts";
|
||||
|
||||
const TITLEBAR_HEIGHT = 40;
|
||||
const TITLEBAR_COLOR = "#01000000"; // #00000000 does not work correctly on Linux
|
||||
@@ -60,8 +51,6 @@ type DesktopWindowRuntimeServices =
|
||||
| DesktopEnvironment.DesktopEnvironment
|
||||
| DesktopAssets.DesktopAssets
|
||||
| DesktopAppSettings.DesktopAppSettings
|
||||
| DesktopClientSettings.DesktopClientSettings
|
||||
| ElectronApp.ElectronApp
|
||||
| ElectronMenu.ElectronMenu
|
||||
| ElectronShell.ElectronShell
|
||||
| ElectronTheme.ElectronTheme
|
||||
@@ -272,8 +261,6 @@ export const make = Effect.gen(function* () {
|
||||
const electronWindow = yield* ElectronWindow.ElectronWindow;
|
||||
const previewManager = yield* PreviewManager.PreviewManager;
|
||||
const desktopSettings = yield* DesktopAppSettings.DesktopAppSettings;
|
||||
const clientSettings = yield* DesktopClientSettings.DesktopClientSettings;
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
// Window-side latch for the primary backend's readiness. Set by
|
||||
// handleBackendReady (driven by the pool's onReady callback), cleared
|
||||
// by handleBackendNotReady (driven by onShutdown). Only consumed by
|
||||
@@ -546,32 +533,7 @@ export const make = Effect.gen(function* () {
|
||||
// close-terminal shortcut can outlive the terminal that handled its first
|
||||
// press, so reject repeats before they reach the native window accelerator.
|
||||
// Deliberate presses still flow through the renderer or native menu.
|
||||
// Chrome-style hold-to-quit: intercept the quit accelerator before the
|
||||
// native menu sees it and only quit after the shortcut is held. The
|
||||
// renderer shows the "Hold to Quit" hint via QUIT_SHORTCUT_CHANNEL.
|
||||
const quitHoldHandler = makeQuitHoldHandler({
|
||||
platform: environment.platform,
|
||||
isEnabled: () =>
|
||||
runPromise(
|
||||
Effect.map(
|
||||
clientSettings.get,
|
||||
Option.match({
|
||||
onNone: () => DEFAULT_CLIENT_SETTINGS.confirmQuit,
|
||||
onSome: (settings) => settings.confirmQuit,
|
||||
}),
|
||||
),
|
||||
),
|
||||
notify: (state) => {
|
||||
if (!window.isDestroyed()) {
|
||||
window.webContents.send(QUIT_SHORTCUT_CHANNEL, state);
|
||||
}
|
||||
},
|
||||
quit: () => {
|
||||
void runPromise(electronApp.quit);
|
||||
},
|
||||
});
|
||||
window.webContents.on("before-input-event", (event, input) => {
|
||||
quitHoldHandler(event, input);
|
||||
if (input.type !== "keyDown" || !input.isAutoRepeat) return;
|
||||
const modifier = environment.platform === "darwin" ? input.meta : input.control;
|
||||
if (modifier && !input.alt && !input.shift && input.key.toLowerCase() === "w") {
|
||||
@@ -893,10 +855,6 @@ export const make = Effect.gen(function* () {
|
||||
webContents.setZoomLevel(
|
||||
direction === "reset" ? 0 : webContents.getZoomLevel() + (direction === "in" ? 0.5 : -0.5),
|
||||
);
|
||||
// Chromium pushes the new level down to embedded guests, which would zoom
|
||||
// the previewed page along with the app UI. The preview browser keeps its
|
||||
// own zoom, so put each guest back where the preview left it.
|
||||
yield* previewManager.reapplyZoom();
|
||||
}),
|
||||
syncAppearance: Effect.gen(function* () {
|
||||
const shouldUseDarkColors = yield* electronTheme.shouldUseDarkColors;
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
makeQuitHoldHandler,
|
||||
QUIT_DOUBLE_TAP_MS,
|
||||
QUIT_HOLD_DURATION_MS,
|
||||
QUIT_HOLD_RELEASE_GRACE_MS,
|
||||
} from "./QuitHold.ts";
|
||||
import type { QuitHoldKeyInput, QuitHoldState } from "./QuitHold.ts";
|
||||
|
||||
function makeInput(overrides: Partial<QuitHoldKeyInput>): QuitHoldKeyInput {
|
||||
return {
|
||||
type: "keyDown",
|
||||
key: "q",
|
||||
meta: true,
|
||||
control: false,
|
||||
alt: false,
|
||||
shift: false,
|
||||
isAutoRepeat: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function makeHarness(options?: {
|
||||
enabled?: boolean;
|
||||
platform?: NodeJS.Platform;
|
||||
isEnabled?: () => Promise<boolean>;
|
||||
}) {
|
||||
const notifications: Array<QuitHoldState> = [];
|
||||
const quit = vi.fn();
|
||||
const handler = makeQuitHoldHandler({
|
||||
platform: options?.platform ?? "darwin",
|
||||
isEnabled: options?.isEnabled ?? (() => Promise.resolve(options?.enabled ?? true)),
|
||||
notify: (state) => notifications.push(state),
|
||||
quit,
|
||||
});
|
||||
const preventDefault = vi.fn();
|
||||
const send = async (input: QuitHoldKeyInput) => {
|
||||
handler({ preventDefault }, input);
|
||||
// Let the isEnabled promise settle.
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
};
|
||||
// Simulates the OS auto-repeating the held shortcut every `intervalMs`.
|
||||
const holdFor = async (
|
||||
durationMs: number,
|
||||
repeatOverrides: Partial<QuitHoldKeyInput> = {},
|
||||
intervalMs = 100,
|
||||
) => {
|
||||
for (let elapsed = 0; elapsed < durationMs; elapsed += intervalMs) {
|
||||
vi.advanceTimersByTime(intervalMs);
|
||||
await send(makeInput({ isAutoRepeat: true, ...repeatOverrides }));
|
||||
}
|
||||
};
|
||||
return { notifications, quit, preventDefault, send, holdFor };
|
||||
}
|
||||
|
||||
describe("makeQuitHoldHandler", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("shows the hint on a tap without quitting, even when the release is never seen", async () => {
|
||||
// macOS suppresses the letter's keyUp while Cmd is held, so a tap may
|
||||
// produce no keyUp at all. Quit must still not fire.
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
expect(harness.preventDefault).toHaveBeenCalledTimes(1);
|
||||
expect(harness.notifications).toEqual(["down"]);
|
||||
|
||||
vi.advanceTimersByTime(QUIT_HOLD_DURATION_MS + QUIT_HOLD_RELEASE_GRACE_MS);
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
// The watchdog dismisses the hint once the press is clearly over.
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
});
|
||||
|
||||
it("quits once the shortcut auto-repeats past the hold duration", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.holdFor(QUIT_HOLD_DURATION_MS - 200);
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
await harness.holdFor(400);
|
||||
expect(harness.quit).toHaveBeenCalledTimes(1);
|
||||
// Exactly one hint cycle for the whole hold.
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
});
|
||||
|
||||
it("does not quit when the hold stops before the duration", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.holdFor(500);
|
||||
await harness.send(makeInput({ type: "keyUp" }));
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
vi.advanceTimersByTime((QUIT_HOLD_DURATION_MS + QUIT_HOLD_RELEASE_GRACE_MS) * 2);
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("cancels the hold when the modifier is released first", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.send(makeInput({ type: "keyUp", key: "Meta", meta: false }));
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
vi.advanceTimersByTime((QUIT_HOLD_DURATION_MS + QUIT_HOLD_RELEASE_GRACE_MS) * 2);
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("quits immediately on a single press when disabled", async () => {
|
||||
const harness = makeHarness({ enabled: false });
|
||||
await harness.send(makeInput({}));
|
||||
expect(harness.quit).toHaveBeenCalledTimes(1);
|
||||
// The hint is dismissed in case the quit gets cancelled downstream.
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
});
|
||||
|
||||
it("discards a stale isEnabled resolution from a superseded press", async () => {
|
||||
// Press #1's isEnabled is still pending when the user releases and
|
||||
// presses again; its late resolution must not act for press #2.
|
||||
const resolvers: Array<(enabled: boolean) => void> = [];
|
||||
const harness = makeHarness({
|
||||
isEnabled: () => new Promise((resolve) => resolvers.push(resolve)),
|
||||
});
|
||||
await harness.send(makeInput({}));
|
||||
await harness.send(makeInput({ type: "keyUp" }));
|
||||
// Outside the double-tap window, so the second press starts a new hold.
|
||||
vi.advanceTimersByTime(QUIT_DOUBLE_TAP_MS + 100);
|
||||
await harness.send(makeInput({}));
|
||||
expect(resolvers).toHaveLength(2);
|
||||
|
||||
// Press #1 resolves late with "disabled" — it must not quit press #2.
|
||||
resolvers[0]?.(false);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
|
||||
// Press #2 resolves enabled and completes a full hold.
|
||||
resolvers[1]?.(true);
|
||||
await harness.holdFor(QUIT_HOLD_DURATION_MS + 200);
|
||||
expect(harness.quit).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("quits on a quick double tap, even when the first release was never seen", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
vi.advanceTimersByTime(QUIT_DOUBLE_TAP_MS - 100);
|
||||
await harness.send(makeInput({}));
|
||||
expect(harness.quit).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("treats two slow taps as separate presses", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.send(makeInput({ type: "keyUp" }));
|
||||
vi.advanceTimersByTime(QUIT_DOUBLE_TAP_MS + 100);
|
||||
await harness.send(makeInput({}));
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
expect(harness.notifications).toEqual(["down", "up", "down"]);
|
||||
});
|
||||
|
||||
it("cancels the hold when another key interrupts it", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.holdFor(500);
|
||||
// Shift pressed mid-hold breaks the gesture...
|
||||
await harness.send(makeInput({ shift: true }));
|
||||
expect(harness.notifications).toEqual(["down", "up"]);
|
||||
// ...so later repeats past the threshold must not quit.
|
||||
await harness.holdFor(QUIT_HOLD_DURATION_MS);
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not count an interrupted press toward a double tap", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({}));
|
||||
await harness.send(makeInput({ shift: true }));
|
||||
// A fresh press right after the interruption starts a new hold, not a
|
||||
// double-tap quit.
|
||||
await harness.send(makeInput({}));
|
||||
expect(harness.quit).not.toHaveBeenCalled();
|
||||
expect(harness.notifications).toEqual(["down", "up", "down"]);
|
||||
});
|
||||
|
||||
it("ignores other shortcuts", async () => {
|
||||
const harness = makeHarness();
|
||||
await harness.send(makeInput({ key: "w" }));
|
||||
await harness.send(makeInput({ shift: true }));
|
||||
await harness.send(makeInput({ meta: false }));
|
||||
expect(harness.preventDefault).not.toHaveBeenCalled();
|
||||
expect(harness.notifications).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses control on non-mac platforms", async () => {
|
||||
const harness = makeHarness({ platform: "linux" });
|
||||
await harness.send(makeInput({ meta: false, control: true }));
|
||||
expect(harness.preventDefault).toHaveBeenCalledTimes(1);
|
||||
await harness.holdFor(QUIT_HOLD_DURATION_MS + 200, { meta: false, control: true });
|
||||
expect(harness.quit).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -1,148 +0,0 @@
|
||||
// @effect-diagnostics globalDate:off globalTimers:off -- Synchronous before-input-event handler; key events must be timed and the watchdog scheduled outside any Effect runtime.
|
||||
|
||||
// Chrome-style hold-to-quit. The quit accelerator is intercepted in
|
||||
// before-input-event (which runs before the native menu accelerator), and the
|
||||
// app only quits once the shortcut has been held for QUIT_HOLD_DURATION_MS.
|
||||
// A quick tap just shows the renderer's "Hold to Quit" hint, and a second tap
|
||||
// within QUIT_DOUBLE_TAP_MS quits immediately. Quitting from the application
|
||||
// menu itself is untouched and quits immediately.
|
||||
export const QUIT_HOLD_DURATION_MS = 1200;
|
||||
// A second quick tap of the shortcut is the user insisting: quit immediately.
|
||||
export const QUIT_DOUBLE_TAP_MS = 500;
|
||||
// "Still held" is proven by auto-repeat keydowns, not by the absence of a
|
||||
// release: macOS suppresses a letter's keyUp while the command key is down, so
|
||||
// a tap's release can go completely unseen and a release-based timer would
|
||||
// quit anyway. The press is treated as released once no key event has arrived
|
||||
// for QUIT_HOLD_RELEASE_GRACE_MS past the hold duration. Keyboards with
|
||||
// auto-repeat disabled cannot hold-to-quit and fall back to the menu's Quit.
|
||||
export const QUIT_HOLD_RELEASE_GRACE_MS = 600;
|
||||
|
||||
export type QuitHoldState = "down" | "up";
|
||||
|
||||
export interface QuitHoldKeyInput {
|
||||
readonly type: string;
|
||||
readonly key: string;
|
||||
readonly meta: boolean;
|
||||
readonly control: boolean;
|
||||
readonly alt: boolean;
|
||||
readonly shift: boolean;
|
||||
readonly isAutoRepeat: boolean;
|
||||
}
|
||||
|
||||
export interface QuitHoldOptions {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly isEnabled: () => Promise<boolean>;
|
||||
readonly notify: (state: QuitHoldState) => void;
|
||||
readonly quit: () => void;
|
||||
}
|
||||
|
||||
export function makeQuitHoldHandler(
|
||||
options: QuitHoldOptions,
|
||||
): (event: { preventDefault: () => void }, input: QuitHoldKeyInput) => void {
|
||||
const modifierKey = options.platform === "darwin" ? "meta" : "control";
|
||||
let watchdog: NodeJS.Timeout | undefined;
|
||||
let holding = false;
|
||||
// Set once isEnabled resolves true; auto-repeats may only quit when armed.
|
||||
let armed = false;
|
||||
let heldSince = 0;
|
||||
let lastPressAt = 0;
|
||||
// Incremented on every new press and every release/quit so a pending
|
||||
// isEnabled() resolution from a superseded press cannot arm (or quit for)
|
||||
// the current one.
|
||||
let generation = 0;
|
||||
|
||||
const clearWatchdog = () => {
|
||||
if (watchdog !== undefined) {
|
||||
clearTimeout(watchdog);
|
||||
watchdog = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const release = () => {
|
||||
if (!holding) return;
|
||||
generation += 1;
|
||||
holding = false;
|
||||
armed = false;
|
||||
clearWatchdog();
|
||||
options.notify("up");
|
||||
};
|
||||
|
||||
// Dismisses the overlay first: if the quit is cancelled downstream the
|
||||
// renderer must not be left with a stuck "Hold to Quit" hint.
|
||||
const quitNow = () => {
|
||||
release();
|
||||
options.quit();
|
||||
};
|
||||
|
||||
return (event, input) => {
|
||||
const key = input.key.toLowerCase();
|
||||
if (input.type === "keyUp") {
|
||||
if (key === "q" || key === modifierKey) release();
|
||||
return;
|
||||
}
|
||||
if (input.type !== "keyDown") return;
|
||||
|
||||
const modifierDown = options.platform === "darwin" ? input.meta : input.control;
|
||||
if (!modifierDown || input.alt || input.shift || key !== "q") {
|
||||
// Any other key (or an extra modifier) pressed mid-hold breaks the
|
||||
// gesture; without this the hold timer keeps running through the
|
||||
// interruption and the next qualifying repeat would quit early. The
|
||||
// interrupted press also stops counting toward a double tap — but only
|
||||
// here, not in release(), which runs mid-restart on an unseen-release
|
||||
// re-press and must not wipe that press's own tap timestamp.
|
||||
if (holding && !input.isAutoRepeat) {
|
||||
lastPressAt = 0;
|
||||
release();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (input.isAutoRepeat) {
|
||||
if (armed && Date.now() - heldSince >= QUIT_HOLD_DURATION_MS) {
|
||||
quitNow();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
const previousPressAt = lastPressAt;
|
||||
lastPressAt = now;
|
||||
// A fresh keydown while "holding" means the key came back down after a
|
||||
// release macOS never delivered — so both branches below see real taps.
|
||||
if (previousPressAt !== 0 && now - previousPressAt <= QUIT_DOUBLE_TAP_MS) {
|
||||
quitNow();
|
||||
return;
|
||||
}
|
||||
if (holding) release();
|
||||
|
||||
generation += 1;
|
||||
const pressGeneration = generation;
|
||||
holding = true;
|
||||
heldSince = now;
|
||||
options.notify("down");
|
||||
void options.isEnabled().then(
|
||||
(enabled) => {
|
||||
if (generation !== pressGeneration) return;
|
||||
if (!enabled) {
|
||||
// Hold-to-quit disabled: a single press quits immediately.
|
||||
quitNow();
|
||||
return;
|
||||
}
|
||||
armed = true;
|
||||
// No auto-repeat by then means the key was released (possibly with a
|
||||
// suppressed keyUp) or repeat is disabled; either way, don't quit.
|
||||
watchdog = setTimeout(() => {
|
||||
watchdog = undefined;
|
||||
release();
|
||||
}, QUIT_HOLD_DURATION_MS + QUIT_HOLD_RELEASE_GRACE_MS);
|
||||
},
|
||||
// A failed settings read must never strand the quit request.
|
||||
() => {
|
||||
if (generation !== pressGeneration) return;
|
||||
quitNow();
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -77,7 +77,6 @@ const backendConfigurationLayer = Layer.succeed(
|
||||
const netLayer = Layer.succeed(NetService.NetService, {
|
||||
canListenOnHost: () => Effect.succeed(true),
|
||||
isPortAvailableOnLoopback: () => Effect.succeed(true),
|
||||
hasListenerOnHost: () => Effect.succeed(false),
|
||||
reserveLoopbackPort: () => Effect.succeed(41773),
|
||||
findAvailablePort: (preferred) => Effect.succeed(preferred),
|
||||
} satisfies NetService.NetService["Service"]);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { macArchFromGpuRenderer } from "./macArch";
|
||||
|
||||
describe("macArchFromGpuRenderer", () => {
|
||||
it("detects explicit Apple Silicon renderers", () => {
|
||||
expect(macArchFromGpuRenderer("Apple M4 Pro")).toBe("arm64");
|
||||
});
|
||||
|
||||
it("prefers an Intel GPU marker even when the renderer also mentions Apple", () => {
|
||||
expect(macArchFromGpuRenderer("ANGLE Metal Renderer: Apple, Intel Iris Plus Graphics")).toBe(
|
||||
"x64",
|
||||
);
|
||||
});
|
||||
|
||||
it("uses x64 for ambiguous Safari and unavailable renderer values", () => {
|
||||
expect(macArchFromGpuRenderer("Apple GPU")).toBe("x64");
|
||||
expect(macArchFromGpuRenderer("")).toBe("x64");
|
||||
});
|
||||
});
|
||||
@@ -1,16 +0,0 @@
|
||||
const INTEL_GPU_PATTERN = /intel|amd|radeon|nvidia|geforce/i;
|
||||
const APPLE_SILICON_GPU_PATTERN = /\bapple\s+m\d/i;
|
||||
|
||||
export function macArchFromGpuRenderer(renderer: string): "arm64" | "x64" {
|
||||
if (INTEL_GPU_PATTERN.test(renderer)) {
|
||||
return "x64";
|
||||
}
|
||||
if (APPLE_SILICON_GPU_PATTERN.test(renderer)) {
|
||||
return "arm64";
|
||||
}
|
||||
|
||||
// Generic "Apple GPU" renderers are ambiguous on Safari. x64 is the safe
|
||||
// fallback because Apple Silicon can run it through Rosetta, while Intel
|
||||
// Macs cannot run an arm64 build.
|
||||
return "x64";
|
||||
}
|
||||
@@ -391,33 +391,14 @@ const mobileEndorsementRows = [
|
||||
|
||||
<script>
|
||||
import { fetchLatestRelease, RELEASES_URL, type ReleaseAsset } from "../lib/releases";
|
||||
import { macArchFromGpuRenderer } from "../lib/macArch";
|
||||
|
||||
type Platform = { os: "mac" | "win" | "linux"; label: string; arch?: string };
|
||||
|
||||
// navigator.userAgent reports "Intel Mac OS X" on both Intel and Apple Silicon
|
||||
// Macs, so probe the GPU renderer instead: Apple Silicon exposes an "Apple" GPU.
|
||||
function detectMacArch(): "arm64" | "x64" {
|
||||
try {
|
||||
const canvas = document.createElement("canvas");
|
||||
const gl = (canvas.getContext("webgl") ||
|
||||
canvas.getContext("experimental-webgl")) as WebGLRenderingContext | null;
|
||||
const debugInfo = gl?.getExtension("WEBGL_debug_renderer_info");
|
||||
if (gl && debugInfo) {
|
||||
const renderer = String(gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) ?? "");
|
||||
return macArchFromGpuRenderer(renderer);
|
||||
}
|
||||
} catch {
|
||||
// fall through to the default below
|
||||
}
|
||||
return macArchFromGpuRenderer("");
|
||||
}
|
||||
|
||||
function detectPlatform(): Platform | null {
|
||||
const ua = navigator.userAgent;
|
||||
if (/Win/i.test(ua)) return { os: "win", label: "Download for Windows" };
|
||||
if (/Mac/i.test(ua)) {
|
||||
return { os: "mac", label: "Download for macOS", arch: detectMacArch() };
|
||||
return { os: "mac", label: "Download for macOS", arch: "arm64" };
|
||||
}
|
||||
if (/Linux/i.test(ua)) return { os: "linux", label: "Download for Linux" };
|
||||
return null;
|
||||
@@ -723,7 +704,7 @@ const mobileEndorsementRows = [
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
/* Three above the headline, two beside the CTA — keeps the copy clear. */
|
||||
/* Three stacked on the left, two on the right — keeps the center CTA clear. */
|
||||
.hero-float-mark.hf-claude {
|
||||
top: 44px;
|
||||
left: 10px;
|
||||
@@ -731,8 +712,8 @@ const mobileEndorsementRows = [
|
||||
}
|
||||
|
||||
.hero-float-mark.hf-grok {
|
||||
top: 44px;
|
||||
left: calc(50% - 39px);
|
||||
top: 240px;
|
||||
left: 4px;
|
||||
right: auto;
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
@@ -760,8 +741,8 @@ const mobileEndorsementRows = [
|
||||
|
||||
@media (max-width: 340px) {
|
||||
.hero-float-mark.hf-grok {
|
||||
top: 57px;
|
||||
left: calc(50% - 26px);
|
||||
top: 220px;
|
||||
left: 0;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 14px;
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
/* ─── Theme tokens ──────────────────────────────────────────────────── */
|
||||
@layer theme {
|
||||
:root {
|
||||
@variant android {
|
||||
--font-mono: "monospace";
|
||||
}
|
||||
|
||||
@variant light {
|
||||
/* Page backgrounds */
|
||||
--color-screen: #f2f2f7;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/Stac
|
||||
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Alert, Linking, Platform, ScrollView, View } from "react-native";
|
||||
import { Alert, Platform, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
@@ -95,21 +95,9 @@ export function ConnectionsNewRouteScreen({
|
||||
return;
|
||||
}
|
||||
|
||||
if (permission.canAskAgain) {
|
||||
Alert.alert(
|
||||
"Camera access needed",
|
||||
"Allow camera access to scan an environment pairing QR code.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Alert.alert(
|
||||
"Camera access needed",
|
||||
"Camera access was denied for this app. Open Settings to enable it.",
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{ text: "Open Settings", onPress: () => void Linking.openSettings() },
|
||||
],
|
||||
"Allow camera access to scan an environment pairing QR code.",
|
||||
);
|
||||
}, [cameraPermission?.granted, requestCameraPermission]);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ type AddProjectDestinationRouteParams = {
|
||||
readonly source?: string | string[];
|
||||
readonly remoteUrl?: string | string[];
|
||||
readonly repositoryTitle?: string | string[];
|
||||
readonly repositoryName?: string | string[];
|
||||
};
|
||||
|
||||
export function AddProjectDestinationRoute({
|
||||
|
||||
@@ -7,9 +7,6 @@ import {
|
||||
canCreateProjectInEnvironment,
|
||||
findExistingAddProject,
|
||||
getAddProjectInitialQuery,
|
||||
getCloneDestinationBrowsePath,
|
||||
getCloneDestinationPath,
|
||||
getCloneDirectoryName,
|
||||
resolveAddProjectPath,
|
||||
sortAddProjectProviderSources,
|
||||
type AddProjectRemoteSource,
|
||||
@@ -26,8 +23,8 @@ import {
|
||||
} from "@t3tools/client-runtime/state/filesystem";
|
||||
import {
|
||||
appendBrowsePathSegment,
|
||||
ensureBrowseDirectoryPath,
|
||||
inferProjectTitleFromPath,
|
||||
isWindowsPlatform,
|
||||
} from "@t3tools/client-runtime/state/projects";
|
||||
import { CommandId, type EnvironmentId, ProjectId } from "@t3tools/contracts";
|
||||
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
|
||||
@@ -239,18 +236,11 @@ function ProjectPathInput(props: {
|
||||
);
|
||||
}
|
||||
|
||||
// `pinnedDirectoryName` is the repository folder the clone destination keeps
|
||||
// appended to whatever folder the user browses to. The plain add-project flow
|
||||
// passes nothing, so it keeps proposing the browsed folder itself.
|
||||
function useBrowsePathInput(environment: EnvironmentOption | null, pinnedDirectoryName = "") {
|
||||
function useBrowsePathInput(environment: EnvironmentOption | null) {
|
||||
const environmentId = environment?.environmentId ?? null;
|
||||
const environmentBaseDirectory = environment?.baseDirectory ?? null;
|
||||
const clonePathCaseSensitive = !isWindowsPlatform(environment?.platform ?? "");
|
||||
const [pathInput, commitPathInput] = useState(() =>
|
||||
getCloneDestinationPath(
|
||||
getAddProjectInitialQuery(environmentBaseDirectory),
|
||||
pinnedDirectoryName,
|
||||
),
|
||||
getAddProjectInitialQuery(environmentBaseDirectory),
|
||||
);
|
||||
const previousEnvironmentIdRef = useRef(environmentId);
|
||||
const environmentRuntime = useRemoteEnvironmentRuntime(environmentId);
|
||||
@@ -269,60 +259,33 @@ function useBrowsePathInput(environment: EnvironmentOption | null, pinnedDirecto
|
||||
[browseNavigation],
|
||||
);
|
||||
const navigateToBrowsePath = useCallback(
|
||||
async (input: {
|
||||
readonly browseDirectoryPath: string;
|
||||
readonly selectedDirectoryName?: string;
|
||||
}) => {
|
||||
const selectedDirectoryPath = input.selectedDirectoryName
|
||||
? appendBrowsePathSegment(input.browseDirectoryPath, input.selectedDirectoryName)
|
||||
: input.browseDirectoryPath;
|
||||
const nextPathInput =
|
||||
pinnedDirectoryName && input.selectedDirectoryName
|
||||
? getCloneDestinationBrowsePath({
|
||||
browseDirectoryPath: input.browseDirectoryPath,
|
||||
selectedDirectoryName: input.selectedDirectoryName,
|
||||
cloneDirectoryName: pinnedDirectoryName,
|
||||
caseSensitive: clonePathCaseSensitive,
|
||||
})
|
||||
: getCloneDestinationPath(selectedDirectoryPath, pinnedDirectoryName);
|
||||
async (path: string) => {
|
||||
setIsBrowseNavigating(true);
|
||||
const committed = await browseNavigation.run(
|
||||
async () => {
|
||||
if (environment && canPreloadBrowsePath(environmentRuntime?.connectionState)) {
|
||||
await loadBrowsePath({
|
||||
environmentId: environment.environmentId,
|
||||
input: { partialPath: selectedDirectoryPath },
|
||||
input: { partialPath: path },
|
||||
});
|
||||
}
|
||||
},
|
||||
() => commitPathInput(nextPathInput),
|
||||
() => commitPathInput(path),
|
||||
);
|
||||
if (committed) {
|
||||
setIsBrowseNavigating(false);
|
||||
}
|
||||
return committed;
|
||||
},
|
||||
[
|
||||
browseNavigation,
|
||||
clonePathCaseSensitive,
|
||||
environment,
|
||||
environmentRuntime?.connectionState,
|
||||
loadBrowsePath,
|
||||
pinnedDirectoryName,
|
||||
],
|
||||
[browseNavigation, environment, environmentRuntime?.connectionState, loadBrowsePath],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (environmentId !== null && environmentId !== previousEnvironmentIdRef.current) {
|
||||
previousEnvironmentIdRef.current = environmentId;
|
||||
setPathInput(
|
||||
getCloneDestinationPath(
|
||||
getAddProjectInitialQuery(environmentBaseDirectory),
|
||||
pinnedDirectoryName,
|
||||
),
|
||||
);
|
||||
setPathInput(getAddProjectInitialQuery(environmentBaseDirectory));
|
||||
}
|
||||
}, [environmentBaseDirectory, environmentId, pinnedDirectoryName, setPathInput]);
|
||||
}, [environmentBaseDirectory, environmentId, setPathInput]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
@@ -669,7 +632,6 @@ export function AddProjectRepositoryScreen(props: {
|
||||
source,
|
||||
remoteUrl,
|
||||
repositoryTitle: remoteUrl,
|
||||
repositoryName: getCloneDirectoryName(remoteUrl),
|
||||
}),
|
||||
);
|
||||
setIsSubmitting(false);
|
||||
@@ -693,7 +655,6 @@ export function AddProjectRepositoryScreen(props: {
|
||||
source,
|
||||
remoteUrl: repository.sshUrl,
|
||||
repositoryTitle: repository.nameWithOwner,
|
||||
repositoryName: getCloneDirectoryName(repository.nameWithOwner),
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -737,11 +698,7 @@ function FolderBrowser(props: {
|
||||
readonly environment: EnvironmentOption;
|
||||
readonly pathInput: string;
|
||||
readonly setPathInput: (path: string) => void;
|
||||
readonly navigateToBrowsePath: (input: {
|
||||
readonly browseDirectoryPath: string;
|
||||
readonly selectedDirectoryName?: string;
|
||||
}) => Promise<boolean>;
|
||||
readonly pinnedDirectoryName?: string;
|
||||
readonly navigateToBrowsePath: (path: string) => Promise<boolean>;
|
||||
}) {
|
||||
const accentColor = useThemeColor("--color-icon-muted");
|
||||
const browsePath = useMemo(
|
||||
@@ -760,16 +717,9 @@ function FolderBrowser(props: {
|
||||
input: browseInput,
|
||||
}),
|
||||
);
|
||||
// A pinned repository folder does not exist yet, so filtering the listing by
|
||||
// it would empty the folder picker. Anything the user typed still filters.
|
||||
const pinnedDirectoryName = props.pinnedDirectoryName ?? "";
|
||||
const pinnedDirectoryMatches = isWindowsPlatform(props.environment.platform)
|
||||
? browsePath.filterQuery.toLowerCase() === pinnedDirectoryName.toLowerCase()
|
||||
: browsePath.filterQuery === pinnedDirectoryName;
|
||||
const browseFilterQuery = pinnedDirectoryMatches ? "" : browsePath.filterQuery;
|
||||
const { visibleEntries: visibleBrowseEntries } = useMemo(
|
||||
() => filterFilesystemBrowseEntries(browseState.data?.entries ?? [], browseFilterQuery),
|
||||
[browseFilterQuery, browseState.data?.entries],
|
||||
() => filterFilesystemBrowseEntries(browseState.data?.entries ?? [], browsePath.filterQuery),
|
||||
[browsePath.filterQuery, browseState.data?.entries],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -797,9 +747,7 @@ function FolderBrowser(props: {
|
||||
right={null}
|
||||
onPress={() => {
|
||||
if (browsePath.parentPath) {
|
||||
void props.navigateToBrowsePath({
|
||||
browseDirectoryPath: browsePath.parentPath,
|
||||
});
|
||||
void props.navigateToBrowsePath(browsePath.parentPath);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -812,10 +760,11 @@ function FolderBrowser(props: {
|
||||
isFirst={index === 0 && !browsePath.canBrowseUp}
|
||||
right={null}
|
||||
onPress={() => {
|
||||
void props.navigateToBrowsePath({
|
||||
browseDirectoryPath: browsePath.directoryPath,
|
||||
selectedDirectoryName: entry.name,
|
||||
});
|
||||
const nextPath =
|
||||
browsePath.directoryPath.length > 0
|
||||
? appendBrowsePathSegment(browsePath.directoryPath, entry.name)
|
||||
: ensureBrowseDirectoryPath(entry.fullPath);
|
||||
void props.navigateToBrowsePath(nextPath);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
@@ -887,7 +836,6 @@ export function AddProjectDestinationScreen(props: {
|
||||
readonly environmentId?: string | string[];
|
||||
readonly remoteUrl?: string | string[];
|
||||
readonly repositoryTitle?: string | string[];
|
||||
readonly repositoryName?: string | string[];
|
||||
}) {
|
||||
const cloneRepository = useAtomCommand(sourceControlEnvironment.cloneRepository, {
|
||||
reportFailure: false,
|
||||
@@ -896,15 +844,8 @@ export function AddProjectDestinationScreen(props: {
|
||||
const createProject = useCreateProject(environment);
|
||||
const remoteUrl = stringParam(props.remoteUrl);
|
||||
const repositoryTitle = stringParam(props.repositoryTitle);
|
||||
// A lookup derives this from "owner/repo", a pasted clone URL from its own
|
||||
// last segment. Older links without the param keep the browsed folder.
|
||||
// Trim once here: the path input and the folder-list filter must compare the
|
||||
// same value, or a deep link with a padded param empties the folder picker.
|
||||
const repositoryName = stringParam(props.repositoryName)?.trim() ?? "";
|
||||
const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } = useBrowsePathInput(
|
||||
environment,
|
||||
repositoryName,
|
||||
);
|
||||
const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } =
|
||||
useBrowsePathInput(environment);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -977,7 +918,6 @@ export function AddProjectDestinationScreen(props: {
|
||||
navigateToBrowsePath={navigateToBrowsePath}
|
||||
pathInput={pathInput}
|
||||
setPathInput={setPathInput}
|
||||
pinnedDirectoryName={repositoryName}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useAuth } from "@clerk/expo";
|
||||
import { AuthView, UserProfileView } from "@clerk/expo/native";
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { useCallback, useLayoutEffect } from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
import { hasCloudPublicConfig } from "../cloud/publicConfig";
|
||||
@@ -25,21 +25,11 @@ function ConfiguredSettingsAuthRouteScreen() {
|
||||
() => navigation.dispatch(StackActions.popTo("SettingsContent")),
|
||||
[navigation],
|
||||
);
|
||||
const hasBeenSignedIn = useRef(isSignedIn);
|
||||
if (isSignedIn) {
|
||||
hasBeenSignedIn.current = true;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (hasBeenSignedIn.current && isLoaded && isSignedIn === false) {
|
||||
navigation.dispatch(StackActions.popTo("SettingsContent"));
|
||||
}
|
||||
}, [isLoaded, isSignedIn, navigation]);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
|
||||
{isLoaded ? (
|
||||
hasBeenSignedIn.current ? (
|
||||
isSignedIn ? (
|
||||
<UserProfileView isDismissible={false} onHostBack={handleHostBack} />
|
||||
) : (
|
||||
<AuthView isDismissible={false} onHostBack={handleHostBack} />
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic";
|
||||
|
||||
describe("resolveAgentAwarenessPlatformPresentation", () => {
|
||||
it("explains that agent awareness settings are unavailable on Android", () => {
|
||||
expect(resolveAgentAwarenessPlatformPresentation("android")).toEqual({
|
||||
supported: false,
|
||||
subtitle: "iOS only",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves supported iOS settings unchanged", () => {
|
||||
expect(resolveAgentAwarenessPlatformPresentation("ios")).toEqual({
|
||||
supported: true,
|
||||
subtitle: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
export function resolveAgentAwarenessPlatformPresentation(platform: string): {
|
||||
readonly supported: boolean;
|
||||
readonly subtitle: string | undefined;
|
||||
} {
|
||||
return platform === "ios"
|
||||
? { supported: true, subtitle: undefined }
|
||||
: { supported: false, subtitle: "iOS only" };
|
||||
}
|
||||
@@ -46,7 +46,6 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
|
||||
import { SettingsRow } from "./components/SettingsRow";
|
||||
import { SettingsSection } from "./components/SettingsSection";
|
||||
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
|
||||
import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic";
|
||||
|
||||
type NotificationStatus = "checking" | "enabled" | "disabled" | "unsupported";
|
||||
type LiveActivityStatus = "checking" | "enabled" | "disabled" | "signed-out" | "linking";
|
||||
@@ -145,7 +144,6 @@ function ConfiguredSettingsRouteScreen() {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const agentAwarenessPushAvailable = supportsAgentAwarenessPush();
|
||||
const agentAwarenessPlatform = resolveAgentAwarenessPlatformPresentation(Platform.OS);
|
||||
const insets = useSafeAreaInsets();
|
||||
const navigation = useNavigation();
|
||||
const { getToken, isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
|
||||
@@ -475,12 +473,10 @@ function ConfiguredSettingsRouteScreen() {
|
||||
icon="bell.badge"
|
||||
label="Device Notifications"
|
||||
disabled={
|
||||
!agentAwarenessPlatform.supported ||
|
||||
!agentAwarenessPushAvailable ||
|
||||
notificationStatus === "checking" ||
|
||||
notificationStatus === "unsupported"
|
||||
}
|
||||
subtitle={agentAwarenessPlatform.subtitle}
|
||||
// Only reads as on when this device is actually registered with the
|
||||
// relay; otherwise notifications cannot be delivered regardless of
|
||||
// the local iOS permission.
|
||||
@@ -491,7 +487,6 @@ function ConfiguredSettingsRouteScreen() {
|
||||
/>
|
||||
<SettingsSwitchRow
|
||||
disabled={
|
||||
!agentAwarenessPlatform.supported ||
|
||||
!agentAwarenessPushAvailable ||
|
||||
!isLoaded ||
|
||||
liveActivityStatus === "checking" ||
|
||||
@@ -499,7 +494,6 @@ function ConfiguredSettingsRouteScreen() {
|
||||
}
|
||||
icon="bolt.circle"
|
||||
label="Live Activity Updates"
|
||||
subtitle={agentAwarenessPlatform.subtitle}
|
||||
// Same gate: a saved preference is meaningless until the device
|
||||
// registration the relay needs to push updates has succeeded.
|
||||
value={
|
||||
|
||||
@@ -11,7 +11,6 @@ export function SettingsSwitchRow(props: {
|
||||
readonly disabled?: boolean;
|
||||
readonly icon: SymbolName;
|
||||
readonly label: string;
|
||||
readonly subtitle?: string;
|
||||
readonly value: boolean;
|
||||
readonly onValueChange: (value: boolean) => void;
|
||||
}) {
|
||||
@@ -28,12 +27,7 @@ export function SettingsSwitchRow(props: {
|
||||
}
|
||||
>
|
||||
<SymbolView name={props.icon} size={22} tintColor={icon} type="monochrome" weight="regular" />
|
||||
<View className="min-w-0 flex-1">
|
||||
<Text className="text-lg text-foreground">{props.label}</Text>
|
||||
{props.subtitle ? (
|
||||
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<Text className="flex-1 text-lg text-foreground">{props.label}</Text>
|
||||
<Switch
|
||||
disabled={props.disabled}
|
||||
ios_backgroundColor={track}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
isProviderSendTurnSupportedImageMimeType,
|
||||
PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
|
||||
PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -163,13 +162,6 @@ export async function buildIncomingShareDraft(input: {
|
||||
await releaseOwnedFiles(input.fileReader, [uri, payload.value]);
|
||||
continue;
|
||||
}
|
||||
if (!isProviderSendTurnSupportedImageMimeType(mimeType)) {
|
||||
warnings.push(
|
||||
`'${resolved?.originalName ?? fallbackName(uri, index, mimeType)}' is not a supported image type.`,
|
||||
);
|
||||
await releaseOwnedFiles(input.fileReader, [uri, payload.value]);
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
resolved?.contentSize !== null &&
|
||||
resolved?.contentSize !== undefined &&
|
||||
|
||||
@@ -56,7 +56,6 @@ import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/re
|
||||
import { enqueueThreadOutboxMessage, removeThreadOutboxMessage } from "../../state/thread-outbox";
|
||||
import { useRemoteConnectionStatus } from "../../state/use-remote-environment-registry";
|
||||
import { useNewTaskFlow } from "./new-task-flow-provider";
|
||||
import { resolveProjectThreadCreationBranch } from "./projectThreadCreationValidation";
|
||||
import { useCreateProjectThread } from "./use-project-actions";
|
||||
import { resolveDraftProjectSelection } from "./new-task-project-selection";
|
||||
import {
|
||||
@@ -584,17 +583,11 @@ export function NewTaskDraftScreen(props: {
|
||||
flow.environments.find(
|
||||
(environment) => environment.environmentId === flow.selectedEnvironmentId,
|
||||
)?.environmentLabel ?? "Environment";
|
||||
const availableCurrentBranchName =
|
||||
const currentBranchName =
|
||||
flow.availableBranches.find((branch) => branch.current)?.name ??
|
||||
flow.availableBranches.find((branch) => branch.isDefault)?.name ??
|
||||
null;
|
||||
const selectedBranchName = resolveProjectThreadCreationBranch({
|
||||
workspaceMode: flow.workspaceMode,
|
||||
selectedBranch:
|
||||
flow.selectedBranchName ??
|
||||
(flow.workspaceMode === "worktree" ? availableCurrentBranchName : null),
|
||||
currentCheckoutBranch: flow.currentCheckoutBranchName,
|
||||
});
|
||||
const selectedBranchName = flow.selectedBranchName ?? currentBranchName;
|
||||
const selectedBranchLabel = resolveNewTaskBranchLabel({
|
||||
branchName: selectedBranchName,
|
||||
startFromOrigin: flow.startFromOrigin,
|
||||
@@ -720,16 +713,11 @@ export function NewTaskDraftScreen(props: {
|
||||
threadTitle: deriveThreadTitleFromPrompt(initialMessageText),
|
||||
projectTitle: selectedProject.title,
|
||||
});
|
||||
const creationBranch = resolveProjectThreadCreationBranch({
|
||||
workspaceMode,
|
||||
selectedBranch: selectedBranchName,
|
||||
currentCheckoutBranch: flow.currentCheckoutBranchName,
|
||||
});
|
||||
const result = await createProjectThread({
|
||||
project: selectedProject,
|
||||
modelSelection,
|
||||
envMode: workspaceMode,
|
||||
branch: creationBranch,
|
||||
branch: selectedBranchName,
|
||||
worktreePath: workspaceMode === "worktree" ? null : selectedWorktreePath,
|
||||
startFromOrigin,
|
||||
runtimeMode,
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Image,
|
||||
Linking,
|
||||
Platform,
|
||||
type LayoutChangeEvent,
|
||||
type NativeScrollEvent,
|
||||
@@ -50,7 +51,6 @@ import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
|
||||
import { useFontFamily } from "../../lib/useFontFamily";
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
|
||||
import { hasWideMarkdownBlock } from "../../lib/wideMarkdownBlocks";
|
||||
import {
|
||||
hasNativeSelectableMarkdownText,
|
||||
@@ -283,7 +283,7 @@ const MarkdownExternalLink = memo(function MarkdownExternalLink(props: {
|
||||
<NativeText
|
||||
className="font-sans"
|
||||
onPress={() => {
|
||||
void tryOpenExternalUrl(props.href, "markdown-link");
|
||||
void Linking.openURL(props.href);
|
||||
}}
|
||||
style={{
|
||||
color: props.color,
|
||||
@@ -613,7 +613,7 @@ function useMarkdownStyles(onLinkPress: (href: string) => void): MarkdownStyleSe
|
||||
onPress={
|
||||
linkHref
|
||||
? () => {
|
||||
void tryOpenExternalUrl(linkHref, "markdown-link");
|
||||
void Linking.openURL(linkHref);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
@@ -1436,7 +1436,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
}
|
||||
|
||||
if (presentation.href) {
|
||||
void tryOpenExternalUrl(presentation.href, "markdown-link");
|
||||
void Linking.openURL(presentation.href);
|
||||
}
|
||||
},
|
||||
[props.environmentId, props.threadId, props.workspaceRoot, navigation],
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
useComposerDraft,
|
||||
} from "../../state/use-composer-drafts";
|
||||
import { useDebouncedValue, usePaginatedBranches } from "../../state/queries";
|
||||
import { vcsEnvironment } from "../../state/vcs";
|
||||
import {
|
||||
flattenQueuedThreadMessages,
|
||||
threadOutboxManager,
|
||||
@@ -140,7 +139,6 @@ type NewTaskFlowContextValue = {
|
||||
readonly branchesFetchingNextPage: boolean;
|
||||
readonly hasMoreBranches: boolean;
|
||||
readonly availableBranches: ReadonlyArray<VcsRef>;
|
||||
readonly currentCheckoutBranchName: string | null;
|
||||
readonly runtimeMode: RuntimeMode;
|
||||
readonly interactionMode: ProviderInteractionMode;
|
||||
readonly planModeEnabled: boolean;
|
||||
@@ -555,22 +553,6 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
),
|
||||
[allBranchRefs],
|
||||
);
|
||||
// The ref actually checked out in the project root, serialized onto new
|
||||
// local threads. It comes from the live status stream rather than listRefs'
|
||||
// `current` flag, which is served from a cache that can lag an out-of-band
|
||||
// `git switch` by minutes — and from the same value the PR badge compares
|
||||
// against. Detached HEAD and non-repository projects report no ref, so this
|
||||
// stays null instead of fabricating a branch. The status family is
|
||||
// deduplicated per (environmentId, cwd) with the thread rows.
|
||||
const projectGitStatus = useEnvironmentQuery(
|
||||
branchTarget.environmentId !== null && branchTarget.cwd !== null
|
||||
? vcsEnvironment.status({
|
||||
environmentId: branchTarget.environmentId,
|
||||
input: { cwd: branchTarget.cwd },
|
||||
})
|
||||
: null,
|
||||
);
|
||||
const currentCheckoutBranchName = projectGitStatus.data?.refName ?? null;
|
||||
|
||||
const filteredBranches = useMemo(() => {
|
||||
const query = branchQuery.trim().toLowerCase();
|
||||
@@ -877,10 +859,6 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
...(projectTitle !== undefined ? { projectTitle } : {}),
|
||||
...(projectCwd !== undefined ? { projectCwd } : {}),
|
||||
workspaceMode: mode,
|
||||
// Only an explicit picker choice, never the current checkout: a
|
||||
// queued local task drains days later against whatever is checked
|
||||
// out then, so recording a queue-time guess would pin a stale label
|
||||
// to a thread that ran somewhere else.
|
||||
branch: workspaceSelection?.branch ?? null,
|
||||
worktreePath: mode === "worktree" ? null : (workspaceSelection?.worktreePath ?? null),
|
||||
// The draft only carries the flag when the user touched it; fall
|
||||
@@ -1018,7 +996,6 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
branchesFetchingNextPage,
|
||||
hasMoreBranches,
|
||||
availableBranches,
|
||||
currentCheckoutBranchName,
|
||||
runtimeMode,
|
||||
interactionMode,
|
||||
planModeEnabled,
|
||||
@@ -1066,7 +1043,6 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
branchesFetchingNextPage,
|
||||
buildPendingTaskMessage,
|
||||
cancelEditingPendingTask,
|
||||
currentCheckoutBranchName,
|
||||
editingPendingTask,
|
||||
environments,
|
||||
expandedProvider,
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { resolveProjectThreadCreationBranch } from "./projectThreadCreationValidation";
|
||||
|
||||
describe("resolveProjectThreadCreationBranch", () => {
|
||||
it("uses the live checkout for an untouched local draft label and recorded branch", () => {
|
||||
expect(
|
||||
resolveProjectThreadCreationBranch({
|
||||
workspaceMode: "local",
|
||||
selectedBranch: null,
|
||||
currentCheckoutBranch: "feature/x",
|
||||
}),
|
||||
).toBe("feature/x");
|
||||
});
|
||||
|
||||
it("prefers an explicit picker choice over the current checkout", () => {
|
||||
expect(
|
||||
resolveProjectThreadCreationBranch({
|
||||
workspaceMode: "local",
|
||||
selectedBranch: "main",
|
||||
currentCheckoutBranch: "feature/x",
|
||||
}),
|
||||
).toBe("main");
|
||||
});
|
||||
|
||||
it("stays null when no ref is checked out (detached HEAD, non-repository, status not loaded)", () => {
|
||||
expect(
|
||||
resolveProjectThreadCreationBranch({
|
||||
workspaceMode: "local",
|
||||
selectedBranch: null,
|
||||
currentCheckoutBranch: null,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("never borrows the current checkout for a worktree draft", () => {
|
||||
expect(
|
||||
resolveProjectThreadCreationBranch({
|
||||
workspaceMode: "worktree",
|
||||
selectedBranch: null,
|
||||
currentCheckoutBranch: "feature/x",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps the explicit base branch for a worktree draft", () => {
|
||||
expect(
|
||||
resolveProjectThreadCreationBranch({
|
||||
workspaceMode: "worktree",
|
||||
selectedBranch: "main",
|
||||
currentCheckoutBranch: "feature/x",
|
||||
}),
|
||||
).toBe("main");
|
||||
});
|
||||
});
|
||||
@@ -32,26 +32,6 @@ export const ProjectThreadCreationValidationError = Schema.Union([
|
||||
]);
|
||||
export type ProjectThreadCreationValidationError = typeof ProjectThreadCreationValidationError.Type;
|
||||
|
||||
/**
|
||||
* Branch recorded on a thread created from the new-task composer. An explicit
|
||||
* picker choice always wins. An untouched current-checkout draft records the
|
||||
* ref that is actually checked out, so the thread's PR badge and branch label
|
||||
* match the live git status instead of staying blank. A detached HEAD, a
|
||||
* non-repository project, or a status that has not arrived stays null rather
|
||||
* than fabricating a branch. Only the online creation path resolves a
|
||||
* checkout; a queued task cannot know the checkout it will drain against.
|
||||
*/
|
||||
export function resolveProjectThreadCreationBranch(input: {
|
||||
readonly workspaceMode: "local" | "worktree";
|
||||
readonly selectedBranch: string | null;
|
||||
readonly currentCheckoutBranch: string | null;
|
||||
}): string | null {
|
||||
if (input.selectedBranch !== null) {
|
||||
return input.selectedBranch;
|
||||
}
|
||||
return input.workspaceMode === "local" ? input.currentCheckoutBranch : null;
|
||||
}
|
||||
|
||||
export function validateProjectThreadCreation(input: {
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly projectId: ProjectId;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
isProviderSendTurnSupportedImageMimeType,
|
||||
PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
|
||||
PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,
|
||||
type UploadChatImageAttachment,
|
||||
@@ -99,10 +98,6 @@ export async function pickComposerImages(input: { readonly existingCount: number
|
||||
error = `Unsupported file type for '${asset.fileName ?? "image"}'.`;
|
||||
continue;
|
||||
}
|
||||
if (!isProviderSendTurnSupportedImageMimeType(mimeType)) {
|
||||
error = `'${asset.fileName ?? "image"}' is not a supported image type. Attach GIF, JPEG, PNG, or WebP images.`;
|
||||
continue;
|
||||
}
|
||||
|
||||
const base64 = asset.base64;
|
||||
if (!base64) {
|
||||
|
||||
@@ -80,6 +80,7 @@ export const RPC_REQUIRED_SCOPES = {
|
||||
[WS_METHODS.projectsSearchContents]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsSearchEntries]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsWriteFile]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.projectsScaffold]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.shellOpenInEditor]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.filesystemBrowse]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.assetsCreateUrl]: AuthOrchestrationReadScope,
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
import { it } from "@effect/vitest";
|
||||
import { HostProcessHostname } from "@t3tools/shared/hostProcess";
|
||||
import * as NetService from "@t3tools/shared/Net";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Sink from "effect/Sink";
|
||||
import * as Stream from "effect/Stream";
|
||||
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
|
||||
import { describe, expect } from "vite-plus/test";
|
||||
|
||||
import * as RemoteOpenTargets from "./RemoteOpenTargets.ts";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const TAILSCALE_STATUS_JSON = JSON.stringify({
|
||||
Self: { DNSName: "bb-1.tail1234.ts.net.", TailscaleIPs: ["100.64.1.2"] },
|
||||
});
|
||||
|
||||
/** Spawner whose `tailscale status --json` exits with the given output. */
|
||||
const spawnerLayer = (input: { readonly exitCode: number; readonly stdout: string }) =>
|
||||
Layer.succeed(
|
||||
ChildProcessSpawner.ChildProcessSpawner,
|
||||
ChildProcessSpawner.make(() =>
|
||||
Effect.succeed(
|
||||
ChildProcessSpawner.makeHandle({
|
||||
pid: ChildProcessSpawner.ProcessId(1),
|
||||
exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(input.exitCode)),
|
||||
isRunning: Effect.succeed(false),
|
||||
kill: () => Effect.void,
|
||||
unref: Effect.succeed(Effect.void),
|
||||
stdin: Sink.drain,
|
||||
stdout: Stream.make(encoder.encode(input.stdout)),
|
||||
stderr: Stream.empty,
|
||||
all: Stream.empty,
|
||||
getInputFd: () => Sink.drain,
|
||||
getOutputFd: () => Stream.empty,
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const netLayer = (input: { readonly ipv4: boolean; readonly ipv6: boolean }) =>
|
||||
Layer.succeed(NetService.NetService, {
|
||||
canListenOnHost: () => Effect.succeed(true),
|
||||
isPortAvailableOnLoopback: () => Effect.succeed(true),
|
||||
hasListenerOnHost: (_port, host) => Effect.succeed(host === "::1" ? input.ipv6 : input.ipv4),
|
||||
reserveLoopbackPort: () => Effect.succeed(40_000),
|
||||
findAvailablePort: (preferred) => Effect.succeed(preferred),
|
||||
});
|
||||
|
||||
const resolveTargets = (input: {
|
||||
readonly sshd: { readonly ipv4: boolean; readonly ipv6: boolean };
|
||||
readonly tailscale: { readonly exitCode: number; readonly stdout: string };
|
||||
readonly hostname: string;
|
||||
}) =>
|
||||
Effect.flatMap(RemoteOpenTargets.RemoteOpenTargets, (service) => service.resolveTargets()).pipe(
|
||||
Effect.provideService(HostProcessHostname, input.hostname),
|
||||
Effect.provide(
|
||||
RemoteOpenTargets.layer.pipe(
|
||||
Layer.provide(Layer.mergeAll(netLayer(input.sshd), spawnerLayer(input.tailscale))),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const TAILSCALE_UP = { exitCode: 0, stdout: TAILSCALE_STATUS_JSON };
|
||||
const TAILSCALE_DOWN = { exitCode: 1, stdout: "" };
|
||||
|
||||
describe("RemoteOpenTargets", () => {
|
||||
it.effect("advertises nothing when no sshd accepts on either loopback", () =>
|
||||
Effect.gen(function* () {
|
||||
const targets = yield* resolveTargets({
|
||||
sshd: { ipv4: false, ipv6: false },
|
||||
tailscale: TAILSCALE_UP,
|
||||
hostname: "bb-1",
|
||||
});
|
||||
expect(targets).toEqual([]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("orders the tailnet name before the mDNS name", () =>
|
||||
Effect.gen(function* () {
|
||||
const targets = yield* resolveTargets({
|
||||
sshd: { ipv4: true, ipv6: true },
|
||||
tailscale: TAILSCALE_UP,
|
||||
hostname: "bb-1",
|
||||
});
|
||||
expect(targets).toEqual([
|
||||
{ kind: "tailscale", host: "bb-1.tail1234.ts.net" },
|
||||
{ kind: "mdns", host: "bb-1.local" },
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("accepts an sshd bound to IPv6 loopback only", () =>
|
||||
Effect.gen(function* () {
|
||||
const targets = yield* resolveTargets({
|
||||
sshd: { ipv4: false, ipv6: true },
|
||||
tailscale: TAILSCALE_DOWN,
|
||||
hostname: "bb-1",
|
||||
});
|
||||
expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("falls back to mDNS alone when tailscale is unavailable", () =>
|
||||
Effect.gen(function* () {
|
||||
const targets = yield* resolveTargets({
|
||||
sshd: { ipv4: true, ipv6: false },
|
||||
tailscale: TAILSCALE_DOWN,
|
||||
hostname: "bb-1",
|
||||
});
|
||||
expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("shortens an FQDN hostname to its first label for mDNS", () =>
|
||||
Effect.gen(function* () {
|
||||
const targets = yield* resolveTargets({
|
||||
sshd: { ipv4: true, ipv6: true },
|
||||
tailscale: TAILSCALE_DOWN,
|
||||
hostname: "bb-1.example.com",
|
||||
});
|
||||
expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* RemoteOpenTargets - resolves the SSH hostnames this environment advertises
|
||||
* for remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`).
|
||||
*
|
||||
* The server can only check itself: sshd listening locally, tailscaled
|
||||
* reporting a MagicDNS name, and the machine hostname for mDNS. Whether a
|
||||
* given name resolves from the viewer's machine is inherently client-side.
|
||||
* Targets are ordered most-reachable first (tailnet name works from anywhere
|
||||
* on the tailnet; `<hostname>.local` only on the same LAN).
|
||||
*/
|
||||
import { type RemoteOpenTarget } from "@t3tools/contracts";
|
||||
import { HostProcessHostname } from "@t3tools/shared/hostProcess";
|
||||
import * as NetService from "@t3tools/shared/Net";
|
||||
import { readTailscaleStatus } from "@t3tools/tailscale";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
|
||||
|
||||
const SSH_PORT = 22;
|
||||
|
||||
export class RemoteOpenTargets extends Context.Service<
|
||||
RemoteOpenTargets,
|
||||
{
|
||||
readonly resolveTargets: () => Effect.Effect<ReadonlyArray<RemoteOpenTarget>>;
|
||||
}
|
||||
>()("t3/environment/RemoteOpenTargets") {}
|
||||
|
||||
export const make = Effect.gen(function* () {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const net = yield* NetService.NetService;
|
||||
|
||||
const resolveTargets = Effect.gen(function* () {
|
||||
// No local sshd means no name can work; advertise nothing so clients
|
||||
// render a clear "no SSH route" state instead of links that hang.
|
||||
// Check both loopback families: sshd can be bound IPv6-only.
|
||||
const sshdListening = yield* Effect.zipWith(
|
||||
net.hasListenerOnHost(SSH_PORT, "127.0.0.1"),
|
||||
net.hasListenerOnHost(SSH_PORT, "::1"),
|
||||
(ipv4, ipv6) => ipv4 || ipv6,
|
||||
);
|
||||
if (!sshdListening) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const targets: Array<RemoteOpenTarget> = [];
|
||||
|
||||
// Tailscale absent or down is the common case, not an error.
|
||||
const magicDnsName = yield* readTailscaleStatus.pipe(
|
||||
Effect.map((status) => status.magicDnsName),
|
||||
Effect.orElseSucceed(() => null),
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
);
|
||||
if (magicDnsName !== null) {
|
||||
targets.push({ kind: "tailscale", host: magicDnsName });
|
||||
}
|
||||
|
||||
// os.hostname() may already be an FQDN (macOS often reports
|
||||
// "Name.local"); mDNS names are always `<first-label>.local`.
|
||||
const hostname = yield* HostProcessHostname;
|
||||
const shortHostname = hostname.split(".")[0]?.trim();
|
||||
if (shortHostname !== undefined && shortHostname.length > 0) {
|
||||
targets.push({ kind: "mdns", host: `${shortHostname}.local` });
|
||||
}
|
||||
|
||||
return targets;
|
||||
});
|
||||
|
||||
return RemoteOpenTargets.of({ resolveTargets: () => resolveTargets });
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(RemoteOpenTargets, make);
|
||||
@@ -42,7 +42,6 @@ import {
|
||||
} from "@t3tools/shared/git";
|
||||
import {
|
||||
getChangeRequestTerminologyForKind,
|
||||
isSshRemoteUrl,
|
||||
type ChangeRequestTerminology,
|
||||
} from "@t3tools/shared/sourceControl";
|
||||
|
||||
@@ -575,7 +574,8 @@ function toResolvedPullRequest(pr: {
|
||||
|
||||
function shouldPreferSshRemote(url: string | null): boolean {
|
||||
if (!url) return false;
|
||||
return isSshRemoteUrl(url);
|
||||
const trimmed = url.trim();
|
||||
return trimmed.startsWith("git@") || trimmed.startsWith("ssh://");
|
||||
}
|
||||
|
||||
function toPullRequestHeadRemoteInfo(pr: {
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodeHttp from "node:http";
|
||||
import * as NodeNet from "node:net";
|
||||
import { afterEach, describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { guardHttpResponseWriteErrors } from "./httpResponseErrorGuard.ts";
|
||||
|
||||
const servers: NodeHttp.Server[] = [];
|
||||
|
||||
function listen(server: NodeHttp.Server): Promise<number> {
|
||||
servers.push(server);
|
||||
return new Promise((resolve) => {
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
resolve((server.address() as NodeNet.AddressInfo).port);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchStatus(port: number, path: string): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = NodeHttp.get({ host: "127.0.0.1", port, path }, (response) => {
|
||||
response.resume();
|
||||
resolve(response.statusCode ?? 0);
|
||||
});
|
||||
request.on("error", reject);
|
||||
request.setTimeout(5_000, () => reject(new Error("request timed out")));
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const server of servers.splice(0)) {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
describe("guardHttpResponseWriteErrors", () => {
|
||||
it("contains an upgrade socket write failure instead of crashing the process", async () => {
|
||||
const writeErrors: unknown[] = [];
|
||||
const failureObserved = Promise.withResolvers<void>();
|
||||
const server = guardHttpResponseWriteErrors(NodeHttp.createServer(), (error) => {
|
||||
writeErrors.push(error);
|
||||
failureObserved.resolve();
|
||||
});
|
||||
|
||||
server.on("upgrade", (_request, socket) => {
|
||||
// Simulate the client vanishing while the auth rejection response is
|
||||
// written to the upgrade socket: the write failure surfaces as an
|
||||
// "error" event on a socket Node's http server no longer listens to.
|
||||
socket.destroy(Object.assign(new Error("write EPIPE"), { code: "EPIPE" }));
|
||||
});
|
||||
|
||||
const port = await listen(server);
|
||||
|
||||
const client = NodeNet.connect(port, "127.0.0.1", () => {
|
||||
client.write(
|
||||
[
|
||||
"GET /rpc HTTP/1.1",
|
||||
"Host: 127.0.0.1",
|
||||
"Connection: Upgrade",
|
||||
"Upgrade: websocket",
|
||||
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==",
|
||||
"Sec-WebSocket-Version: 13",
|
||||
"",
|
||||
"",
|
||||
].join("\r\n"),
|
||||
);
|
||||
});
|
||||
client.on("error", () => {});
|
||||
|
||||
await failureObserved.promise;
|
||||
client.destroy();
|
||||
|
||||
expect(writeErrors).toHaveLength(1);
|
||||
expect(writeErrors[0]).toBeInstanceOf(Error);
|
||||
expect((writeErrors[0] as NodeJS.ErrnoException).code).toBe("EPIPE");
|
||||
|
||||
// The process survived the failed write and the server keeps serving.
|
||||
server.on("request", (_request, response) => {
|
||||
response.writeHead(200, { "content-type": "text/plain" });
|
||||
response.end("ok");
|
||||
});
|
||||
await expect(fetchStatus(port, "/")).resolves.toBe(200);
|
||||
});
|
||||
|
||||
it("arms every response with an error listener without disturbing normal traffic", async () => {
|
||||
const writeErrors: unknown[] = [];
|
||||
let responseErrorListeners = -1;
|
||||
const server = guardHttpResponseWriteErrors(NodeHttp.createServer(), (error) => {
|
||||
writeErrors.push(error);
|
||||
});
|
||||
|
||||
server.on("request", (_request, response) => {
|
||||
responseErrorListeners = response.listenerCount("error");
|
||||
response.writeHead(200, { "content-type": "text/plain" });
|
||||
response.end("ok");
|
||||
});
|
||||
|
||||
const port = await listen(server);
|
||||
|
||||
await expect(fetchStatus(port, "/")).resolves.toBe(200);
|
||||
expect(responseErrorListeners).toBeGreaterThan(0);
|
||||
expect(writeErrors).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,39 +0,0 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import type * as NodeHttp from "node:http";
|
||||
|
||||
/**
|
||||
* Node surfaces late socket write failures (EPIPE, ECONNRESET,
|
||||
* ERR_STREAM_DESTROYED) as "error" events. An "error" event without a
|
||||
* listener escalates into an uncaught exception and terminates the whole
|
||||
* server process, taking every other client and all in-flight provider
|
||||
* work with it.
|
||||
*
|
||||
* Two emitters need coverage:
|
||||
*
|
||||
* - Upgrade sockets. Once a connection upgrades (the websocket RPC path,
|
||||
* including its auth rejection responses), Node's http server detaches
|
||||
* its own socket error handling, so the raw socket has no listener at
|
||||
* all until the websocket server adopts it.
|
||||
* - Server responses. Response streams have no default error listener
|
||||
* either.
|
||||
*
|
||||
* A disconnected client only affects its own request: the request fiber is
|
||||
* already interrupted through the response "close" event, so the write
|
||||
* failure needs no handling beyond being observed.
|
||||
*/
|
||||
export function guardHttpResponseWriteErrors<T extends NodeHttp.Server>(
|
||||
server: T,
|
||||
onError?: (error: unknown) => void,
|
||||
): T {
|
||||
server.on("request", (_request, response) => {
|
||||
response.on("error", (error) => {
|
||||
onError?.(error);
|
||||
});
|
||||
});
|
||||
server.on("upgrade", (_request, socket) => {
|
||||
socket.on("error", (error) => {
|
||||
onError?.(error);
|
||||
});
|
||||
});
|
||||
return server;
|
||||
}
|
||||
@@ -203,7 +203,6 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
|
||||
assert.equal(defaultsByCommand.get("projectSearch.toggle"), "mod+shift+f");
|
||||
assert.equal(defaultsByCommand.get("sidebar.toggle"), "mod+b");
|
||||
assert.equal(defaultsByCommand.get("rightPanel.toggle"), "mod+alt+b");
|
||||
assert.isFalse(defaultsByCommand.has("rightPanel.toggleMaximized"));
|
||||
assert.equal(defaultsByCommand.get("terminal.splitVertical"), "mod+shift+d");
|
||||
assert.equal(defaultsByCommand.get("modelPicker.jump.1"), "mod+1");
|
||||
assert.equal(defaultsByCommand.get("modelPicker.jump.9"), "mod+9");
|
||||
|
||||
@@ -219,11 +219,6 @@ it.effect("registers annotated tools and preserves authenticated request context
|
||||
expect(clickTool?.tool.annotations?.readOnlyHint).toBe(false);
|
||||
expect(clickTool?.tool.annotations?.destructiveHint).toBe(true);
|
||||
expect(clickTool?.tool.annotations?.openWorldHint).toBe(true);
|
||||
expect(clickTool?.tool.outputSchema).toEqual({
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
description: "The preview action completed successfully.",
|
||||
});
|
||||
|
||||
const navigateTool = server.tools.find(({ tool }) => tool.name === "preview_navigate");
|
||||
expect(navigateTool?.tool.annotations?.destructiveHint).toBe(false);
|
||||
@@ -265,24 +260,15 @@ it.effect("registers annotated tools and preserves authenticated request context
|
||||
alternateTabId,
|
||||
);
|
||||
|
||||
const actionRequests = [
|
||||
{ name: "preview_click", arguments: { x: 10, y: 10 } },
|
||||
{ name: "preview_type", arguments: { text: "Hello" } },
|
||||
{ name: "preview_press", arguments: { key: "Enter" } },
|
||||
{ name: "preview_scroll", arguments: { deltaY: 100 } },
|
||||
{ name: "preview_wait_for", arguments: { text: "Example" } },
|
||||
];
|
||||
for (const request of actionRequests) {
|
||||
const result = yield* server
|
||||
.callTool(request)
|
||||
.pipe(
|
||||
Effect.provideService(McpInvocationContext.McpInvocationContext, invocation),
|
||||
Effect.provideService(McpSchema.McpServerClient, client),
|
||||
);
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.structuredContent).toEqual({});
|
||||
expect(result.content).toEqual([{ type: "text", text: "{}" }]);
|
||||
}
|
||||
const press = yield* server
|
||||
.callTool({ name: "preview_press", arguments: { key: "Enter" } })
|
||||
.pipe(
|
||||
Effect.provideService(McpInvocationContext.McpInvocationContext, invocation),
|
||||
Effect.provideService(McpSchema.McpServerClient, client),
|
||||
);
|
||||
expect(press.isError).toBe(false);
|
||||
expect(press.structuredContent).toBeNull();
|
||||
expect(press.content).toEqual([{ type: "text", text: "null" }]);
|
||||
}),
|
||||
).pipe(Effect.provide(TestLayer)),
|
||||
);
|
||||
@@ -72,14 +72,15 @@ const handlers = {
|
||||
invokeTargeted<PreviewAutomationSetColorSchemeResult>("setColorScheme", input),
|
||||
preview_snapshot: (input) => invokeTargeted<PreviewAutomationSnapshot>("snapshot", input ?? {}),
|
||||
preview_click: (input) =>
|
||||
invokeTargeted<void>("click", input, input.timeoutMs).pipe(Effect.as({})),
|
||||
preview_type: (input) => invokeTargeted<void>("type", input, input.timeoutMs).pipe(Effect.as({})),
|
||||
preview_press: (input) => invokeTargeted<void>("press", input).pipe(Effect.as({})),
|
||||
preview_scroll: (input) => invokeTargeted<void>("scroll", input).pipe(Effect.as({})),
|
||||
invokeTargeted<void>("click", input, input.timeoutMs).pipe(Effect.as(null)),
|
||||
preview_type: (input) =>
|
||||
invokeTargeted<void>("type", input, input.timeoutMs).pipe(Effect.as(null)),
|
||||
preview_press: (input) => invokeTargeted<void>("press", input).pipe(Effect.as(null)),
|
||||
preview_scroll: (input) => invokeTargeted<void>("scroll", input).pipe(Effect.as(null)),
|
||||
preview_evaluate: (input) =>
|
||||
invokeTargeted<unknown>("evaluate", input).pipe(Effect.map((result) => result ?? null)),
|
||||
preview_wait_for: (input) =>
|
||||
invokeTargeted<void>("waitFor", input, input.timeoutMs).pipe(Effect.as({})),
|
||||
invokeTargeted<void>("waitFor", input, input.timeoutMs).pipe(Effect.as(null)),
|
||||
preview_recording_start: (input) =>
|
||||
invokeTargeted<PreviewAutomationRecordingStatus>("recordingStart", input ?? {}),
|
||||
preview_recording_stop: (input) =>
|
||||
|
||||
@@ -55,20 +55,3 @@ it("exports provider-compatible object schemas with described parameters", () =>
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("exports exact object result schemas for preview actions", () => {
|
||||
const actionNames = [
|
||||
"preview_click",
|
||||
"preview_type",
|
||||
"preview_press",
|
||||
"preview_scroll",
|
||||
"preview_wait_for",
|
||||
] as const;
|
||||
for (const name of actionNames) {
|
||||
expect(Tool.getJsonSchemaFromSchema(PreviewToolkit.tools[name].successSchema)).toEqual({
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
description: "The preview action completed successfully.",
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -29,10 +29,6 @@ const dependencies = [
|
||||
PreviewAutomationBroker.PreviewAutomationBroker,
|
||||
];
|
||||
|
||||
const PreviewActionResult = Schema.Record(Schema.String, Schema.Never).annotate({
|
||||
description: "The preview action completed successfully.",
|
||||
});
|
||||
|
||||
const browserTool = <T extends Tool.Any>(tool: T): T =>
|
||||
tool.annotate(Tool.OpenWorld, true).annotate(Tool.Destructive, true) as T;
|
||||
|
||||
@@ -121,7 +117,7 @@ export const PreviewClickTool = browserTool(
|
||||
description:
|
||||
"Click exactly one target in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; selector accepts legacy CSS; x and y must be supplied together.",
|
||||
parameters: PreviewAutomationClickInput,
|
||||
success: PreviewActionResult,
|
||||
success: Schema.Null,
|
||||
failure: PreviewAutomationError,
|
||||
dependencies,
|
||||
}).annotate(Tool.Title, "Click preview page"),
|
||||
@@ -132,7 +128,7 @@ export const PreviewTypeTool = browserTool(
|
||||
description:
|
||||
"Insert literal text into one input in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; set clear=true to replace existing text.",
|
||||
parameters: PreviewAutomationTypeInput,
|
||||
success: PreviewActionResult,
|
||||
success: Schema.Null,
|
||||
failure: PreviewAutomationError,
|
||||
dependencies,
|
||||
}).annotate(Tool.Title, "Type into preview page"),
|
||||
@@ -143,7 +139,7 @@ export const PreviewPressTool = browserTool(
|
||||
description:
|
||||
"Press one keyboard key in the tab selected by tabId, or this agent session's current tab when omitted. Examples: {key:'Enter'}, {key:'Escape'}, or {key:'a',modifiers:['Meta']}.",
|
||||
parameters: PreviewAutomationPressInput,
|
||||
success: PreviewActionResult,
|
||||
success: Schema.Null,
|
||||
failure: PreviewAutomationError,
|
||||
dependencies,
|
||||
}).annotate(Tool.Title, "Press key in preview page"),
|
||||
@@ -154,7 +150,7 @@ export const PreviewScrollTool = safeBrowserTool(
|
||||
description:
|
||||
"Scroll the tab selected by tabId, or this agent session's current tab when omitted. Positive deltaY scrolls down and positive deltaX scrolls right; a locator/selector targets a container.",
|
||||
parameters: PreviewAutomationScrollInput,
|
||||
success: PreviewActionResult,
|
||||
success: Schema.Null,
|
||||
failure: PreviewAutomationError,
|
||||
dependencies,
|
||||
}).annotate(Tool.Title, "Scroll preview page"),
|
||||
@@ -176,7 +172,7 @@ export const PreviewWaitForTool = readonlyBrowserTool(
|
||||
description:
|
||||
"Wait in the tab selected by tabId, or this agent session's current tab when omitted, until all supplied locator, selector, text, and URL conditions match.",
|
||||
parameters: PreviewAutomationWaitForInput,
|
||||
success: PreviewActionResult,
|
||||
success: Schema.Null,
|
||||
failure: PreviewAutomationError,
|
||||
dependencies,
|
||||
}).annotate(Tool.Title, "Wait for preview page condition"),
|
||||
|
||||
@@ -20,7 +20,7 @@ function activity(payload: Record<string, unknown>): OrchestrationThreadActivity
|
||||
* If slimming ever moves to an allowlist over the whole payload, these
|
||||
* assertions are the tripwire.
|
||||
*/
|
||||
describe("projectActivityPayload", () => {
|
||||
describe("projectActivityPayload agent-field survival", () => {
|
||||
it("preserves tool attribution (agentId/parentToolUseId) through data slimming", () => {
|
||||
const projected = projectActivityPayload(
|
||||
activity({
|
||||
@@ -44,98 +44,6 @@ describe("projectActivityPayload", () => {
|
||||
expect(data.somethingClientNeverReads).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps a bounded Codex command output summary", () => {
|
||||
const projected = projectActivityPayload(
|
||||
activity({
|
||||
itemType: "command_execution",
|
||||
data: {
|
||||
item: {
|
||||
command: "/bin/zsh -lc 'printf hello'",
|
||||
aggregatedOutput: `hello from codex\n${"x".repeat(5000)}`,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
const data = (projected.payload as Record<string, unknown>).data as Record<string, unknown>;
|
||||
expect(data.item).toEqual({
|
||||
command: "/bin/zsh -lc 'printf hello'",
|
||||
aggregatedOutput: "hello from codex",
|
||||
});
|
||||
expect(JSON.stringify(projected.payload).length).toBeLessThan(500);
|
||||
});
|
||||
|
||||
it("keeps bounded Claude and ACP command output summaries", () => {
|
||||
const claude = projectActivityPayload(
|
||||
activity({
|
||||
itemType: "command_execution",
|
||||
data: {
|
||||
command: "printf hello",
|
||||
rawOutput: { stdout: `hello from claude\n${"y".repeat(5000)}` },
|
||||
},
|
||||
}),
|
||||
);
|
||||
const acp = projectActivityPayload(
|
||||
activity({
|
||||
itemType: "command_execution",
|
||||
data: {
|
||||
command: "printf hello",
|
||||
content: [
|
||||
{
|
||||
type: "content",
|
||||
content: { type: "text", text: `hello from acp\n${"z".repeat(5000)}` },
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const claudeData = (claude.payload as Record<string, unknown>).data as Record<string, unknown>;
|
||||
const acpData = (acp.payload as Record<string, unknown>).data as Record<string, unknown>;
|
||||
expect(claudeData.rawOutput).toEqual({ content: "hello from claude" });
|
||||
expect(acpData.rawOutput).toEqual({ content: "hello from acp" });
|
||||
expect(JSON.stringify(claude.payload).length).toBeLessThan(500);
|
||||
expect(JSON.stringify(acp.payload).length).toBeLessThan(500);
|
||||
});
|
||||
|
||||
it("normalizes Claude and OpenCode command inputs before slimming provider data", () => {
|
||||
const claude = projectActivityPayload(
|
||||
activity({
|
||||
itemType: "command_execution",
|
||||
toolCallId: "claude-call-1",
|
||||
data: {
|
||||
toolName: "Bash",
|
||||
input: { command: "vp test run" },
|
||||
result: { content: "x".repeat(5_000) },
|
||||
},
|
||||
}),
|
||||
);
|
||||
const openCode = projectActivityPayload(
|
||||
activity({
|
||||
itemType: "command_execution",
|
||||
toolCallId: "opencode-call-1",
|
||||
data: {
|
||||
tool: "bash",
|
||||
state: {
|
||||
status: "running",
|
||||
input: { command: "vp lint" },
|
||||
output: "x".repeat(5_000),
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(claude.payload).toMatchObject({
|
||||
toolCallId: "claude-call-1",
|
||||
data: { command: "vp test run" },
|
||||
});
|
||||
expect(openCode.payload).toMatchObject({
|
||||
toolCallId: "opencode-call-1",
|
||||
data: { command: "vp lint" },
|
||||
});
|
||||
expect(JSON.stringify(claude.payload).length).toBeLessThan(200);
|
||||
expect(JSON.stringify(openCode.payload).length).toBeLessThan(200);
|
||||
});
|
||||
|
||||
it("slims Codex-shaped mcp_tool_call items to rendered fields plus a result summary", () => {
|
||||
const projected = projectActivityPayload(
|
||||
activity({
|
||||
|
||||
@@ -91,58 +91,19 @@ function projectCommandData(data: Record<string, unknown>): Record<string, unkno
|
||||
projectedItem.command = item.command;
|
||||
}
|
||||
|
||||
const aggregatedOutput = asTrimmedString(item.aggregatedOutput);
|
||||
if (aggregatedOutput) {
|
||||
const summary = summarizeToolTextOutput(aggregatedOutput);
|
||||
if (summary) {
|
||||
projectedItem.aggregatedOutput = summary;
|
||||
}
|
||||
}
|
||||
|
||||
const input = asRecord(item.input);
|
||||
if (input && "command" in input) {
|
||||
projectedItem.input = { command: input.command };
|
||||
}
|
||||
|
||||
const result = asRecord(item.result);
|
||||
if (result) {
|
||||
const projectedResult: Record<string, unknown> = {};
|
||||
if ("command" in result) {
|
||||
projectedResult.command = result.command;
|
||||
}
|
||||
const content = asTrimmedString(result.content);
|
||||
if (content) {
|
||||
const summary = summarizeToolTextOutput(content);
|
||||
if (summary) {
|
||||
projectedResult.content = summary;
|
||||
}
|
||||
}
|
||||
if (Object.keys(projectedResult).length > 0) {
|
||||
projectedItem.result = projectedResult;
|
||||
}
|
||||
if (result && "command" in result) {
|
||||
projectedItem.result = { command: result.command };
|
||||
}
|
||||
|
||||
return Object.keys(projectedItem).length > 0 ? projectedItem : undefined;
|
||||
}
|
||||
|
||||
function projectCommandValue(data: Record<string, unknown>): unknown {
|
||||
if (data.command !== undefined) {
|
||||
return data.command;
|
||||
}
|
||||
|
||||
const input = asRecord(data.input);
|
||||
if (input?.command !== undefined) {
|
||||
return input.command;
|
||||
}
|
||||
|
||||
const stateInput = asRecord(asRecord(data.state)?.input);
|
||||
if (stateInput?.command !== undefined) {
|
||||
return stateInput.command;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function summarizeToolTextOutput(value: string): string | null {
|
||||
const lines: string[] = [];
|
||||
for (const rawLine of value.split(/\r?\n/u)) {
|
||||
@@ -271,12 +232,6 @@ function projectMcpToolCallData(data: Record<string, unknown>): Record<string, u
|
||||
}
|
||||
|
||||
function projectRawOutput(value: unknown): Record<string, unknown> | undefined {
|
||||
const direct = asTrimmedString(value);
|
||||
if (direct) {
|
||||
const summary = summarizeToolTextOutput(direct);
|
||||
return summary ? { content: summary } : undefined;
|
||||
}
|
||||
|
||||
const rawOutput = asRecord(value);
|
||||
if (!rawOutput) {
|
||||
return undefined;
|
||||
@@ -301,34 +256,9 @@ function projectRawOutput(value: unknown): Record<string, unknown> | undefined {
|
||||
return summary ? { content: summary } : undefined;
|
||||
}
|
||||
|
||||
const stderr = asTrimmedString(rawOutput.stderr);
|
||||
if (stderr) {
|
||||
const summary = summarizeToolTextOutput(stderr);
|
||||
return summary ? { content: summary } : undefined;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function projectAcpContent(value: unknown): Record<string, unknown> | undefined {
|
||||
if (!Array.isArray(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const text = value
|
||||
.map((entryValue) => {
|
||||
const entry = asRecord(entryValue);
|
||||
const content = asRecord(entry?.content);
|
||||
return entry?.type === "content" && content?.type === "text"
|
||||
? asTrimmedString(content.text)
|
||||
: null;
|
||||
})
|
||||
.filter((entry): entry is string => entry !== null)
|
||||
.join("\n");
|
||||
const summary = summarizeToolTextOutput(text);
|
||||
return summary ? { content: summary } : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes activity payload fields that no current client reads while retaining
|
||||
* the full payload in persistence and the event store.
|
||||
@@ -357,9 +287,8 @@ export function projectActivityPayload(
|
||||
if (item) {
|
||||
projectedData.item = item;
|
||||
}
|
||||
const command = projectCommandValue(data);
|
||||
if (command !== undefined) {
|
||||
projectedData.command = command;
|
||||
if ("command" in data) {
|
||||
projectedData.command = data.command;
|
||||
}
|
||||
|
||||
const changedFiles: string[] = [];
|
||||
@@ -376,7 +305,7 @@ export function projectActivityPayload(
|
||||
projectedData.kind = data.kind;
|
||||
}
|
||||
|
||||
const rawOutput = projectRawOutput(data.rawOutput) ?? projectAcpContent(data.content);
|
||||
const rawOutput = projectRawOutput(data.rawOutput);
|
||||
if (rawOutput) {
|
||||
projectedData.rawOutput = rawOutput;
|
||||
}
|
||||
@@ -439,10 +368,10 @@ function dropStaleContextWindowActivities(
|
||||
/**
|
||||
* Identity both clients use to fold a tool lifecycle row into the call it
|
||||
* belongs to (`deriveToolLifecycleCollapseKey` in web's `session-logic` and
|
||||
* mobile's `threadActivity`): the runtime item id ingestion stamps as
|
||||
* `toolCallId`, a legacy `data.toolCallId`, or the itemType/title/detail triple.
|
||||
* Returns null for rows with no identity at all — those never collapse on the
|
||||
* client either, so they must not be dropped here.
|
||||
* mobile's `threadActivity`): an explicit `data.toolCallId` when the adapter
|
||||
* emits one, otherwise the itemType/title/detail triple. Returns null for rows
|
||||
* with no identity at all — those never collapse on the client either, so they
|
||||
* must not be dropped here.
|
||||
*/
|
||||
function toolLifecycleIdentity(activity: OrchestrationThreadActivity): string | null {
|
||||
const payload = asRecord(activity.payload);
|
||||
@@ -450,8 +379,7 @@ function toolLifecycleIdentity(activity: OrchestrationThreadActivity): string |
|
||||
return null;
|
||||
}
|
||||
|
||||
const toolCallId =
|
||||
asTrimmedString(payload.toolCallId) ?? asTrimmedString(asRecord(payload.data)?.toolCallId);
|
||||
const toolCallId = asTrimmedString(asRecord(payload.data)?.toolCallId);
|
||||
if (toolCallId) {
|
||||
return `id:${toolCallId}`;
|
||||
}
|
||||
|
||||
@@ -53,21 +53,6 @@ export class OrchestrationCommandPreviouslyRejectedError extends Schema.TaggedEr
|
||||
}
|
||||
}
|
||||
|
||||
export class OrchestrationCommandIdConflictError extends Schema.TaggedErrorClass<OrchestrationCommandIdConflictError>()(
|
||||
"OrchestrationCommandIdConflictError",
|
||||
{
|
||||
commandId: Schema.String,
|
||||
receiptAggregateKind: Schema.String,
|
||||
receiptAggregateId: Schema.String,
|
||||
commandAggregateKind: Schema.String,
|
||||
commandAggregateId: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Command id '${this.commandId}' already used for ${this.receiptAggregateKind} '${this.receiptAggregateId}'; refusing to replay its receipt for ${this.commandAggregateKind} '${this.commandAggregateId}'.`;
|
||||
}
|
||||
}
|
||||
|
||||
export class OrchestrationProjectorDecodeError extends Schema.TaggedErrorClass<OrchestrationProjectorDecodeError>()(
|
||||
"OrchestrationProjectorDecodeError",
|
||||
{
|
||||
@@ -97,7 +82,6 @@ export class OrchestrationListenerCallbackError extends Schema.TaggedErrorClass<
|
||||
export type OrchestrationDispatchError =
|
||||
| ProjectionRepositoryError
|
||||
| OrchestrationCommandInvariantError
|
||||
| OrchestrationCommandIdConflictError
|
||||
| OrchestrationCommandPreviouslyRejectedError
|
||||
| OrchestrationProjectorDecodeError
|
||||
| OrchestrationListenerCallbackError;
|
||||
|
||||
@@ -1230,153 +1230,4 @@ describe("OrchestrationEngine", () => {
|
||||
|
||||
await system.dispose();
|
||||
});
|
||||
|
||||
it("replays the accepted receipt for a genuine retry of the same command", async () => {
|
||||
const createdAt = now();
|
||||
const system = await createOrchestrationSystem();
|
||||
const { engine } = system;
|
||||
|
||||
await system.run(
|
||||
engine.dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.make("cmd-retry-project-create"),
|
||||
projectId: asProjectId("project-retry"),
|
||||
title: "Retry Project",
|
||||
workspaceRoot: "/tmp/project-retry",
|
||||
defaultModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
await system.run(
|
||||
engine.dispatch({
|
||||
type: "thread.create",
|
||||
commandId: CommandId.make("cmd-retry-thread-create"),
|
||||
threadId: ThreadId.make("thread-retry"),
|
||||
projectId: asProjectId("project-retry"),
|
||||
title: "retry",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
const turnStart = {
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-retry-turn-start"),
|
||||
threadId: ThreadId.make("thread-retry"),
|
||||
message: {
|
||||
messageId: asMessageId("msg-retry"),
|
||||
role: "user",
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt,
|
||||
} as const;
|
||||
|
||||
const first = await system.run(engine.dispatch(turnStart));
|
||||
const second = await system.run(engine.dispatch(turnStart));
|
||||
expect(second.sequence).toBe(first.sequence);
|
||||
|
||||
const readModel = await system.readModel();
|
||||
const thread = readModel.threads.find((candidate) => candidate.id === "thread-retry");
|
||||
expect(thread?.messages.filter((message) => message.role === "user")).toHaveLength(1);
|
||||
|
||||
await system.dispose();
|
||||
});
|
||||
|
||||
it("rejects reusing an accepted command id for a different aggregate", async () => {
|
||||
const createdAt = now();
|
||||
const system = await createOrchestrationSystem();
|
||||
const { engine } = system;
|
||||
|
||||
await system.run(
|
||||
engine.dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.make("cmd-conflict-project-create"),
|
||||
projectId: asProjectId("project-conflict"),
|
||||
title: "Conflict Project",
|
||||
workspaceRoot: "/tmp/project-conflict",
|
||||
defaultModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
for (const threadId of ["thread-conflict-a", "thread-conflict-b"]) {
|
||||
await system.run(
|
||||
engine.dispatch({
|
||||
type: "thread.create",
|
||||
commandId: CommandId.make(`cmd-${threadId}-create`),
|
||||
threadId: ThreadId.make(threadId),
|
||||
projectId: asProjectId("project-conflict"),
|
||||
title: threadId,
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
await system.run(
|
||||
engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-conflict-turn-start"),
|
||||
threadId: ThreadId.make("thread-conflict-a"),
|
||||
message: {
|
||||
messageId: asMessageId("msg-conflict-a"),
|
||||
role: "user",
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(
|
||||
system.run(
|
||||
engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-conflict-turn-start"),
|
||||
threadId: ThreadId.make("thread-conflict-b"),
|
||||
message: {
|
||||
messageId: asMessageId("msg-conflict-b"),
|
||||
role: "user",
|
||||
text: "hello again",
|
||||
attachments: [],
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt,
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow("already used for thread 'thread-conflict-a'");
|
||||
|
||||
const readModel = await system.readModel();
|
||||
const targetThread = readModel.threads.find(
|
||||
(candidate) => candidate.id === "thread-conflict-b",
|
||||
);
|
||||
expect(targetThread?.messages.filter((message) => message.role === "user")).toHaveLength(0);
|
||||
|
||||
await system.dispose();
|
||||
});
|
||||
});
|
||||
@@ -32,7 +32,6 @@ import { toPersistenceSqlError } from "../../persistence/Errors.ts";
|
||||
import { OrchestrationEventStore } from "../../persistence/Services/OrchestrationEventStore.ts";
|
||||
import { OrchestrationCommandReceiptRepository } from "../../persistence/Services/OrchestrationCommandReceipts.ts";
|
||||
import {
|
||||
OrchestrationCommandIdConflictError,
|
||||
OrchestrationCommandInvariantError,
|
||||
OrchestrationCommandPreviouslyRejectedError,
|
||||
type OrchestrationDispatchError,
|
||||
@@ -49,7 +48,6 @@ import {
|
||||
const isOrchestrationCommandPreviouslyRejectedError = Schema.is(
|
||||
OrchestrationCommandPreviouslyRejectedError,
|
||||
);
|
||||
const isOrchestrationCommandIdConflictError = Schema.is(OrchestrationCommandIdConflictError);
|
||||
const isOrchestrationCommandInvariantError = Schema.is(OrchestrationCommandInvariantError);
|
||||
|
||||
interface CommandEnvelope {
|
||||
@@ -141,21 +139,6 @@ const makeOrchestrationEngine = Effect.gen(function* () {
|
||||
commandId: envelope.command.commandId,
|
||||
});
|
||||
if (Option.isSome(existingReceipt)) {
|
||||
// A receipt only proves this exact command was handled. Replaying it
|
||||
// for a command aimed at another aggregate would report success for
|
||||
// work that never happened.
|
||||
if (
|
||||
existingReceipt.value.aggregateKind !== aggregateRef.aggregateKind ||
|
||||
existingReceipt.value.aggregateId !== aggregateRef.aggregateId
|
||||
) {
|
||||
return yield* new OrchestrationCommandIdConflictError({
|
||||
commandId: envelope.command.commandId,
|
||||
receiptAggregateKind: existingReceipt.value.aggregateKind,
|
||||
receiptAggregateId: existingReceipt.value.aggregateId,
|
||||
commandAggregateKind: aggregateRef.aggregateKind,
|
||||
commandAggregateId: aggregateRef.aggregateId,
|
||||
});
|
||||
}
|
||||
if (existingReceipt.value.status === "accepted") {
|
||||
return {
|
||||
sequence: existingReceipt.value.resultSequence,
|
||||
@@ -279,10 +262,7 @@ const makeOrchestrationEngine = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
const error = Cause.squash(exit.cause) as OrchestrationDispatchError;
|
||||
if (
|
||||
!isOrchestrationCommandPreviouslyRejectedError(error) &&
|
||||
!isOrchestrationCommandIdConflictError(error)
|
||||
) {
|
||||
if (!isOrchestrationCommandPreviouslyRejectedError(error)) {
|
||||
yield* reconcileReadModelAfterDispatchFailure.pipe(
|
||||
Effect.catch(() =>
|
||||
Effect.logWarning(
|
||||
|
||||
@@ -2281,130 +2281,6 @@ projectionSnapshotLayer("ProjectionSnapshotQuery windowed thread detail", (it) =
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("bounds activity hydration and preserves unresolved requests", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedFanOutThread();
|
||||
const snapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`DELETE FROM projection_thread_activities`;
|
||||
yield* sql`
|
||||
WITH RECURSIVE activity_rows(sequence) AS (
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
SELECT sequence + 1 FROM activity_rows WHERE sequence < 501
|
||||
)
|
||||
INSERT INTO projection_thread_activities (
|
||||
activity_id, thread_id, turn_id, tone, kind, summary, payload_json, sequence, created_at
|
||||
)
|
||||
SELECT
|
||||
printf('activity-%04d', sequence),
|
||||
'thread-w',
|
||||
'turn-5',
|
||||
'tool',
|
||||
'tool.completed',
|
||||
'ran tool',
|
||||
printf('{"sequence":%d}', sequence),
|
||||
sequence,
|
||||
'2026-03-01T00:04:00.000Z'
|
||||
FROM activity_rows
|
||||
`;
|
||||
|
||||
const fullDetail = yield* snapshotQuery.getThreadDetailById(threadW);
|
||||
assert.equal(fullDetail._tag, "Some");
|
||||
if (fullDetail._tag === "Some") {
|
||||
assert.equal(fullDetail.value.activities.length, 500);
|
||||
assert.equal(fullDetail.value.activities[0]?.id, asEventId("activity-0002"));
|
||||
assert.equal(fullDetail.value.activities.at(-1)?.id, asEventId("activity-0501"));
|
||||
}
|
||||
|
||||
const windowedDetail = yield* snapshotQuery.getThreadDetailSnapshot(threadW, {
|
||||
turnLimit: 2,
|
||||
});
|
||||
assert.equal(windowedDetail._tag, "Some");
|
||||
if (windowedDetail._tag === "Some") {
|
||||
assert.equal(windowedDetail.value.thread.activities.length, 500);
|
||||
assert.equal(windowedDetail.value.thread.activities[0]?.id, asEventId("activity-0002"));
|
||||
assert.equal(windowedDetail.value.thread.activities.at(-1)?.id, asEventId("activity-0501"));
|
||||
}
|
||||
|
||||
yield* sql`
|
||||
INSERT INTO projection_thread_activities (
|
||||
activity_id, thread_id, turn_id, tone, kind, summary, payload_json, sequence, created_at
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'approval-old', 'thread-w', NULL, 'approval', 'approval.requested',
|
||||
'Approve old command', '{"requestId":"approval-1"}', NULL,
|
||||
'2026-03-01T00:00:01.000Z'
|
||||
),
|
||||
(
|
||||
'user-input-old', 'thread-w', NULL, 'approval', 'user-input.requested',
|
||||
'Answer old question', '{"requestId":"input-1"}', NULL,
|
||||
'2026-03-01T00:00:02.000Z'
|
||||
),
|
||||
(
|
||||
'user-input-closed', 'thread-w', NULL, 'approval', 'user-input.requested',
|
||||
'Closed question', '{"requestId":"input-closed"}', NULL,
|
||||
'2026-03-01T00:00:03.000Z'
|
||||
),
|
||||
(
|
||||
'user-input-closed-resolution', 'thread-w', NULL, 'info', 'user-input.resolved',
|
||||
'Closed question', '{"requestId":"input-closed"}', NULL,
|
||||
'2026-03-01T00:00:04.000Z'
|
||||
),
|
||||
(
|
||||
'user-input-tied-z-request', 'thread-w', NULL, 'approval', 'user-input.requested',
|
||||
'Tied open question', '{"requestId":"input-tied-open"}', NULL,
|
||||
'2026-03-01T00:00:05.000Z'
|
||||
),
|
||||
(
|
||||
'user-input-tied-a-resolution', 'thread-w', NULL, 'info', 'user-input.resolved',
|
||||
'Tied open question', '{"requestId":"input-tied-open"}', NULL,
|
||||
'2026-03-01T00:00:05.000Z'
|
||||
)
|
||||
`;
|
||||
yield* sql`
|
||||
INSERT INTO projection_pending_approvals (
|
||||
request_id, thread_id, turn_id, status, decision, created_at, resolved_at
|
||||
)
|
||||
VALUES (
|
||||
'approval-1', 'thread-w', NULL, 'pending', NULL,
|
||||
'2026-03-01T00:00:01.000Z', NULL
|
||||
)
|
||||
`;
|
||||
yield* sql`
|
||||
UPDATE projection_threads
|
||||
SET pending_approval_count = 1, pending_user_input_count = 1
|
||||
WHERE thread_id = 'thread-w'
|
||||
`;
|
||||
|
||||
const detailWithPinnedRequests = yield* snapshotQuery.getThreadDetailById(threadW);
|
||||
assert.equal(detailWithPinnedRequests._tag, "Some");
|
||||
if (detailWithPinnedRequests._tag === "Some") {
|
||||
const ids = detailWithPinnedRequests.value.activities.map((activity) => activity.id);
|
||||
assert.equal(detailWithPinnedRequests.value.activities.length, 503);
|
||||
assert.equal(ids.includes(asEventId("approval-old")), true);
|
||||
assert.equal(ids.includes(asEventId("user-input-old")), true);
|
||||
assert.equal(ids.includes(asEventId("user-input-closed")), false);
|
||||
assert.equal(ids.includes(asEventId("user-input-tied-z-request")), true);
|
||||
}
|
||||
|
||||
const windowWithPinnedRequests = yield* snapshotQuery.getThreadDetailSnapshot(threadW, {
|
||||
turnLimit: 2,
|
||||
});
|
||||
assert.equal(windowWithPinnedRequests._tag, "Some");
|
||||
if (windowWithPinnedRequests._tag === "Some") {
|
||||
const ids = windowWithPinnedRequests.value.thread.activities.map((activity) => activity.id);
|
||||
assert.equal(windowWithPinnedRequests.value.thread.activities.length, 503);
|
||||
assert.equal(ids.includes(asEventId("approval-old")), true);
|
||||
assert.equal(ids.includes(asEventId("user-input-old")), true);
|
||||
assert.equal(ids.includes(asEventId("user-input-closed")), false);
|
||||
assert.equal(ids.includes(asEventId("user-input-tied-z-request")), true);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("a thread with no turns returns its content unwindowed on the first page", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
@@ -69,10 +69,6 @@ import {
|
||||
const decodeReadModel = Schema.decodeUnknownEffect(OrchestrationReadModel);
|
||||
const decodeShellSnapshot = Schema.decodeUnknownEffect(OrchestrationShellSnapshot);
|
||||
const decodeThread = Schema.decodeUnknownEffect(OrchestrationThread);
|
||||
// Keep detail reads consistent with the in-memory projector's retained
|
||||
// activity window. Applying the limit in SQL avoids decoding an unbounded
|
||||
// payload_json set before the projector can enforce that invariant.
|
||||
const THREAD_DETAIL_ACTIVITY_LIMIT = 500;
|
||||
const ProjectionProjectDbRowSchema = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
@@ -1019,25 +1015,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
payload_json AS "payload",
|
||||
sequence,
|
||||
created_at AS "createdAt"
|
||||
FROM (
|
||||
SELECT
|
||||
activity_id,
|
||||
thread_id,
|
||||
turn_id,
|
||||
tone,
|
||||
kind,
|
||||
summary,
|
||||
payload_json,
|
||||
sequence,
|
||||
created_at
|
||||
FROM projection_thread_activities
|
||||
WHERE thread_id = ${threadId}
|
||||
ORDER BY
|
||||
sequence DESC,
|
||||
created_at DESC,
|
||||
activity_id DESC
|
||||
LIMIT ${THREAD_DETAIL_ACTIVITY_LIMIT}
|
||||
) AS recent_activities
|
||||
FROM projection_thread_activities
|
||||
WHERE thread_id = ${threadId}
|
||||
ORDER BY
|
||||
sequence ASC,
|
||||
created_at ASC,
|
||||
@@ -1253,95 +1232,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
`,
|
||||
});
|
||||
|
||||
// Blocking request payloads must remain available even if they predate the
|
||||
// recent activity window. Each CTE returns at most one unresolved row per
|
||||
// request, so the merge below stays bounded by actionable work.
|
||||
const listPinnedThreadActivityRowsByThread = SqlSchema.findAll({
|
||||
Request: ThreadIdLookupInput,
|
||||
Result: ProjectionThreadActivityDbRowSchema,
|
||||
execute: ({ threadId }) =>
|
||||
sql`
|
||||
WITH pending_approval_requests AS (
|
||||
SELECT request_id, thread_id
|
||||
FROM projection_pending_approvals
|
||||
WHERE thread_id = ${threadId}
|
||||
AND status = 'pending'
|
||||
),
|
||||
pending_approval_activities AS (
|
||||
SELECT
|
||||
activity.activity_id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY pending.request_id
|
||||
ORDER BY activity.created_at DESC, activity.activity_id DESC
|
||||
) AS request_order
|
||||
FROM pending_approval_requests AS pending
|
||||
CROSS JOIN projection_thread_activities AS activity
|
||||
WHERE activity.thread_id = pending.thread_id
|
||||
AND activity.kind = 'approval.requested'
|
||||
AND json_extract(activity.payload_json, '$.requestId') = pending.request_id
|
||||
),
|
||||
pending_user_input_thread AS (
|
||||
SELECT thread_id
|
||||
FROM projection_threads
|
||||
WHERE thread_id = ${threadId}
|
||||
AND pending_user_input_count > 0
|
||||
),
|
||||
user_input_lifecycle AS (
|
||||
SELECT
|
||||
activity.activity_id,
|
||||
activity.kind,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY json_extract(activity.payload_json, '$.requestId')
|
||||
ORDER BY activity.created_at DESC, activity.activity_id DESC
|
||||
) AS request_order
|
||||
FROM pending_user_input_thread AS pending
|
||||
CROSS JOIN projection_thread_activities AS activity
|
||||
WHERE activity.thread_id = pending.thread_id
|
||||
AND (
|
||||
activity.kind IN ('user-input.requested', 'user-input.resolved')
|
||||
OR (
|
||||
activity.kind = 'provider.user-input.respond.failed'
|
||||
AND (
|
||||
lower(COALESCE(json_extract(activity.payload_json, '$.detail'), ''))
|
||||
LIKE '%stale pending user-input request%'
|
||||
OR lower(COALESCE(json_extract(activity.payload_json, '$.detail'), ''))
|
||||
LIKE '%unknown pending user-input request%'
|
||||
OR lower(COALESCE(json_extract(activity.payload_json, '$.detail'), ''))
|
||||
LIKE '%unknown pending user input request%'
|
||||
OR lower(COALESCE(json_extract(activity.payload_json, '$.detail'), ''))
|
||||
LIKE '%unknown pending codex user input request%'
|
||||
)
|
||||
)
|
||||
)
|
||||
AND json_extract(activity.payload_json, '$.requestId') IS NOT NULL
|
||||
),
|
||||
pinned_activity_ids AS (
|
||||
SELECT activity_id
|
||||
FROM pending_approval_activities
|
||||
WHERE request_order = 1
|
||||
UNION ALL
|
||||
SELECT activity_id
|
||||
FROM user_input_lifecycle
|
||||
WHERE request_order = 1
|
||||
AND kind = 'user-input.requested'
|
||||
)
|
||||
SELECT
|
||||
activity.activity_id AS "activityId",
|
||||
activity.thread_id AS "threadId",
|
||||
activity.turn_id AS "turnId",
|
||||
activity.tone,
|
||||
activity.kind,
|
||||
activity.summary,
|
||||
activity.payload_json AS "payload",
|
||||
activity.sequence,
|
||||
activity.created_at AS "createdAt"
|
||||
FROM pinned_activity_ids AS pinned
|
||||
INNER JOIN projection_thread_activities AS activity
|
||||
ON activity.activity_id = pinned.activity_id
|
||||
ORDER BY activity.created_at ASC, activity.activity_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
const listThreadActivityRowsByThreadWindow = SqlSchema.findAll({
|
||||
Request: ThreadTurnRangeLookupInput,
|
||||
Result: ProjectionThreadActivityDbRowSchema,
|
||||
@@ -1357,51 +1247,34 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
payload_json AS "payload",
|
||||
sequence,
|
||||
created_at AS "createdAt"
|
||||
FROM (
|
||||
SELECT
|
||||
activity_id,
|
||||
thread_id,
|
||||
turn_id,
|
||||
tone,
|
||||
kind,
|
||||
summary,
|
||||
payload_json,
|
||||
sequence,
|
||||
created_at
|
||||
FROM projection_thread_activities
|
||||
WHERE thread_id = ${threadId}
|
||||
AND (
|
||||
turn_id IN (
|
||||
SELECT turn_id FROM projection_turns
|
||||
WHERE thread_id = ${threadId}
|
||||
AND turn_id IS NOT NULL
|
||||
AND (
|
||||
requested_at > ${minAnchorAt}
|
||||
OR (
|
||||
requested_at = ${minAnchorAt}
|
||||
AND turn_id >= ${minTurnKey}
|
||||
)
|
||||
FROM projection_thread_activities
|
||||
WHERE thread_id = ${threadId}
|
||||
AND (
|
||||
turn_id IN (
|
||||
SELECT turn_id FROM projection_turns
|
||||
WHERE thread_id = ${threadId}
|
||||
AND turn_id IS NOT NULL
|
||||
AND (
|
||||
requested_at > ${minAnchorAt}
|
||||
OR (
|
||||
requested_at = ${minAnchorAt}
|
||||
AND turn_id >= ${minTurnKey}
|
||||
)
|
||||
AND (
|
||||
requested_at < ${beforeAnchorAt}
|
||||
OR (
|
||||
requested_at = ${beforeAnchorAt}
|
||||
AND turn_id < ${beforeTurnKey}
|
||||
)
|
||||
)
|
||||
AND (
|
||||
requested_at < ${beforeAnchorAt}
|
||||
OR (
|
||||
requested_at = ${beforeAnchorAt}
|
||||
AND turn_id < ${beforeTurnKey}
|
||||
)
|
||||
)
|
||||
OR (
|
||||
turn_id IS NULL
|
||||
AND created_at >= ${minAnchorAt}
|
||||
AND created_at < ${beforeAnchorAt}
|
||||
)
|
||||
)
|
||||
)
|
||||
ORDER BY
|
||||
sequence DESC,
|
||||
created_at DESC,
|
||||
activity_id DESC
|
||||
LIMIT ${THREAD_DETAIL_ACTIVITY_LIMIT}
|
||||
) AS recent_activities
|
||||
OR (
|
||||
turn_id IS NULL
|
||||
AND created_at >= ${minAnchorAt}
|
||||
AND created_at < ${beforeAnchorAt}
|
||||
)
|
||||
)
|
||||
ORDER BY
|
||||
sequence ASC,
|
||||
created_at ASC,
|
||||
@@ -2501,7 +2374,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
messageRows,
|
||||
proposedPlanRows,
|
||||
activityRows,
|
||||
pinnedActivityRows,
|
||||
checkpointRows,
|
||||
latestTurnRow,
|
||||
sessionRow,
|
||||
@@ -2544,14 +2416,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
),
|
||||
),
|
||||
),
|
||||
listPinnedThreadActivityRowsByThread({ threadId }).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlOrDecodeError(
|
||||
"ProjectionSnapshotQuery.getThreadDetailById:listPinnedActivities:query",
|
||||
"ProjectionSnapshotQuery.getThreadDetailById:listPinnedActivities:decodeRows",
|
||||
),
|
||||
),
|
||||
),
|
||||
listCheckpointRowsByThread({ threadId }).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlOrDecodeError(
|
||||
@@ -2582,17 +2446,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
return Option.none<OrchestrationThread>();
|
||||
}
|
||||
|
||||
const selectedActivityRows = [
|
||||
...new Map(
|
||||
[...activityRows, ...pinnedActivityRows].map((row) => [row.activityId, row] as const),
|
||||
).values(),
|
||||
].toSorted(
|
||||
(left, right) =>
|
||||
(left.sequence ?? -1) - (right.sequence ?? -1) ||
|
||||
left.createdAt.localeCompare(right.createdAt) ||
|
||||
left.activityId.localeCompare(right.activityId),
|
||||
);
|
||||
|
||||
const thread = {
|
||||
id: threadRow.value.threadId,
|
||||
projectId: threadRow.value.projectId,
|
||||
@@ -2630,7 +2483,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
return message;
|
||||
}),
|
||||
proposedPlans: proposedPlanRows.map(mapProposedPlanRow),
|
||||
activities: selectedActivityRows.map((row) => {
|
||||
activities: activityRows.map((row) => {
|
||||
const activity = {
|
||||
id: row.activityId,
|
||||
tone: row.tone,
|
||||
|
||||
@@ -39,7 +39,6 @@ import {
|
||||
type ProviderCommandReactorShape,
|
||||
} from "../Services/ProviderCommandReactor.ts";
|
||||
import { forkParked, ServerActivation } from "../../serverActivation.ts";
|
||||
import { canReplaceThreadTitle, DEFAULT_THREAD_TITLE } from "../threadTitles.ts";
|
||||
import {
|
||||
resolveSourceControlWriterModelSelection,
|
||||
ServerSettingsService,
|
||||
@@ -92,6 +91,7 @@ const turnStartKeyForEvent = (event: ProviderIntentEvent): string =>
|
||||
const HANDLED_TURN_START_KEY_MAX = 10_000;
|
||||
const HANDLED_TURN_START_KEY_TTL = Duration.minutes(30);
|
||||
const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
|
||||
const DEFAULT_THREAD_TITLE = "New thread";
|
||||
const MAX_REGENERATION_ATTACHMENTS = 4;
|
||||
const MAX_THREAD_TITLE_CONTEXT_CHARS = 8_000;
|
||||
const MAX_FIRST_USER_TITLE_CONTEXT_CHARS = 2_000;
|
||||
@@ -227,6 +227,18 @@ export function providerErrorLabelFromInstanceHint(input: {
|
||||
);
|
||||
}
|
||||
|
||||
function canReplaceThreadTitle(currentTitle: string, titleSeed?: string): boolean {
|
||||
const trimmedCurrentTitle = currentTitle.trim();
|
||||
if (trimmedCurrentTitle === DEFAULT_THREAD_TITLE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const trimmedTitleSeed = titleSeed?.trim();
|
||||
return trimmedTitleSeed !== undefined && trimmedTitleSeed.length > 0
|
||||
? trimmedCurrentTitle === trimmedTitleSeed
|
||||
: false;
|
||||
}
|
||||
|
||||
function findProviderAdapterRequestError(
|
||||
cause: Cause.Cause<ProviderServiceError>,
|
||||
): ProviderAdapterRequestError | undefined {
|
||||
@@ -614,7 +626,6 @@ const make = Effect.gen(function* () {
|
||||
...(preferredProvider ? { provider: preferredProvider } : {}),
|
||||
providerInstanceId: desiredInstanceId,
|
||||
...(effectiveCwd ? { cwd: effectiveCwd } : {}),
|
||||
...(thread.title ? { title: thread.title } : {}),
|
||||
modelSelection: desiredModelSelection,
|
||||
...(input?.resumeCursor !== undefined ? { resumeCursor: input.resumeCursor } : {}),
|
||||
runtimeMode: desiredRuntimeMode,
|
||||
|
||||
@@ -82,63 +82,3 @@ describe("runtimeEventToActivities task progress", () => {
|
||||
expect(usagePayload).not.toHaveProperty("status");
|
||||
});
|
||||
});
|
||||
describe("runtimeEventToActivities tool streaming persistence", () => {
|
||||
const accumulatedStdout = [
|
||||
"first line of output",
|
||||
...Array.from({ length: 500 }, (_, index) => `Capturing frame ${index}/9028`),
|
||||
].join("\n");
|
||||
const streamingData = {
|
||||
toolCallId: "tool-call-1",
|
||||
kind: "execute",
|
||||
command: "blender --render",
|
||||
rawOutput: { stdout: accumulatedStdout },
|
||||
content: [{ type: "content", content: { type: "text", text: accumulatedStdout } }],
|
||||
};
|
||||
|
||||
it("persists tool.updated with the wire projection of data, not the accumulated stream", () => {
|
||||
const event = {
|
||||
...base,
|
||||
type: "item.updated",
|
||||
eventId: EventId.make("evt-tool-streaming-updated"),
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
status: "inProgress",
|
||||
title: "Render",
|
||||
detail: accumulatedStdout,
|
||||
data: streamingData,
|
||||
},
|
||||
} satisfies ProviderRuntimeEvent;
|
||||
|
||||
const activities = runtimeEventToActivities(event);
|
||||
|
||||
expect(activities).toHaveLength(1);
|
||||
const payload = activities[0]?.payload as Record<string, unknown>;
|
||||
const data = payload.data as Record<string, unknown>;
|
||||
expect(payload.status).toBe("inProgress");
|
||||
expect(data.toolCallId).toBe("tool-call-1");
|
||||
expect(data.command).toBe("blender --render");
|
||||
expect(data.rawOutput).toEqual({ content: "first line of output" });
|
||||
expect(data.content).toBeUndefined();
|
||||
expect(JSON.stringify(data).length).toBeLessThan(1_000);
|
||||
});
|
||||
|
||||
it("persists the full terminal payload on tool.completed", () => {
|
||||
const event = {
|
||||
...base,
|
||||
type: "item.completed",
|
||||
eventId: EventId.make("evt-tool-streaming-completed"),
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
status: "completed",
|
||||
title: "Render",
|
||||
data: streamingData,
|
||||
},
|
||||
} satisfies ProviderRuntimeEvent;
|
||||
|
||||
const activities = runtimeEventToActivities(event);
|
||||
|
||||
expect(activities).toHaveLength(1);
|
||||
const payload = activities[0]?.payload as Record<string, unknown>;
|
||||
expect(payload.data).toEqual(streamingData);
|
||||
});
|
||||
});
|
||||
@@ -48,7 +48,6 @@ import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQu
|
||||
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
|
||||
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
|
||||
import { ProviderRuntimeIngestionLive } from "./ProviderRuntimeIngestion.ts";
|
||||
import { DEFAULT_THREAD_TITLE } from "../threadTitles.ts";
|
||||
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
|
||||
import { ProviderRuntimeIngestionService } from "../Services/ProviderRuntimeIngestion.ts";
|
||||
import { ProjectionSnapshotQuery } from "../Services/ProjectionSnapshotQuery.ts";
|
||||
@@ -222,10 +221,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
}
|
||||
});
|
||||
|
||||
async function createHarness(options?: {
|
||||
serverSettings?: Partial<ServerSettings>;
|
||||
threadTitle?: string;
|
||||
}) {
|
||||
async function createHarness(options?: { serverSettings?: Partial<ServerSettings> }) {
|
||||
const workspaceRoot = makeTempDir("t3-provider-project-");
|
||||
NodeFS.mkdirSync(NodePath.join(workspaceRoot, ".git"));
|
||||
const provider = createProviderServiceHarness();
|
||||
@@ -281,7 +277,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
commandId: CommandId.make("cmd-thread-create"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: options?.threadTitle ?? "Thread",
|
||||
title: "Thread",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
@@ -2815,16 +2811,11 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
createdAt: now,
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-9"),
|
||||
itemId: asItemId("tool-call-9"),
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
status: "inProgress",
|
||||
title: "Command run",
|
||||
detail: "Bash: vp test run",
|
||||
data: {
|
||||
toolName: "Bash",
|
||||
input: { command: "vp test run" },
|
||||
},
|
||||
status: "in_progress",
|
||||
title: "Read file",
|
||||
detail: "/tmp/file.ts",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2839,20 +2830,11 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
);
|
||||
|
||||
expect(thread.session?.status).toBe("ready");
|
||||
const activity = thread.activities.find(
|
||||
(entry: ProviderRuntimeTestActivity) => entry.kind === "tool.started",
|
||||
);
|
||||
const payload = activity?.payload as Record<string, unknown> | undefined;
|
||||
expect(payload).toMatchObject({
|
||||
itemType: "command_execution",
|
||||
toolCallId: "tool-call-9",
|
||||
status: "inProgress",
|
||||
detail: "Bash: vp test run",
|
||||
data: {
|
||||
toolName: "Bash",
|
||||
input: { command: "vp test run" },
|
||||
},
|
||||
});
|
||||
expect(
|
||||
thread.activities.some(
|
||||
(activity: ProviderRuntimeTestActivity) => activity.kind === "tool.started",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("consumes P1 runtime events into thread metadata, diff checkpoints, and activities", async () => {
|
||||
@@ -2933,7 +2915,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
const thread = await waitForThread(
|
||||
harness.readModel,
|
||||
(entry) =>
|
||||
entry.title === "Thread" &&
|
||||
entry.title === "Renamed by provider" &&
|
||||
entry.activities.some(
|
||||
(activity: ProviderRuntimeTestActivity) => activity.kind === "turn.plan.updated",
|
||||
) &&
|
||||
@@ -2948,7 +2930,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
),
|
||||
);
|
||||
|
||||
expect(thread.title).toBe("Thread");
|
||||
expect(thread.title).toBe("Renamed by provider");
|
||||
|
||||
const planActivity = thread.activities.find(
|
||||
(activity: ProviderRuntimeTestActivity) => activity.id === "evt-turn-plan-updated",
|
||||
@@ -2970,8 +2952,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
expect(toolUpdate?.kind).toBe("tool.updated");
|
||||
expect(toolUpdatePayload?.itemType).toBe("command_execution");
|
||||
expect(toolUpdatePayload?.status).toBe("in_progress");
|
||||
expect(toolUpdatePayload?.toolCallId).toBe("item-p1-tool");
|
||||
expect(toolUpdatePayload?.data).toMatchObject({ toolCallId: "item-p1-tool" });
|
||||
|
||||
const warning = thread.activities.find(
|
||||
(activity: ProviderRuntimeTestActivity) => activity.id === "evt-runtime-warning",
|
||||
@@ -2991,51 +2971,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
expect(checkpoint?.checkpointRef).toBe("provider-diff:evt-turn-diff-updated");
|
||||
});
|
||||
|
||||
it("mirrors a provider title only while the thread still has the default title", async () => {
|
||||
const harness = await createHarness({ threadTitle: DEFAULT_THREAD_TITLE });
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
|
||||
harness.emit({
|
||||
type: "thread.metadata.updated",
|
||||
eventId: asEventId("evt-thread-metadata-default"),
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
createdAt: now,
|
||||
threadId: asThreadId("thread-1"),
|
||||
payload: {
|
||||
name: "Renamed by provider",
|
||||
metadata: { source: "provider" },
|
||||
},
|
||||
});
|
||||
|
||||
const thread = await waitForThread(
|
||||
harness.readModel,
|
||||
(entry) => entry.title === "Renamed by provider",
|
||||
);
|
||||
expect(thread.title).toBe("Renamed by provider");
|
||||
});
|
||||
|
||||
it("rejects a provider title once the thread has a real title", async () => {
|
||||
const harness = await createHarness({ threadTitle: "User-set title" });
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
|
||||
harness.emit({
|
||||
type: "thread.metadata.updated",
|
||||
eventId: asEventId("evt-thread-metadata-real"),
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
createdAt: now,
|
||||
threadId: asThreadId("thread-1"),
|
||||
payload: {
|
||||
name: "Renamed by provider",
|
||||
metadata: { source: "provider" },
|
||||
},
|
||||
});
|
||||
|
||||
await harness.drain();
|
||||
const readModel = await harness.readModel();
|
||||
const thread = readModel.threads.find((entry) => entry.id === ThreadId.make("thread-1"));
|
||||
expect(thread?.title).toBe("User-set title");
|
||||
});
|
||||
|
||||
it("projects context window updates into normalized thread activities", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
|
||||
@@ -41,10 +41,8 @@ import {
|
||||
ProviderRuntimeIngestionService,
|
||||
type ProviderRuntimeIngestionShape,
|
||||
} from "../Services/ProviderRuntimeIngestion.ts";
|
||||
import { projectActivityPayload } from "../ActivityPayloadProjection.ts";
|
||||
import { forkParked } from "../../serverActivation.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { canReplaceThreadTitle } from "../threadTitles.ts";
|
||||
|
||||
const providerTurnKey = (threadId: ThreadId, turnId: TurnId) => `${threadId}:${turnId}`;
|
||||
const providerTaskKey = (threadId: ThreadId, taskId: string) => `${threadId}:${taskId}`;
|
||||
@@ -211,17 +209,6 @@ function truncateDetail(value: string, limit = 180): string {
|
||||
return value.length > limit ? `${value.slice(0, limit - 3)}...` : value;
|
||||
}
|
||||
|
||||
function withToolCallId(data: unknown, toolCallId: string | undefined): unknown {
|
||||
if (toolCallId === undefined) return data;
|
||||
if (data !== null && typeof data === "object" && !Array.isArray(data)) {
|
||||
return { toolCallId, ...data };
|
||||
}
|
||||
return {
|
||||
toolCallId,
|
||||
...(data !== undefined ? { value: data } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeProposedPlanMarkdown(planMarkdown: string | undefined): string | undefined {
|
||||
const trimmed = planMarkdown?.trim();
|
||||
if (!trimmed) {
|
||||
@@ -798,16 +785,8 @@ export function runtimeEventToActivities(
|
||||
if (!isToolLifecycleItemType(event.payload.itemType)) {
|
||||
return [];
|
||||
}
|
||||
const data = withToolCallId(event.payload.data, event.itemId);
|
||||
// A streaming update's `data` carries the full tool output accumulated
|
||||
// so far (adapters merge state forward), and a new activity is emitted
|
||||
// per chunk, so persisting `data` verbatim writes O(N²) bytes per tool
|
||||
// call into both the event store and the projection table. No reader
|
||||
// needs it: ws.ts and http.ts apply `projectActivityPayload` before any
|
||||
// payload reaches a client. Persist the projected form for non-terminal
|
||||
// updates; `item.completed` below still persists the full payload.
|
||||
return [
|
||||
projectActivityPayload({
|
||||
{
|
||||
id: event.eventId,
|
||||
createdAt: event.createdAt,
|
||||
tone: "tool",
|
||||
@@ -815,10 +794,9 @@ export function runtimeEventToActivities(
|
||||
summary: event.payload.title ?? "Tool updated",
|
||||
payload: {
|
||||
itemType: event.payload.itemType,
|
||||
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
|
||||
...(event.payload.status ? { status: event.payload.status } : {}),
|
||||
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
|
||||
...(data !== undefined ? { data } : {}),
|
||||
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
|
||||
...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
|
||||
...(event.payload.parentToolUseId
|
||||
? { parentToolUseId: event.payload.parentToolUseId }
|
||||
@@ -826,7 +804,7 @@ export function runtimeEventToActivities(
|
||||
},
|
||||
turnId: toTurnId(event.turnId) ?? null,
|
||||
...maybeSequence,
|
||||
}),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -834,7 +812,6 @@ export function runtimeEventToActivities(
|
||||
if (!isToolLifecycleItemType(event.payload.itemType)) {
|
||||
return [];
|
||||
}
|
||||
const data = withToolCallId(event.payload.data, event.itemId);
|
||||
return [
|
||||
{
|
||||
id: event.eventId,
|
||||
@@ -844,10 +821,8 @@ export function runtimeEventToActivities(
|
||||
summary: event.payload.title ?? "Tool",
|
||||
payload: {
|
||||
itemType: event.payload.itemType,
|
||||
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
|
||||
...(event.payload.status ? { status: event.payload.status } : {}),
|
||||
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
|
||||
...(data !== undefined ? { data } : {}),
|
||||
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
|
||||
...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
|
||||
...(event.payload.parentToolUseId
|
||||
? { parentToolUseId: event.payload.parentToolUseId }
|
||||
@@ -863,7 +838,6 @@ export function runtimeEventToActivities(
|
||||
if (!isToolLifecycleItemType(event.payload.itemType)) {
|
||||
return [];
|
||||
}
|
||||
const data = withToolCallId(event.payload.data, event.itemId);
|
||||
return [
|
||||
{
|
||||
id: event.eventId,
|
||||
@@ -873,10 +847,7 @@ export function runtimeEventToActivities(
|
||||
summary: `${event.payload.title ?? "Tool"} started`,
|
||||
payload: {
|
||||
itemType: event.payload.itemType,
|
||||
...(event.itemId !== undefined ? { toolCallId: event.itemId } : {}),
|
||||
...(event.payload.status ? { status: event.payload.status } : {}),
|
||||
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
|
||||
...(data !== undefined ? { data } : {}),
|
||||
...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
|
||||
...(event.payload.parentToolUseId
|
||||
? { parentToolUseId: event.payload.parentToolUseId }
|
||||
@@ -1921,14 +1892,12 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
if (event.type === "thread.metadata.updated" && event.payload.name) {
|
||||
if (canReplaceThreadTitle(thread.title)) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.meta.update",
|
||||
commandId: yield* providerCommandId(event, "thread-meta-update"),
|
||||
threadId: thread.id,
|
||||
title: event.payload.name,
|
||||
});
|
||||
}
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.meta.update",
|
||||
commandId: yield* providerCommandId(event, "thread-meta-update"),
|
||||
threadId: thread.id,
|
||||
title: event.payload.name,
|
||||
});
|
||||
}
|
||||
|
||||
if (event.type === "turn.diff.updated") {
|
||||
|
||||
@@ -24,11 +24,6 @@ function makeReadModel(
|
||||
session: OrchestrationSession | null = null,
|
||||
activities: OrchestrationThread["activities"] = [],
|
||||
messages: OrchestrationThread["messages"] = [],
|
||||
lifecycle: {
|
||||
readonly pinnedAt?: string | null;
|
||||
readonly snoozedUntil?: string | null;
|
||||
readonly snoozedAt?: string | null;
|
||||
} = {},
|
||||
): OrchestrationReadModel {
|
||||
return {
|
||||
snapshotSequence: 0,
|
||||
@@ -49,9 +44,6 @@ function makeReadModel(
|
||||
archivedAt,
|
||||
settledOverride,
|
||||
settledAt: settledOverride === "settled" ? SETTLED_AT : null,
|
||||
snoozedUntil: lifecycle.snoozedUntil ?? null,
|
||||
snoozedAt: lifecycle.snoozedAt ?? (lifecycle.snoozedUntil != null ? SETTLED_AT : null),
|
||||
pinnedAt: lifecycle.pinnedAt ?? null,
|
||||
deletedAt: null,
|
||||
messages,
|
||||
proposedPlans: [],
|
||||
@@ -77,7 +69,7 @@ function makeSession(status: OrchestrationSession["status"]): OrchestrationSessi
|
||||
}
|
||||
|
||||
it.layer(NodeServices.layer)("settled thread decider", (it) => {
|
||||
it.effect("settles awake threads without a redundant wake and re-emits idempotently", () =>
|
||||
it.effect("settles active threads and re-emits idempotently for settled ones", () =>
|
||||
Effect.gen(function* () {
|
||||
const event = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
@@ -116,75 +108,6 @@ it.layer(NodeServices.layer)("settled thread decider", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("settling a snoozed thread also wakes it", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle-snoozed"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel(null, null, null, [], [], {
|
||||
snoozedUntil: "1970-01-02T09:00:00.000Z",
|
||||
}),
|
||||
});
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events.map((entry) => entry.type)).toEqual(["thread.settled", "thread.unsnoozed"]);
|
||||
const settled = events.find((entry) => entry.type === "thread.settled");
|
||||
const unsnoozed = events.find((entry) => entry.type === "thread.unsnoozed");
|
||||
if (settled?.type === "thread.settled" && unsnoozed?.type === "thread.unsnoozed") {
|
||||
expect(unsnoozed.payload.reason).toBe("user");
|
||||
expect(unsnoozed.payload.updatedAt).toBe(settled.payload.updatedAt);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("repeated settle repairs legacy settled and snoozed state", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle-snoozed-again"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel("settled", null, null, [], [], {
|
||||
snoozedUntil: "1970-01-02T09:00:00.000Z",
|
||||
}),
|
||||
});
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events.map((entry) => entry.type)).toEqual(["thread.settled", "thread.unsnoozed"]);
|
||||
const settled = events.find((entry) => entry.type === "thread.settled");
|
||||
const unsnoozed = events.find((entry) => entry.type === "thread.unsnoozed");
|
||||
if (settled?.type === "thread.settled" && unsnoozed?.type === "thread.unsnoozed") {
|
||||
expect(settled.payload.settledAt).toBe(SETTLED_AT);
|
||||
expect(settled.payload.updatedAt).toBe(NOW);
|
||||
expect(unsnoozed.payload.updatedAt).not.toBe(NOW);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("settling a pinned and snoozed thread clears the pin and snooze", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle-pinned-snoozed"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel(null, null, null, [], [], {
|
||||
pinnedAt: SETTLED_AT,
|
||||
snoozedUntil: "1970-01-02T09:00:00.000Z",
|
||||
}),
|
||||
});
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events.map((entry) => entry.type)).toEqual([
|
||||
"thread.settled",
|
||||
"thread.unpinned",
|
||||
"thread.unsnoozed",
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects settling a thread with a live session", () =>
|
||||
Effect.gen(function* () {
|
||||
for (const status of ["starting", "running"] as const) {
|
||||
|
||||
@@ -509,11 +509,16 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
updatedAt: alreadySettled ? thread.updatedAt : occurredAt,
|
||||
},
|
||||
};
|
||||
// Settling is "I'm done with this": clear states that would keep the
|
||||
// row pinned or snoozed instead of showing the new settled state.
|
||||
const companionEvents: Array<Omit<OrchestrationEvent, "sequence">> = [];
|
||||
if (thread.pinnedAt != null) {
|
||||
companionEvents.push({
|
||||
// Settling is "I'm done with this": it clears a pin the same way it
|
||||
// parks the thread. Without this, settling a pinned thread would only
|
||||
// stamp invisible state — the pin would hold the card in place until
|
||||
// a separate unpin.
|
||||
if (thread.pinnedAt == null) {
|
||||
return settledEvent;
|
||||
}
|
||||
return [
|
||||
settledEvent,
|
||||
{
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
@@ -525,25 +530,8 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
updatedAt: occurredAt,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (thread.snoozedUntil != null) {
|
||||
companionEvents.push({
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.unsnoozed",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
reason: "user",
|
||||
updatedAt: occurredAt,
|
||||
},
|
||||
});
|
||||
}
|
||||
return companionEvents.length > 0 ? [settledEvent, ...companionEvents] : settledEvent;
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
case "thread.unsettle": {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
export const DEFAULT_THREAD_TITLE = "New thread";
|
||||
|
||||
export function canReplaceThreadTitle(currentTitle: string, titleSeed?: string): boolean {
|
||||
const trimmedCurrentTitle = currentTitle.trim();
|
||||
if (trimmedCurrentTitle === DEFAULT_THREAD_TITLE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const trimmedTitleSeed = titleSeed?.trim();
|
||||
return trimmedTitleSeed !== undefined && trimmedTitleSeed.length > 0
|
||||
? trimmedCurrentTitle === trimmedTitleSeed
|
||||
: false;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodeChildProcess from "node:child_process";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
import { SqlitePersistenceMemory, makeSqlitePersistenceLive } from "./Sqlite.ts";
|
||||
|
||||
const lockHolderSource = `
|
||||
const { DatabaseSync } = require("node:sqlite");
|
||||
const db = new DatabaseSync(process.argv[1]);
|
||||
db.exec("BEGIN IMMEDIATE");
|
||||
process.stdout.write("locked\\n");
|
||||
setTimeout(() => {
|
||||
db.exec("COMMIT");
|
||||
db.close();
|
||||
}, Number(process.argv[2]));
|
||||
`;
|
||||
|
||||
const spawnWriteLockHolder = (dbPath: string, holdMs: number) =>
|
||||
Effect.promise(
|
||||
() =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
const holder = NodeChildProcess.spawn(
|
||||
process.execPath,
|
||||
["-e", lockHolderSource, dbPath, String(holdMs)],
|
||||
{ stdio: ["ignore", "pipe", "ignore"] },
|
||||
);
|
||||
holder.stdout.once("data", () => resolve());
|
||||
holder.on("error", reject);
|
||||
holder.on("exit", () =>
|
||||
reject(new Error("lock holder exited before acquiring the write lock")),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("waits out a concurrent writer instead of failing with SQLITE_BUSY", () => {
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-sqlite-busy-"));
|
||||
const dbPath = NodePath.join(tempDir, "state.sqlite");
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* sql`CREATE TABLE busy_probe(id INTEGER PRIMARY KEY)`;
|
||||
yield* spawnWriteLockHolder(dbPath, 300);
|
||||
yield* sql`INSERT INTO busy_probe(id) VALUES (${1})`;
|
||||
const rows = yield* sql<{ readonly id: number }>`SELECT id FROM busy_probe`;
|
||||
assert.deepEqual([...rows], [{ id: 1 }]);
|
||||
}).pipe(
|
||||
Effect.provide(makeSqlitePersistenceLive(dbPath).pipe(Layer.provide(NodeServices.layer))),
|
||||
Effect.ensuring(Effect.sync(() => NodeFS.rmSync(tempDir, { recursive: true, force: true }))),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("applies busy_timeout in the shared persistence setup", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
const rows = yield* sql<{ readonly timeout: number }>`PRAGMA busy_timeout`;
|
||||
assert.equal(rows[0]?.timeout, 5000);
|
||||
}).pipe(Effect.provide(SqlitePersistenceMemory)),
|
||||
);
|
||||
@@ -33,8 +33,6 @@ const makeRuntimeSqliteLayer = Effect.fn("makeRuntimeSqliteLayer")(function* (
|
||||
const setup = Layer.effectDiscard(
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
// CLI and server write from separate processes; wait rather than fail with SQLITE_BUSY.
|
||||
yield* sql`PRAGMA busy_timeout = 5000;`;
|
||||
yield* sql`PRAGMA foreign_keys = ON;`;
|
||||
yield* sql`PRAGMA journal_mode = WAL;`;
|
||||
yield* runMigrations();
|
||||
|
||||
@@ -47,7 +47,6 @@ let integrationListeningPort: number | null = null;
|
||||
const TestIntegrationNet = Layer.succeed(Net.NetService, {
|
||||
canListenOnHost: () => Effect.succeed(true),
|
||||
isPortAvailableOnLoopback: (port) => Effect.sync(() => port !== integrationListeningPort),
|
||||
hasListenerOnHost: (port) => Effect.sync(() => port === integrationListeningPort),
|
||||
reserveLoopbackPort: () => Effect.succeed(40_000),
|
||||
findAvailablePort: (preferred) => Effect.succeed(preferred),
|
||||
});
|
||||
@@ -63,7 +62,6 @@ const makeProbeFailureLayer = (
|
||||
Layer.succeed(Net.NetService, {
|
||||
canListenOnHost: () => Effect.succeed(true),
|
||||
isPortAvailableOnLoopback: () => Effect.succeed(true),
|
||||
hasListenerOnHost: () => Effect.succeed(false),
|
||||
reserveLoopbackPort: () => Effect.succeed(40_000),
|
||||
findAvailablePort: (preferred) => Effect.succeed(preferred),
|
||||
}),
|
||||
@@ -109,7 +107,6 @@ const makeLsofScannerLayer = (input: {
|
||||
Layer.succeed(Net.NetService, {
|
||||
canListenOnHost: () => Effect.succeed(true),
|
||||
isPortAvailableOnLoopback: () => Effect.succeed(true),
|
||||
hasListenerOnHost: () => Effect.succeed(false),
|
||||
reserveLoopbackPort: () => Effect.succeed(40_000),
|
||||
findAvailablePort: (preferred) => Effect.succeed(preferred),
|
||||
}),
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import { GitCommandError } from "@t3tools/contracts";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as ProjectScaffoldService from "./ProjectScaffoldService.ts";
|
||||
|
||||
const RealGitLayer = ProjectScaffoldService.layer.pipe(
|
||||
Layer.provideMerge(GitVcsDriver.layer),
|
||||
Layer.provide(ServerConfig.layerTest(process.cwd(), { prefix: "t3-project-scaffold-" })),
|
||||
Layer.provideMerge(VcsProcess.layer),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const runGit = (cwd: string, args: ReadonlyArray<string>) =>
|
||||
Effect.gen(function* () {
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
return yield* driver.execute({
|
||||
operation: "ProjectScaffoldService.test.git",
|
||||
cwd,
|
||||
args,
|
||||
timeoutMs: 10_000,
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("scaffolds a committed repo on main with README and favicon", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const service = yield* ProjectScaffoldService.ProjectScaffoldService;
|
||||
const tempDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-scaffold-" });
|
||||
const destination = path.join(tempDir, "cool-idea");
|
||||
|
||||
const result = yield* service.scaffold({ name: "Cool Idea", destinationPath: destination });
|
||||
assert.equal(result.cwd, destination);
|
||||
|
||||
const readme = yield* fileSystem.readFileString(path.join(destination, "README.md"));
|
||||
assert.equal(readme, "# Cool Idea\n\nInitialized with T3 Code.\n");
|
||||
const favicon = yield* fileSystem.readFileString(path.join(destination, "favicon.svg"));
|
||||
assert.include(favicon, "<svg");
|
||||
|
||||
// The initial commit is the point of the scaffold: worktree creation
|
||||
// fails on an unborn HEAD, so HEAD must resolve and the tree be clean.
|
||||
const branch = yield* runGit(destination, ["symbolic-ref", "--short", "HEAD"]);
|
||||
assert.equal(branch.stdout.trim(), "main");
|
||||
yield* runGit(destination, ["rev-parse", "--verify", "HEAD"]);
|
||||
const status = yield* runGit(destination, ["status", "--porcelain"]);
|
||||
assert.equal(status.stdout.trim(), "");
|
||||
}),
|
||||
).pipe(Effect.provide(RealGitLayer)),
|
||||
);
|
||||
|
||||
it.effect("refuses an existing destination folder", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const service = yield* ProjectScaffoldService.ProjectScaffoldService;
|
||||
const tempDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-scaffold-" });
|
||||
const destination = path.join(tempDir, "taken");
|
||||
yield* fileSystem.makeDirectory(destination);
|
||||
|
||||
const error = yield* Effect.flip(
|
||||
service.scaffold({ name: "Taken", destinationPath: destination }),
|
||||
);
|
||||
assert.include(error.detail, "already exists");
|
||||
}),
|
||||
).pipe(Effect.provide(RealGitLayer)),
|
||||
);
|
||||
|
||||
it.effect("removes the created folder when a git step fails", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-scaffold-" });
|
||||
const destination = path.join(tempDir, "doomed");
|
||||
|
||||
const failingGitLayer = ProjectScaffoldService.layer.pipe(
|
||||
Layer.provide(
|
||||
Layer.mock(GitVcsDriver.GitVcsDriver)({
|
||||
execute: (input) =>
|
||||
input.args.includes("commit")
|
||||
? Effect.fail(
|
||||
new GitCommandError({
|
||||
operation: input.operation,
|
||||
command: "git",
|
||||
cwd: input.cwd,
|
||||
detail: "boom",
|
||||
}),
|
||||
)
|
||||
: Effect.succeed({
|
||||
exitCode: ChildProcessSpawner.ExitCode(0),
|
||||
stdout: "",
|
||||
stderr: "",
|
||||
stdoutTruncated: false,
|
||||
stderrTruncated: false,
|
||||
}),
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const error = yield* Effect.gen(function* () {
|
||||
const service = yield* ProjectScaffoldService.ProjectScaffoldService;
|
||||
return yield* Effect.flip(
|
||||
service.scaffold({ name: "Doomed", destinationPath: destination }),
|
||||
);
|
||||
}).pipe(Effect.provide(failingGitLayer));
|
||||
|
||||
assert.isNotNull(error);
|
||||
assert.isFalse(yield* fileSystem.exists(destination));
|
||||
}),
|
||||
).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
@@ -0,0 +1,165 @@
|
||||
import * as NodeOS from "node:os";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import {
|
||||
ProjectScaffoldError,
|
||||
type ProjectScaffoldInput,
|
||||
type ProjectScaffoldResult,
|
||||
} from "@t3tools/contracts";
|
||||
import { generateProjectFaviconSvg, generateProjectReadme } from "@t3tools/shared/projectScaffold";
|
||||
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
|
||||
const isProjectScaffoldError = Schema.is(ProjectScaffoldError);
|
||||
|
||||
// Fallback identity for the initial commit when the machine has no git
|
||||
// user.name/user.email configured. The commit genuinely comes from the tool,
|
||||
// and a first-run user should not hit a git config error here.
|
||||
const FALLBACK_COMMIT_IDENTITY = {
|
||||
name: "T3 Code",
|
||||
email: "[email protected]",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Creates a brand-new project folder: mkdir, `git init -b main`, README.md and
|
||||
* a generated favicon.svg, then one initial commit. The initial commit is
|
||||
* mandatory — thread start creates a worktree from the base branch, and
|
||||
* `git worktree add` fails on a repo with an unborn HEAD.
|
||||
*/
|
||||
export class ProjectScaffoldService extends Context.Service<
|
||||
ProjectScaffoldService,
|
||||
{
|
||||
readonly scaffold: (
|
||||
input: ProjectScaffoldInput,
|
||||
) => Effect.Effect<ProjectScaffoldResult, ProjectScaffoldError>;
|
||||
}
|
||||
>()("t3/project/ProjectScaffoldService") {}
|
||||
|
||||
function expandHomePath(input: string, path: Path.Path): string {
|
||||
if (input === "~") {
|
||||
return NodeOS.homedir();
|
||||
}
|
||||
if (input.startsWith("~/") || input.startsWith("~\\")) {
|
||||
return path.join(NodeOS.homedir(), input.slice(2));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
function mapScaffoldError(operation: string) {
|
||||
return Effect.mapError((cause: unknown) =>
|
||||
isProjectScaffoldError(cause)
|
||||
? cause
|
||||
: new ProjectScaffoldError({
|
||||
operation,
|
||||
detail: "The project could not be created.",
|
||||
cause,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export const make = Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const git = yield* GitVcsDriver.GitVcsDriver;
|
||||
const path = yield* Path.Path;
|
||||
|
||||
const gitConfigValue = (cwd: string, key: string) =>
|
||||
git
|
||||
.execute({
|
||||
operation: "ProjectScaffoldService.readGitConfig",
|
||||
cwd,
|
||||
args: ["config", "--get", key],
|
||||
allowNonZeroExit: true,
|
||||
})
|
||||
.pipe(Effect.map((result) => (result.exitCode === 0 ? result.stdout.trim() : "")));
|
||||
|
||||
const populateRepository = Effect.fn("ProjectScaffoldService.populateRepository")(function* (
|
||||
destination: string,
|
||||
name: string,
|
||||
) {
|
||||
yield* git.execute({
|
||||
operation: "ProjectScaffoldService.gitInit",
|
||||
cwd: destination,
|
||||
args: ["init", "-b", "main"],
|
||||
});
|
||||
|
||||
yield* fileSystem.writeFileString(
|
||||
path.join(destination, "README.md"),
|
||||
generateProjectReadme(name),
|
||||
);
|
||||
yield* fileSystem.writeFileString(
|
||||
path.join(destination, "favicon.svg"),
|
||||
generateProjectFaviconSvg(name),
|
||||
);
|
||||
|
||||
yield* git.execute({
|
||||
operation: "ProjectScaffoldService.gitAdd",
|
||||
cwd: destination,
|
||||
args: ["add", "README.md", "favicon.svg"],
|
||||
});
|
||||
|
||||
const userName = yield* gitConfigValue(destination, "user.name");
|
||||
const userEmail = yield* gitConfigValue(destination, "user.email");
|
||||
const identityArgs =
|
||||
userName.length > 0 && userEmail.length > 0
|
||||
? []
|
||||
: [
|
||||
"-c",
|
||||
`user.name=${FALLBACK_COMMIT_IDENTITY.name}`,
|
||||
"-c",
|
||||
`user.email=${FALLBACK_COMMIT_IDENTITY.email}`,
|
||||
];
|
||||
|
||||
yield* git.execute({
|
||||
operation: "ProjectScaffoldService.gitCommit",
|
||||
cwd: destination,
|
||||
args: [...identityArgs, "commit", "-m", "Initial commit"],
|
||||
});
|
||||
});
|
||||
|
||||
const scaffold = Effect.fn("ProjectScaffoldService.scaffold")(function* (
|
||||
input: ProjectScaffoldInput,
|
||||
) {
|
||||
const destination = path.resolve(expandHomePath(input.destinationPath.trim(), path));
|
||||
const alreadyExists = new ProjectScaffoldError({
|
||||
operation: "prepareDestination",
|
||||
detail: `A folder already exists at ${destination}.`,
|
||||
});
|
||||
|
||||
if (yield* fileSystem.exists(destination).pipe(Effect.orElseSucceed(() => false))) {
|
||||
return yield* alreadyExists;
|
||||
}
|
||||
|
||||
yield* fileSystem.makeDirectory(path.dirname(destination), { recursive: true });
|
||||
// Non-recursive mkdir is the exclusive ownership claim: if a concurrent
|
||||
// scaffold created the folder between the check above and here, this fails
|
||||
// instead of silently adopting (and later deleting) the other call's repo.
|
||||
yield* fileSystem.makeDirectory(destination).pipe(
|
||||
Effect.catch((cause) =>
|
||||
fileSystem.exists(destination).pipe(
|
||||
Effect.orElseSucceed(() => false),
|
||||
Effect.flatMap((nowExists) => Effect.fail(nowExists ? alreadyExists : cause)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Remove the folder this call created when any later step fails, so a
|
||||
// retry with the same name starts clean. Parents created by the recursive
|
||||
// mkdir are left in place; they are the stable projects root.
|
||||
yield* populateRepository(destination, input.name).pipe(
|
||||
Effect.onError(() => fileSystem.remove(destination, { recursive: true }).pipe(Effect.ignore)),
|
||||
);
|
||||
|
||||
return { cwd: destination };
|
||||
});
|
||||
|
||||
return ProjectScaffoldService.of({
|
||||
scaffold: (input) => scaffold(input).pipe(mapScaffoldError("scaffold")),
|
||||
});
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(ProjectScaffoldService, make);
|
||||
@@ -66,105 +66,6 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("discovers project skills from the workspace .agents directory", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
|
||||
const configDir = path.join(tempDir, "claude-home");
|
||||
const workspace = path.join(tempDir, "workspace");
|
||||
|
||||
yield* writeSkill(
|
||||
path.join(workspace, ".agents", "skills"),
|
||||
"review",
|
||||
["---", "name: review", "description: Review the changes.", "---"].join("\n"),
|
||||
);
|
||||
|
||||
const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
|
||||
|
||||
assert.deepEqual(skills, [
|
||||
{
|
||||
name: "review",
|
||||
path: path.join(workspace, ".agents", "skills", "review", "SKILL.md"),
|
||||
enabled: true,
|
||||
scope: "project",
|
||||
description: "Review the changes.",
|
||||
},
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("prefers workspace .claude skills on three-way name collisions", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
|
||||
const configDir = path.join(tempDir, "claude-home");
|
||||
const workspace = path.join(tempDir, "workspace");
|
||||
|
||||
yield* writeSkill(
|
||||
path.join(configDir, "skills"),
|
||||
"deploy",
|
||||
["---", "name: deploy", "description: User deploy.", "---"].join("\n"),
|
||||
);
|
||||
yield* writeSkill(
|
||||
path.join(workspace, ".agents", "skills"),
|
||||
"deploy",
|
||||
["---", "name: deploy", "description: Agents deploy.", "---"].join("\n"),
|
||||
);
|
||||
yield* writeSkill(
|
||||
path.join(workspace, ".claude", "skills"),
|
||||
"deploy",
|
||||
["---", "name: deploy", "description: Claude deploy.", "---"].join("\n"),
|
||||
);
|
||||
|
||||
const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
|
||||
|
||||
assert.deepEqual(skills, [
|
||||
{
|
||||
name: "deploy",
|
||||
path: path.join(workspace, ".claude", "skills", "deploy", "SKILL.md"),
|
||||
enabled: true,
|
||||
scope: "project",
|
||||
description: "Claude deploy.",
|
||||
},
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("prefers workspace .agents skills over user skills on name collisions", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
|
||||
const configDir = path.join(tempDir, "claude-home");
|
||||
const workspace = path.join(tempDir, "workspace");
|
||||
|
||||
yield* writeSkill(
|
||||
path.join(configDir, "skills"),
|
||||
"deploy",
|
||||
["---", "name: deploy", "description: User deploy.", "---"].join("\n"),
|
||||
);
|
||||
yield* writeSkill(
|
||||
path.join(workspace, ".agents", "skills"),
|
||||
"deploy",
|
||||
["---", "name: deploy", "description: Agents deploy.", "---"].join("\n"),
|
||||
);
|
||||
|
||||
const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
|
||||
|
||||
assert.deepEqual(skills, [
|
||||
{
|
||||
name: "deploy",
|
||||
path: path.join(workspace, ".agents", "skills", "deploy", "SKILL.md"),
|
||||
enabled: true,
|
||||
scope: "project",
|
||||
description: "Agents deploy.",
|
||||
},
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("prefers project skills over user skills on name collisions", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
|
||||