Compare commits

...

190 Commits

Author SHA1 Message Date
49be50aa99 chore: ignore local .gstack/ tooling dir 2026-10-23 05:14:12 +03:00
0b8a3a505e fix: ignore the project watcher's spurious self-notification on macOS
fs.watch's recursive FSEvents backend fires an extra "change" event whose
filename is just the watched project folder's own basename, both alongside
real file changes and once more asynchronously after the folder is removed
and the watcher closed. watchProject had no filter for it, so that bogus
event reached the renderer as a PROJECTS_CHANGED notification naming a path
that was never a real project file.

Reproduced deterministically outside vitest (plain fs.watch), then fixed by
skipping any event whose filename equals the watched directory's own name.
3 previously-flaky tests in projects.watch.test.ts (expecting an empty
`changed` array) now pass consistently across repeated runs; full desktop
suite is 111/111 green, tsc clean.
2026-10-21 04:00:58 +03:00
Konstantin Paulus
af570c164a
Merge pull request #104 from diffusionstudio/fix/auto-updater
feat: update version to 0.216.0 across all modules and implement auto…
2026-10-19 00:13:14 +02:00
konstantin-paulus
98ea0c986b feat: update version to 0.216.0 across all modules and implement auto-update notifications 2026-10-19 00:11:57 +02:00
Konstantin Paulus
68b633db3c
Merge pull request #102 from diffusionstudio/feat/alpha-mask
Feat/alpha mask
2026-10-17 17:40:32 +02:00
konstantin-paulus
a54e4152c3 feat: update package versions to 0.215.0 across all modules 2026-10-17 17:35:13 +02:00
konstantin-paulus
5aeb75118a feat: add credits display to node menu and update commands to include pricing logic 2026-10-17 17:26:44 +02:00
konstantin-paulus
744dbcb6b7 feat: update tool titles for clarity and consistency in toolbar 2026-10-17 17:18:54 +02:00
konstantin-paulus
b8869dd649 feat: add new icons for edit with prompt, remove background, and remove silences; update command icons 2026-10-17 17:09:21 +02:00
konstantin-paulus
e2d070f968 feat: add mask icon display in SubItemLayer component 2026-10-17 16:53:49 +02:00
konstantin-paulus
783edc2197 feat: add 'Use as mask' shortcut and implement mask application logic 2026-10-17 13:51:37 +02:00
konstantin-paulus
075732f237 feat: implement mask tool and replace clip path functionality with masks 2026-10-17 13:33:10 +02:00
konstantin-paulus
6a45d560d1 feat: add 'type' prop to mask for channel specification and update example usage 2026-10-16 16:38:37 +02:00
konstantin-paulus
0491460e1a Merge branch 'clip-mask-containers' into feat/alpha-mask 2026-10-16 16:16:05 +02:00
Konstantin Paulus
1ac2f5cc9a
Merge pull request #100 from diffusionstudio/feat/canvas-context-menu
Feat/canvas context menu
2026-10-16 11:23:22 +02:00
konstantin-paulus
f3d3a08cc2 feat: optimize canvas position handling by replacing ResizeObserver with computed effect 2026-10-16 11:19:50 +02:00
konstantin-paulus
f29396e13a feat: update package versions to 0.214.0 across all modules 2026-10-16 11:09:52 +02:00
konstantin-paulus
0cd29c91b8 feat: adjust submenu positioning by updating SUB_GUTTER constant 2026-10-16 10:52:06 +02:00
konstantin-paulus
efbc257512 feat: add clean-up command to arrange selected nodes in a grid layout 2026-10-16 10:41:59 +02:00
konstantin-paulus
78b0580c85 feat: update media actions in canvas context menu for enhanced functionality 2026-10-16 10:28:13 +02:00
konstantin-paulus
8107138490 feat: add keyboard shortcut for opening folder in context menu 2026-10-16 10:18:09 +02:00
konstantin-paulus
d68a336199 feat: add keyboard shortcut for delete action in folder context menu 2026-10-16 10:16:44 +02:00
konstantin-paulus
7b3e1fc5e1 feat: add media asset commands and integrate into canvas context menu 2026-10-16 10:14:37 +02:00
konstantin-paulus
b01a79a9e1 feat: refactor soundAsset function to use findGeometryAsset for improved asset retrieval 2026-10-16 00:32:49 +02:00
konstantin-paulus
a567775be1 feat: enhance FloatingProjectHeader with fullscreen detection and traffic light visibility 2026-10-16 00:26:22 +02:00
konstantin-paulus
53aa33ead9 feat: add folder rename cancellation functionality in asset management 2026-10-16 00:05:40 +02:00
konstantin-paulus
c897d7b4d0 feat: add folder move functionality to asset context menus 2026-10-15 23:56:33 +02:00
konstantin-paulus
41ea0e26ab feat: add palette option to command for better control over visibility in UI 2026-10-15 23:53:44 +02:00
konstantin-paulus
893eab6d02 feat: implement clipboard functionality for media import and enhance context menu options 2026-10-15 21:29:27 +02:00
konstantin-paulus
66bed78f88 feat: refactor auto-captions command and improve scene selection logic 2026-10-15 20:56:28 +02:00
konstantin-paulus
db9a6f668f feat: enhance context menus and commands with new shortcuts and improved structure 2026-10-15 15:42:33 +02:00
konstantin-paulus
5433beaebb feat: add keyboard shortcut for toggling prompt input with 'G' key 2026-10-15 14:53:37 +02:00
konstantin-paulus
250c4cc96f feat: update more-three-dots icon for improved clarity and consistency 2026-10-15 11:11:07 +02:00
konstantin-paulus
5681fd9bff feat: add icons for clipboard actions and chat functionality in shortcuts and window commands 2026-10-15 11:07:23 +02:00
konstantin-paulus
9d8327b48d feat: enhance context menu with improved layout and submenu offsets 2026-10-15 11:01:26 +02:00
konstantin-paulus
bbb2fad77a feat: enhance canvas behavior with dynamic panning on panel visibility changes 2026-10-15 10:57:59 +02:00
konstantin-paulus
9b3983d32a feat: add window commands for UI toggling and chat access 2026-10-15 10:52:01 +02:00
konstantin-paulus
6c6349a38f feat: add layer toggle commands and integrate context menus in timeline and canvas 2026-10-15 10:44:14 +02:00
konstantin-paulus
d3d2a0b468 feat: implement node context menu for right-click actions on canvas nodes 2026-10-15 10:37:18 +02:00
konstantin-paulus
3bf9f55067 fix: adjust padding in command palette list class for improved layout 2026-10-15 10:15:49 +02:00
konstantin-paulus
c530e9ca09 feat: adjust item and row height in command palette for improved UI 2026-10-15 10:13:23 +02:00
konstantin-paulus
56a8f09e53 Refactor command palette and action bar components
- Removed unused ActionBarMenu and related components from action-bar.tsx.
- Simplified ExportCurrentFrameCommand and ExportVideoCommand by removing ActionBar dependencies.
- Integrated LayeredCommand and LayerSection types into commands context for better structure.
- Enhanced CommandPalette to support layered commands with options.
- Deleted PresetMenu component as its functionality was integrated into the command handling.
- Improved overall code organization and readability across affected files.
2026-10-15 10:05:40 +02:00
konstantin-paulus
748f31ac45 feat: implement recent commands tracking in the command palette 2026-10-15 09:42:23 +02:00
konstantin-paulus
c413432d75 feat: implement focus handling for the composer on chat tab activation 2026-10-14 23:46:50 +02:00
konstantin-paulus
8d657e578e feat: refactor asset insertion logic to support new scene creation and improve handling of empty assets 2026-10-14 22:49:16 +02:00
konstantin-paulus
2609b28820 feat: enhance asset import functionality with selection management 2026-10-14 22:40:49 +02:00
konstantin-paulus
090669c999 feat: add label to context menu group for improved organization 2026-10-14 20:55:20 +02:00
konstantin-paulus
9ccaac43ce feat: enhance context and dropdown menus with grouping and improved item alignment 2026-10-14 20:51:36 +02:00
konstantin-paulus
e53775d581 feat: add "TRANSCRIPT" filter option to asset filtering 2026-10-14 20:33:27 +02:00
konstantin-paulus
82ebd30df7 feat: refactor context menu integration and add insert options for assets 2026-10-14 20:16:07 +02:00
konstantin-paulus
b8f06155ed feat: implement remove silence command and related functionality 2026-10-14 19:43:25 +02:00
konstantin-paulus
96d7242faa feat: add project folder commands and enhance command ordering in palette 2026-10-14 17:12:21 +02:00
konstantin-paulus
c95e6afc1d feat: update toolbar drag-and-drop functionality with slot anchoring 2026-10-14 16:42:06 +02:00
konstantin-paulus
d8ca02ae02 feat: implement dynamic toolbar slot positioning and update related components 2026-10-14 16:28:33 +02:00
konstantin-paulus
ec84c73d62 feat: enhance command structure with ready state and update execution logic 2026-10-14 14:38:02 +02:00
konstantin-paulus
9617d8adec feat: add export current frame and video commands with preset menus 2026-10-14 14:23:34 +02:00
konstantin-paulus
c21f56a705 feat: implement escape key functionality to close prompt input and update command section order 2026-10-14 12:54:23 +02:00
konstantin-paulus
2a54059ea8 feat: add timeline navigation shortcuts and corresponding icons 2026-10-14 12:32:33 +02:00
konstantin-paulus
f964e5c798 feat: add reload window command and keyboard shortcuts for asset management 2026-10-14 12:02:41 +02:00
konstantin-paulus
29f214bc39 feat: add generate command and update auto-captions command title 2026-10-14 11:47:03 +02:00
konstantin-paulus
bb4ac3bdd8 Refactor command handling and UI components
- Introduced a new CommandBar component to manage command actions and their UI.
- Replaced ActionBar in ClipPathBar and ObjectMaskBar with the new CommandBar.
- Added new command functionalities including AutoCaptions, EditWithPrompt, MakeVideo, RemoveBackground, Rerun, ReuseSettings, and Upscale.
- Implemented CommandPalette for command selection via keyboard shortcuts.
- Updated useAutoCaptions and useTransforms hooks for better scene management.
- Removed deprecated ActionBar component and adjusted related imports.
- Enhanced commands context management for better command registration and execution flow.
2026-10-14 11:32:21 +02:00
konstantin-paulus
17e09d1cc4 feat: bump version to 0.213.1 across all packages 2026-10-14 00:23:21 +02:00
Konstantin Paulus
5d93ffee9c
Merge pull request #99 from diffusionstudio/feat/multi-asset-selection
Feat/multi asset selection
2026-10-14 00:16:04 +02:00
konstantin-paulus
b9dcc6193e feat: bump version to 0.213.0 across all packages 2026-10-14 00:11:25 +02:00
konstantin-paulus
db5a4e90ad feat: update timeline colors to match engine constants for improved consistency 2026-10-13 23:58:37 +02:00
konstantin-paulus
a3cd943478 feat: refine asset attachment logic to handle file modification time more accurately 2026-10-13 23:44:40 +02:00
konstantin-paulus
5ac1c05eca feat: add SVG thumbnail support and improve getSvgDimensions function 2026-10-13 23:24:51 +02:00
konstantin-paulus
7760cb569d feat: enhance asset and folder item components to support multiple selections and context menu actions 2026-10-13 23:21:43 +02:00
konstantin-paulus
fb8a924a7a feat: add MiddleEllipsis component for improved text truncation and update asset and folder item components to utilize it 2026-10-13 21:04:33 +02:00
konstantin-paulus
e5a4024bdc feat: enhance createProjectList to support optional project record updates 2026-10-13 10:33:37 +02:00
Konstantin Paulus
ccf990a25b
Merge pull request #97 from diffusionstudio/feat/draft-projects
Feat/draft projects
2026-10-13 10:01:59 +02:00
konstantin-paulus
be7c406fb3 feat: update package versions to 0.212.0 across all modules 2026-10-13 10:00:11 +02:00
konstantin-paulus
83e734a590 feat: implement project moving functionality and enhance save location picker 2026-10-13 09:52:23 +02:00
konstantin-paulus
a5717bfb66 feat: update project folder handling and improve UI elements 2026-10-13 09:32:57 +02:00
konstantin-paulus
78fe83fbf8 feat: add collections management to dashboard
- Introduced a new `view-grid.svg` icon for the dashboard.
- Implemented `DashboardSidebarCollections` component to manage collections in the sidebar.
- Updated `DashboardProjectsView` to support project scopes including drafts and collections.
- Enhanced `DashboardPage` to handle collection navigation and state.
- Created `collections.ts` for collection-related database operations.
- Modified project-related functions to support collection filing.
- Updated database schema to include collections.
- Refactored context menus to include collection management options.
2026-10-13 09:23:19 +02:00
konstantin-paulus
bd11bc6b05 feat: implement multi-project deletion and selection functionality 2026-10-12 23:56:48 +02:00
konstantin-paulus
852b3d5138 feat: display all sorted projects instead of limiting to a maximum visible count 2026-10-12 22:31:38 +02:00
konstantin-paulus
47d38fb602 docs: add warning about avoiding cloud-synced locations for project folders 2026-10-12 12:36:33 +02:00
konstantin-paulus
9a42b13865 refactor: simplify project handling by removing unused folder logic and updating related comments 2026-10-12 12:29:12 +02:00
konstantin-paulus
58af16065d feat: add project relocation and missing project handling functionality 2026-10-12 11:59:11 +02:00
konstantin-paulus
fb50341b0f feat: reopen session in new project folder and resume conversation 2026-10-12 11:46:25 +02:00
konstantin-paulus
c6a5c721e4 feat: add support for opening project folders in various code editors 2026-10-12 11:39:51 +02:00
konstantin-paulus
9bc577c771 refactor: streamline project creation and saving process
- Removed the ensureProjectsRoot function and related logic, simplifying project creation to directly create a project without waiting for a root.
- Deleted the DashboardProjectsFolderBar component and its references, as it was no longer needed.
- Updated the createProject function to eliminate the generation of random project names, now defaulting to a simple "Untitled" draft.
- Introduced a new FolderMenu component for managing project folders, including saving functionality.
- Enhanced the ProjectProvider context to handle draft saving and folder management, including keyboard shortcuts for saving.
- Updated documentation to reflect changes in project saving behavior and context reporting.
2026-10-12 11:19:53 +02:00
konstantin-paulus
450495c44b Refactor project renaming logic and documentation
- Updated comments in the project renaming functions to clarify that only the display name is changed while the folder name remains unchanged.
- Removed the unused `moveProjectRecord` function to streamline project record management.
- Adjusted related components to reflect the updated renaming behavior, ensuring consistency across the application.
2026-10-12 09:35:19 +02:00
Konstantin Paulus
90ba4d0a2d
Merge pull request #91 from stevemclin/fix/timeline-shift-wheel-horizontal-scroll
fix(timeline): read Shift as a sideways wheel gesture
2026-10-11 16:59:40 +01:00
konstantin-paulus
8a1313b777 Refactor clip path handling and enhance SVG support
- Updated the handling of clip paths in various components, replacing references to `isClipPath` with `isClipShape` for consistency.
- Enhanced the `ClipPathsSettings` component to correctly select and manage clip path shapes.
- Added support for `<mask>` and `<clipPath>` elements in the documentation, clarifying their usage and properties.
- Improved the handling of ambiguous SVG tags by including `<mask>` and `<clipPath>` in the relevant sets.
- Introduced a new `clip-path.tsx` file to manage clip path functionalities, ensuring better organization and maintainability of the codebase.
2026-10-11 11:47:17 +02:00
Konstantin Paulus
eeb0238603
Merge pull request #96 from diffusionstudio/path-primitive
Path primitive
2026-10-10 23:45:49 +01:00
konstantin-paulus
d3260cb452 Update package versions to 0.211.0 across all relevant files
- Incremented version number from 0.210.0 to 0.211.0 in package.json and package-lock.json for the editor, cli, desktop, web, and jsx packages.
- Ensured consistency in versioning across the project to reflect the latest updates.
2026-10-11 00:35:54 +02:00
konstantin-paulus
ed4a04fb44 Add AI credits icon and update references in components
- Introduced a new SVG icon for AI credits in ai-credits.svg.
- Updated references in ActionBar and PromptInputActions components to use the new ai-credits icon instead of ai-generate.
- Modified the DashboardPage to reflect the new icon for the AI credits sidebar item, enhancing visual consistency across the application.
2026-10-11 00:19:43 +02:00
konstantin-paulus
d6c76e690d Add stroke cap customization to StrokeInspector component
- Introduced stroke cap options in the StrokeInspector, allowing users to select between butt, round, and square caps.
- Updated the component's state management to handle the new cap property alongside existing stroke properties.
- Enhanced the UI with a new SegmentedIconTabs control for cap selection, improving user experience and customization capabilities.
2026-10-11 00:08:17 +02:00
konstantin-paulus
7a2eee7fe0 Update model options in genai configuration
- Replaced 'nano-banana-2.1' and 'flux-2-klein' with 'FLUX.2 Klein' and 'Grok Imagine 2.0' in the MODEL_OPTIONS array to reflect new model offerings.
- Restored 'Nano Banana Pro' and 'Seedream 5.0 Pro' to maintain a comprehensive list of available models.
- Enhanced comments for clarity on model ordering and relevance.
2026-10-10 22:03:00 +02:00
konstantin-paulus
747a719148 Remove unused SVG icons and refactor StrokeInspector component
- Deleted obsolete SVG icons: preferences-adjust-vertical.svg, stroke.dash-offset.svg, stroke.dash.svg, and stroke.gap.svg to streamline asset management.
- Refactored the StrokeInspector component to replace the DropdownMenu with a Select component for improved user experience and consistency in line style selection.
- Updated related imports and adjusted the handling of line style options to enhance clarity and maintainability.
2026-10-10 21:50:57 +02:00
konstantin-paulus
daeb15f948 Update @diffusionstudio/api-contract to version 0.5.0 and enhance model configurations
- Upgraded the @diffusionstudio/api-contract dependency across multiple packages to version 0.5.0.
- Added new model configurations for image, video, and voice categories, including 'nano-banana-2.1', 'flux-3-image', 'minimax-h3-max', and 'elevenlabs-v4'.
- Updated documentation to reflect the new models and their capabilities, ensuring accurate references for users.
2026-10-10 21:29:04 +02:00
konstantin-paulus
fc13c899f9 Enhance keyframe drag functionality and update drag gesture handling
- Updated the updateDragGestures function to include scene parameter for better context during drag operations.
- Introduced beginKeyframeDrag and applyKeyframeDrag functions to manage keyframe dragging, ensuring keyframes are moved correctly in relation to their clips.
- Refactored handleKeyframe to utilize the new keyframe drag functions, simplifying the drag logic and improving code clarity.
- Adjusted rendering logic in renderKeyframeTrack to streamline keyframe handling during drag events.
2026-10-10 16:54:57 +02:00
konstantin-paulus
1fc4d16bf8 Enhance project initialization handling and update project configuration
- Updated the SceneInitOverlay component to differentiate between new and existing projects, ensuring the prompt only appears for projects that have never had content.
- Introduced a new useProjectConfig hook to manage project state and track whether the stage has been initialized.
- Enhanced ProjectConfig class to include reactive signals for loaded and initialized states, allowing for better project lifecycle management.
- Updated documentation to clarify the role of the initialized state in project management.
2026-10-10 14:22:17 +02:00
konstantin-paulus
d5190170d6 Add stroke dash properties and related SVG icons for enhanced stroke customization
- Introduced new SVG icons for stroke styles, including solid, dashed, and various dash configurations.
- Updated the StrokeInspector component to support line styles with dash properties (dash, dashGap, dashOffset).
- Enhanced the stroke handling in the rendering system to apply dash styles correctly.
- Updated documentation to include new stroke properties and their usage in animations and styling.
- Improved entity serialization and deserialization to handle new stroke dash attributes effectively.
2026-10-10 14:19:16 +02:00
konstantin-paulus
e13b7f9edc Refactor path tool to enhance vertex handling and add preview functionality
- Removed extensive comments from the path tool for clarity and conciseness.
- Introduced a new PREVIEW_RADIUS constant for better control over vertex preview size.
- Updated the vertexDot function to accept a customizable radius parameter.
- Enhanced the drawPenTool function to include a visual preview of where the next vertex will be placed.
- Improved the drawPathEditor function to indicate potential vertex addition points on the outline.
2026-10-10 13:09:50 +02:00
konstantin-paulus
2c736e5f4a Add PivotRow component and integrate pivot functionality into transform settings
- Introduced a new PivotRow component to manage pivot properties (pivotX, pivotY) for entities.
- Updated TransformSettings to conditionally display PivotRow instead of AnchorRow based on the entity's pivot state.
- Enhanced the clip-path and group handling logic to utilize pivot instead of anchor for transformations.
- Updated documentation to reflect the new pivot properties and their usage in the context of groups and transformations.
2026-10-10 13:02:21 +02:00
konstantin-paulus
bd3a67db17 Remove obsolete tool.pen-small.svg icon and update path handling in node.tsx to use vector-path instead. 2026-10-10 01:09:35 +02:00
konstantin-paulus
3970904400 Refactor SVG icons and enhance path settings component
- Updated path SVG icons to improve design consistency and removed the obsolete path.trim-offset.svg file.
- Introduced new vector-path and vector-side-count SVG icons for enhanced visual representation.
- Modified the AppearanceSettings component to use the new vector-side-count icon.
- Enhanced the PathSettings component with dropdown menus for managing path addons, improving user interaction and customization options.
2026-10-10 01:03:50 +02:00
konstantin-paulus
1e11b17ae7 Add README for icon assets detailing usage and conversion process
- Created a README.md file in the icons directory to document the usage of SVG icons within the application.
- Included guidelines for converting Figma icons to the 25×25 pixel grid format, ensuring sharp rendering on 1x screens.
- Provided detailed instructions on geometry reading, redrawing, and cleaning up SVG files for consistency and quality.
- Enhanced documentation to support developers in maintaining and adding new icons effectively.
2026-10-10 00:46:47 +02:00
konstantin-paulus
b1aa6618b6 Refactor icon components and remove unnecessary size classes
- Removed size classes from Icon components in various files to standardize icon sizes.
- Deleted unused SVG icon files to clean up the assets directory.
- Updated related components to ensure consistent icon rendering without size specifications.
2026-10-10 00:15:51 +02:00
konstantin-paulus
0e57cd2edc Refactor EditValue to PropValue across edit types
- Removed the EditValue type and replaced it with PropValue in edit-types.ts and edit.ts files.
- Updated related interfaces and functions to ensure consistency in type usage for properties in editing operations.
- Enhanced type clarity by standardizing the value types used in source edits and property management.
2026-10-09 23:28:10 +02:00
konstantin-paulus
dd49464d56 Enhance entity serialization with new path properties
- Added support for VectorPath, EvenOdd, ViewBox, and PathTrim properties in the EntityRecord interface.
- Updated the serializeEntity function to handle new path-related data, ensuring full precision for VectorPath.
- Enhanced the deserializeEntity function to correctly parse and set new path properties from EntityRecord.
- Improved keyframe handling to include path data for keyframes, allowing for more detailed animation control.
2026-10-09 23:18:46 +02:00
konstantin-paulus
5552978747 Enhance path editing capabilities and introduce new SVG icons
- Updated the source file to include 'path' in the set of ambiguous SVG tags.
- Added new SVG icons for path trimming (trim-start, trim-end, trim-offset) and a small pen tool icon.
- Implemented a PathSettings component to manage path-specific properties such as fill rule and trim settings.
- Enhanced the Toolbar and ToolMenu components to include the new Pen tool for drawing and editing paths.
- Integrated path editing functionality, allowing users to edit vertices and manage path outlines directly on the canvas.
- Updated the inspector components to support path properties and interactions, improving the overall user experience for path manipulation.
- Enhanced documentation to include details about the new path features and SVG elements.
2026-10-09 23:18:37 +02:00
konstantin-paulus
eaacc15fc8 Add ellipse and polygon shapes to drawing tools
- Introduced new shape tools for Ellipse and Polygon, enhancing the drawing capabilities within the application.
- Updated the Toolbar component to include shape tools, allowing users to select and utilize these new shapes.
- Enhanced the ToolMenu to provide options for selecting Ellipse and Polygon tools.
- Implemented functionality for managing point counts in polygons and added relevant controls in the AppearanceSettings.
- Updated the rendering engine to support the new shapes, ensuring they can be drawn and manipulated effectively.
- Enhanced documentation to include details about the new shapes and their properties.
2026-10-09 13:44:11 +02:00
konstantin-paulus
3dbdb22953 Refactor canvas component and remove DrawOverlay
- Removed the DrawOverlay component from the canvas, streamlining the rendering process.
- Updated the Canvas component to reference the new draw tool functionality instead of DrawOverlay.
- Introduced a new DrawTool trait to manage drawing interactions, enhancing the overall drawing experience in the application.
- Updated engine initialization to include the DrawTool, ensuring proper integration with the existing systems.
2026-10-09 12:34:32 +02:00
konstantin-paulus
83df6a2a4b Add withEmptiedTracks function to manage keyframe tracks
- Introduced the withEmptiedTracks function to identify and remove keyframe tracks that no longer have keyframes associated with them.
- Updated the deleteSelection function to utilize withEmptiedTracks, ensuring that tracks are removed when their last keyframes are deleted.
- Enhanced keyframe management logic for improved performance and maintainability in the engine.
2026-10-09 12:25:41 +02:00
konstantin-paulus
21cb4d0e17 Refactor LayoutPanel component for improved dropdown menu structure
- Simplified the rendering of the layout dropdown menu within the LayoutPanel component.
- Removed unnecessary conditional rendering, streamlining the code for better readability and maintainability.
- Ensured consistent functionality while enhancing the overall structure of the dropdown menu.
2026-10-09 12:19:46 +02:00
konstantin-paulus
4e64fd8229 Refactor keyframe handling for paint properties
- Replaced Keyframe component with PaintKeyframe to manage keyframes for paint properties more effectively.
- Updated SolidFillPicker and FillItem components to utilize the new PaintKeyframe for improved keyframe management.
- Enhanced keyframe logic in the engine to support multiple paint properties, ensuring consistent behavior across paint types.
- Improved overall code clarity and maintainability by consolidating keyframe functionality related to paint.
2026-10-09 12:14:38 +02:00
konstantin-paulus
9f09a76ded Integrate Tooltip functionality into SegmentedIconTabs component
- Added Tooltip support to the SegmentedIconTabs component, enhancing user experience by providing additional context for icon tabs.
- Wrapped button elements with TooltipTrigger and included TooltipContent for improved accessibility and information display.
2026-10-09 11:41:34 +02:00
konstantin-paulus
09f227f49e Enhance StrokeInspector with visual icons and slider functionality
- Added icons to the ControlledTextField components for stroke weight and miter limit, improving visual cues for users.
- Enabled slider functionality for both inputs, enhancing user interaction and experience.
2026-10-09 11:40:10 +02:00
konstantin-paulus
5b7846382f Enhance TextPanel component with font size controls
- Added an icon to the ControlledTextField for better visual representation of font size adjustments.
- Enabled slider functionality for the font size input, improving user interaction and experience.
2026-10-09 11:19:10 +02:00
konstantin-paulus
81ab54fed1 Enhance FloatingInspector components with onClose functionality
- Added onClose prop to FloatingInspector in various inspector components to improve user experience by allowing the inspectors to close properly.
- Updated AnimationInspector, BackgroundSettings, CaptionSettings, EffectsInspector, ExportInspector, FillPicker, GradientFillPicker, ObjectMaskInspector, ShadowInspector, SourceRows, StrokeInspector, TransitionSettings, and Variables components to utilize the new onClose functionality.
- Improved overall interaction by ensuring inspectors can be closed from within their respective contexts.
2026-10-09 11:16:02 +02:00
konstantin-paulus
d14c0f3c59 Implement viewport clamping for FloatingInspector component
- Added a clampToViewport function to ensure the FloatingInspector remains within the viewport boundaries during resizing.
- Replaced the previous resize event listener with a ResizeObserver for more efficient handling of size changes.
- Updated the root reference management to observe and unobserve the element correctly, enhancing the component's responsiveness to layout changes.
2026-10-09 10:54:00 +02:00
konstantin-paulus
bdbe912409 Enhance stroke and fill handling in inspector components
- Updated FillPicker to manage stroke paint placement and gradient handling more effectively.
- Refactored StrokeInspector to utilize the new useStrokePaint hook for improved paint management.
- Adjusted rendering logic in strokes and related components to support both solid and gradient paints.
- Enhanced documentation to clarify stroke and fill interactions, including the use of paint children in strokes.
- Improved overall user experience by ensuring consistent behavior across fill and stroke components.
2026-10-09 10:49:36 +02:00
konstantin-paulus
acb7092faa Add angular gradient support in fill-picker and related components
- Introduced AngularGradientPaint to support angular gradients in the fill-picker component.
- Updated fill-row and gradient-picker components to recognize and handle angular gradients.
- Enhanced gradient handling logic to accommodate angular gradient properties and interactions.
- Updated documentation to reflect the new angular gradient capabilities and usage examples.
- Refactored gradient tool logic to include angular gradient manipulation and rendering.
2026-10-08 23:15:53 +02:00
konstantin-paulus
83c38cc53a Update color-opacity-picker component to enhance styling
- Modified the class names in the NumberField and HexColorInput components to include `last:rounded-r-md`, improving the visual appearance of the input fields.
- Ensured consistent styling across both components for better user experience.
2026-10-08 15:54:35 +02:00
konstantin-paulus
e836ffce14 Add shimmer effect for ongoing caption generation
- Introduced a new `shimmer` function to visually indicate when a scene is being captioned, enhancing user experience.
- Updated the `generateCaptions` function to prevent multiple caption generations on the same scene.
- Added `Shimmering` trait to manage the shimmer state and timing.
- Updated rendering logic to include the shimmer effect around scenes during processing.
- Added `@diffusionstudio/api-contract` dependency to `package-lock.json` for improved API integration.
2026-10-08 10:02:02 +02:00
Konstantin Paulus
38ecaef5c3
Merge pull request #92 from diffusionstudio/api-v2-migration
Api v2 migration
2026-10-07 23:39:25 +01:00
konstantin-paulus
32ab74e482 Update model references and package dependencies for improved functionality
- Removed outdated API reference from the `.env.example` file.
- Updated `@diffusionstudio/api-contract` dependency version to `^0.4.0` in both `package.json` files.
- Replaced model name `gemini-3.5-flash` with `qwen3.8-omni-flash` in configuration and documentation, ensuring alignment with the latest model capabilities.
- Added a note in the editor documentation regarding project management in cloud-synced folders to prevent issues with media handling.
2026-10-08 00:29:26 +02:00
konstantin-paulus
3e376ca95f Enhance analytics tracking in desktop and web applications
- Updated the `startAnalytics` function to accept a `WindowHost` parameter, allowing for improved tracking of app usage.
- Introduced a timer to track app usage every minute when the window is active.
- Added similar usage tracking functionality in the web application's analytics module, ensuring consistent tracking across platforms.
2026-10-07 18:28:03 +02:00
konstantin-paulus
42ede69691 Add transcript parsing functionality and integrate with asset resolution
- Introduced a new `parseTranscriptJson` function to handle various transcript JSON formats, ensuring robust parsing and error handling.
- Updated the `resolveTranscript` function to utilize `parseTranscriptJson` for improved transcript processing, replacing direct JSON parsing.
- Enhanced the overall structure and clarity of transcript handling within the media captioning system.
2026-10-07 17:22:42 +02:00
konstantin-paulus
e6573a717d Enhance asset metadata handling in AssetInfoPanel
- Introduced `createResource` to fetch job details associated with the asset, improving the retrieval of generation information.
- Updated logic to extract prompt and model details from the job data, enhancing the clarity of asset generation metadata.
- Refactored the use of asset properties to ensure accurate representation of asset creation and modification dates.
2026-10-07 15:16:21 +02:00
konstantin-paulus
35f4cf6c26 Refactor media tool documentation and update command references
- Updated documentation for various media tools to reflect the removal of the `media` prefix from command names, enhancing clarity and consistency.
- Adjusted links and references in the documentation to point to the new command structures for `grab`, `transcribe`, `filmstrip`, `waveform`, and `listen`.
- Added new documentation for the `filmstrip`, `grab`, `listen`, `probe`, and `transcribe` tools, detailing their functionalities and usage.
- Improved error handling descriptions and examples in the documentation to assist users in understanding tool operations better.
2026-10-07 15:06:38 +02:00
konstantin-paulus
55e1f1189f Refactor media command structure and update documentation
- Removed the `media` prefix from various commands (`media_grab`, `media_transcribe`, etc.) to simplify usage and improve consistency across the CLI and API.
- Updated the corresponding handlers and references in the codebase to reflect the new command names.
- Enhanced the README and documentation to clarify the changes in command structure and provide updated examples for users.
- Introduced new handlers for `grab`, `transcribe`, `filmstrip`, `waveform`, and `listen`, ensuring they align with the updated command naming conventions.
- Improved error handling and validation in the new command implementations for better user experience.
2026-10-07 15:04:15 +02:00
konstantin-paulus
6e25123941 Refactor audio handling and enhance media processing tools
- Introduced a new `audioFile` function to extract audio from assets, ensuring only the audio track is uploaded for analysis and transcription.
- Updated `mediaListen` and `mediaTranscribe` handlers to utilize the new audio extraction logic, improving efficiency and clarity in processing audio and video assets.
- Implemented error handling for audio analysis and transcription, ensuring robust responses for unsupported formats and empty audio tracks.
- Added `requireSignIn` and `apiError` functions to manage user authentication and API error handling, enhancing the reliability of tool operations.
- Updated documentation to reflect changes in audio processing and tool functionalities, providing clearer guidance for users.
2026-10-07 14:49:57 +02:00
konstantin-paulus
116eae23b8 Update cost calculation logic in estimate function to reflect model's minimum pricing
- Adjusted the chargeOf function to ensure that the cost calculation returns the model's minimum price instead of a fixed value of 1, aligning with API pricing requirements.
- Updated documentation comments for clarity on pricing logic and conditions for undefined values.
2026-10-07 14:32:07 +02:00
konstantin-paulus
e8c1bde745 Update model configurations and tool requests for improved functionality
- Replaced outdated model names in the configuration with new models: `remove-background` and `upscale-image` are now `bria-rmbg-2.0` and `seedvr-2`, respectively.
- Updated the `request` logic in the `use-transforms` file to reflect the new model names for background removal and image/video upscaling.
- Changed the transcription model from `transcribe` to `universal-3.5-pro` in the captions generation process.
- Adjusted documentation to align with the new model names and their functionalities, ensuring clarity for users.
2026-10-07 14:13:27 +02:00
konstantin-paulus
4e232a3c5d Update package versions to 0.210.0 across all modules
- Bumped version numbers in package.json and package-lock.json for the editor, CLI, desktop, web, and JSX packages to 0.210.0, ensuring consistency across the project.
- This update may include new features, bug fixes, or improvements as part of the version increment.
2026-10-07 12:35:25 +02:00
konstantin-paulus
9d09dbf0ca Remove unused large hailuo icon and update model configurations to reflect new icon names and descriptions. Adjusted model options for Grok Imagine and Krea to use appropriate icons, and modified video model configurations for Kling and Flux to enhance clarity and consistency. 2026-10-07 12:29:13 +02:00
konstantin-paulus
fe3f1d68e7 Implement estimate option in generate tool for cost and time prediction
- Added an `--estimate` option to the `generate` command, allowing users to retrieve the estimated credits and execution time without starting a job.
- Updated the `generate` function to handle the new estimate logic, returning a structured response with `credits` and `etaSeconds`.
- Enhanced documentation to clarify the usage of the estimate feature and its implications for job execution.
- Modified related types and validation to accommodate the new estimate functionality, ensuring robust input handling.
2026-10-07 12:04:03 +02:00
konstantin-paulus
f10a6917f9 Enhance generate tool to include model fields and improve input validation
- Updated the `generate` function to declare every model's fields by name, allowing clients to send only the declared properties.
- Introduced a new `modelFields` constant that aggregates fields from both API and local models, enhancing input validation.
- Added tests to verify the correct declaration of model fields and ensure proper parsing of input data.
2026-10-07 11:20:22 +02:00
konstantin-paulus
1f0476833b Update waveform rendering logic to clarify export behavior
- Enhanced documentation to specify that waveforms are only drawn in the editor and not included in exports, particularly when part of a scene composition.
- Modified the condition for rendering waveforms in real-time to ensure it only occurs when the entity is not part of a parent node, improving rendering accuracy.
2026-10-07 10:51:14 +02:00
konstantin-paulus
5c685e15b0 Refactor object mask handling and enhance effects inspector functionality
- Updated EffectsInspector and ObjectMaskInspector components to utilize the getParentNode function for improved mask grouping.
- Modified useObjectMasks hook to accept a clip parameter, allowing for more accurate retrieval of object masks based on the current video context.
- Enhanced objectMaskGroups function to categorize masks based on the associated video footage, improving user experience when selecting masks from the library.
2026-10-07 10:47:07 +02:00
konstantin-paulus
6ce93217bb Enhance effects inspector and object mask handling
- Added a new "Opacity" effect option to the EFFECT_OPTIONS array for better control over layer effects.
- Refactored the EffectsInspector component to utilize grouped object masks, improving the organization of mask options in the dropdown menu.
- Updated the ObjectMaskInspector to support selection from grouped masks, enhancing user experience when choosing masks from the library.
- Modified the useObjectMasks hook to return grouped masks, streamlining the retrieval of masks by their respective folders.
2026-10-07 10:43:17 +02:00
konstantin-paulus
e18ab84562 Remove media segment functionality and related tests
- Eliminated the `media_segment` command and its associated options from the CLI, streamlining the media handling process.
- Removed references to `media_segment` in the API handlers and tests, ensuring a cleaner codebase.
- Updated the `present` function to no longer handle `media_segment`, focusing on other media processing tasks.
- Adjusted related documentation to reflect the removal of the `media_segment` functionality, enhancing clarity for developers.
2026-10-07 10:29:55 +02:00
konstantin-paulus
21589f4843 Enhance audio handling in media generation and update documentation
- Updated the `generate` function to support audio field references for scenes, allowing users to transcribe audio from scene mixes.
- Introduced new utility functions for audio encoding and scene reference validation, improving the handling of audio uploads.
- Modified the `requireScene` function to include a reason parameter for better error messaging.
- Updated documentation to reflect the new capabilities for transcribing scenes and handling audio, enhancing clarity for developers.
2026-10-07 00:23:55 +02:00
konstantin-paulus
6a0ef3c188 Implement generate and job endpoints in the web API
- Added `generate` and `job` handlers to facilitate media generation and job management through the API.
- Enhanced the `generate` function to handle file uploads and return job details, including estimated run time and credit costs.
- Implemented the `job` function to retrieve job status and results, allowing users to poll for job completion and access generated files.
- Updated documentation to reflect the new endpoints and their usage, improving clarity for developers integrating with the API.
2026-10-06 23:14:59 +02:00
konstantin-paulus
d2e56157a4 Enhance authentication event tracking to differentiate new users
- Updated the authentication state change handler to track sign-in events specifically for new users by introducing an `isNewUser` check.
- Modified the condition for tracking the 'signed_in' event to ensure it only triggers for new users, improving the accuracy of user engagement analytics.
2026-10-06 18:24:23 +02:00
konstantin-paulus
73e578f47c Refactor analytics tracking and configuration in desktop application
- Replaced the Umami tracking implementation with a new analytics system that utilizes a queue for event tracking.
- Introduced `configureAnalytics` function to set API URL and token for event tracking.
- Updated event tracking methods to handle canvas edits and code changes, improving the granularity of analytics data.
- Modified main channels to reflect the new analytics configuration, enhancing the integration between the main and renderer processes.
- Improved documentation and code organization for better maintainability and clarity.
2026-10-06 18:11:41 +02:00
konstantin-paulus
8d9dfb690c Update placement logic for beside function to improve alignment
- Changed documentation and implementation in the `beside` function to clarify that the spot is now top-aligned with the reference box instead of level.
- Adjusted the calculation of `minY` to align with the top of the box, enhancing the placement logic for better visual consistency on the canvas.
2026-10-06 16:22:09 +02:00
konstantin-paulus
62c1f1533d Refactor recent projects display in DashboardHomeView for responsive grid layout
- Introduced dynamic column calculation for recent projects based on available width, improving responsiveness.
- Replaced fixed column count with a calculated grid layout that adapts to screen size, enhancing user experience.
- Updated documentation for constants related to recent project card dimensions and grid configuration.
2026-10-06 16:12:39 +02:00
konstantin-paulus
68b3095405 Enhance project deletion logic to handle non-existent directories
- Updated the `deleteProject` function to check if the directory exists before attempting to move it to the trash, preventing errors when trying to delete already deleted projects.
- Improved documentation to clarify that a project can still be removed from the list even if its folder is already gone.
2026-10-06 16:08:32 +02:00
konstantin-paulus
2c536d913d Implement upgrade dialog visibility control in purchase success component
- Added `hideUpgradeDialog` function to manage the visibility of the upgrade dialog.
- Integrated `hideUpgradeDialog` call in the `show` function of the `PurchaseSuccess` component to ensure the dialog is closed when a new purchase is displayed, enhancing user experience by preventing overlapping dialogs.
2026-10-06 16:04:23 +02:00
konstantin-paulus
105f81de89 Add credit display and tooltip functionality in action bar and prompt input components
- Introduced a new `TransformButton` component to encapsulate the credit display and tooltip functionality for transformation actions in the action bar.
- Updated the `ActionBar` component to utilize `TransformButton`, enhancing the user experience by providing clear credit information for each action.
- Enhanced the `PromptInputActions` component to show estimated credits for rerun actions, improving user awareness of costs.
- Refactored the `use-estimate` module to support dynamic credit calculations and formatting, ensuring accurate cost representation throughout the application.
2026-10-06 15:30:11 +02:00
SteveMclin
e5efb565c5 fix(timeline): read Shift as a sideways wheel gesture
Shift+wheel never scrolled the timeline sideways on Windows or Linux. The
handler only moved horizontally when the event itself carried a deltaX, and
a mouse on those platforms keeps reporting the gesture on deltaY: the
browser swaps its default action for Shift, not the event's axes. macOS and
trackpads set deltaX themselves, which is why the bug only showed up on
Windows and Linux mice.

The axis is now read out of the deltas while Shift is held, in both the
timeline canvas and the row-label scroller, which had the same blind spot.
A delta that needs borrowing only wins when it is the larger of the two, so
a trackpad's own horizontal delta is still used as it arrives.
2026-10-06 15:15:50 +02:00
konstantin-paulus
932c92d5f6 Add credit estimation feature in PromptInput component
- Integrated a new `useEstimate` hook to calculate the cost of generation based on the current configuration.
- Updated the `PromptInput` component to display estimated credits required for generation, enhancing user awareness of costs.
- Improved the UI to show credit information dynamically, providing a better user experience during prompt generation.
2026-10-06 13:37:24 +02:00
konstantin-paulus
ecf97f8cc1 Add duration range support in model options and prompt input
- Introduced a new `durationRange` property in the `ModelOption` interface to allow models to specify a range of valid durations.
- Implemented a `DurationRangeMenu` component in the `PromptInput` to enable users to select durations within the specified range, including presets and custom input.
- Updated the `fitToModel` function to utilize the new duration range when configuring model options, enhancing the flexibility of duration selection.
- Enhanced the UI to dynamically display and handle duration selections, improving overall user experience.
2026-10-06 13:31:05 +02:00
konstantin-paulus
f4e7e7f54f Add duration selection functionality with slider in PromptInput component
- Introduced a new DurationMenu component that allows users to select durations using a slider.
- Refactored duration handling to utilize a list of available durations, improving user interaction.
- Updated the duration accessor to return a number or undefined for better type safety.
- Enhanced the UI to display the selected duration dynamically, improving overall usability.
2026-10-06 13:10:11 +02:00
konstantin-paulus
75f0bfc8fc Remove "Add audio" functionality from the action bar and related components
- Deleted the "Add audio" button from the ActionBar and its associated logic in the PromptInputActions component.
- Updated the TransformType definition to exclude "addAudio" and removed related handling in the use-transforms module.
- Adjusted the model configuration to reflect the removal of audio-related transformations, streamlining the available options for users.
2026-10-06 12:53:36 +02:00
konstantin-paulus
14feb5d4f7 Add Gemini 3.8 Flash TTS model and voice options
- Introduced the "gemini-3.8-flash-tts" model with associated voice options to the configuration.
- Added a new `GEMINI_VOICE_OPTIONS` array, detailing various prebuilt voices with descriptions and preview URLs.
- Updated the default model for the VOICE mode to use the new Gemini model, enhancing the voice generation capabilities in the application.
2026-10-06 12:46:45 +02:00
konstantin-paulus
56fb94104b Refactor prompt input handling and introduce saved configuration functionality
- Replaced `createDefaultConfig` with `restoreConfig` in multiple components to utilize saved configurations for prompt input.
- Added `saved-config.ts` to manage saving and loading prompt configurations across sessions, enhancing user experience by preserving state.
- Updated the `PromptInput` component to load saved configurations on initialization and save changes automatically.
- Adjusted the `openPromptInput` method to accept optional configurations, allowing for more flexible prompt handling.
- Modified model defaults in `config.ts` to reflect updated model options, ensuring consistency across the application.
2026-10-06 12:25:32 +02:00
konstantin-paulus
8d3965fa9c Enhance model menu with keyboard navigation and search functionality
- Introduced keyboard navigation for the model selection menu, allowing users to highlight options using arrow keys and select with Enter.
- Refactored the search input to support dynamic filtering of model options based on user input, improving accessibility and usability.
- Updated the `SearchInput` component to accept a ref and onKeyDown handler for better integration with the model menu.
- Enhanced the overall user experience by ensuring focus management and visual feedback during selection.
2026-10-06 12:12:16 +02:00
konstantin-paulus
e5b8971aac Update model options and refactor default model handling
- Reordered and updated the `MODEL_OPTIONS` to enhance clarity and relevance, introducing new models and adjusting their positions.
- Refactored the `fitToModel` and `createDefaultConfig` functions to utilize a new `defaultModelOption` for improved model selection based on mode.
- Removed deprecated model entries to streamline the configuration and ensure consistency across components.
2026-10-06 12:02:35 +02:00
konstantin-paulus
8616127c50 Enhance model configuration with resolution support
- Added resolution handling to the generation configuration, allowing models to specify available output resolutions.
- Updated the `MODEL_OPTIONS` and `MODEL_MODES` to include new models and their respective resolutions.
- Refactored the `fitToModel` function to accommodate resolution selection, ensuring compatibility with model capabilities.
- Integrated resolution options into the `PromptInput` component for user selection, improving the overall user experience.
- Adjusted type definitions to include resolution in the generation configuration, enhancing type safety across components.
2026-10-06 11:43:38 +02:00
konstantin-paulus
e3af57b136 Refactor generation configuration and type handling
- Moved generation configuration types from `schemas.ts` to `types.ts` for better organization and clarity.
- Updated imports across components to utilize the new `types.ts` file, ensuring consistent type usage.
- Refactored the `createDefaultConfig` and `fitToModel` functions in `requests.ts` to streamline model configuration handling.
- Removed deprecated `schemas.ts` file to clean up the codebase and improve maintainability.
2026-10-06 10:52:46 +02:00
konstantin-paulus
9bde5fe6ef Add file attachment handling and paste support in agent chat
- Introduced functionality for handling pasted files as attachments, including image previews.
- Enhanced the `fileAttachment` function to support generating object URLs for image previews.
- Implemented a `createPasteHandler` to manage paste events and display error messages for failed uploads.
- Updated the `Composer` and `DashboardHomeView` components to integrate paste handling.
- Added server-side support for uploading attachments, ensuring unique paths for each upload.
- Enhanced the protocol to include an `attachments.upload` method for handling file uploads.
2026-10-05 23:37:30 +02:00
konstantin-paulus
b83d6e4b80 Enhance focus behavior and clean up UI components
- Added a CSS rule to remove focus outlines for non-input elements, improving visual clarity.
- Removed unnecessary focus-related classes from various UI components, streamlining their styles.
- Updated button and dialog components to enhance user experience by simplifying focus management.
2026-10-05 23:25:59 +02:00
konstantin-paulus
6f14ce551a Add focus behavior to PromptInput component on mount
- Implemented `onMount` lifecycle method to automatically focus the textarea and set the selection range to the end of the current value when the component is rendered.
- This enhancement improves user experience by allowing immediate interaction with the input field.
2026-10-05 23:22:12 +02:00
konstantin-paulus
e4c4cdad4b Refactor API client and job handling logic
- Simplified the API client setup by consolidating authorization logic into the `httpBatchLink`.
- Updated job handling to replace subscription-based polling with a more efficient polling mechanism using `jobs.get`.
- Improved error handling during job polling to allow for retries before giving up on failed polls.
- Enhanced code clarity by removing deprecated subscription logic and unnecessary comments.
2026-10-05 23:12:45 +02:00
konstantin-paulus
d29d18b33c Export generating utility functions to enhance modularity and facilitate generation processes in the runtime package. 2026-10-05 23:02:31 +02:00
konstantin-paulus
42753381ff Refactor generative AI components and consolidate generation logic
- Replaced individual generation hooks for image, video, voice, and audio with a unified `useGenerate` hook to streamline generation processes.
- Updated the `ActionBar` and `PromptInputActions` components to utilize the new `useGenerate` hook for rerunning generation jobs.
- Enhanced media selection handling by refactoring the `useMediaSelection` hook to return image and video media more efficiently.
- Removed deprecated placeholder functionality and related imports, improving code clarity and maintainability.
- Introduced a new `requests.ts` file to manage API request configurations for generation tasks.
- Updated the `useGenerationRecords` hook to track job information more effectively, including the first job and total credits.
- Improved transform handling in the `useTransforms` hook to apply transformations over selected media nodes.
- Added auto-caption generation functionality in the `useAutoCaptions` hook, integrating with the project context.
- Removed unused files and code related to legacy generation methods, enhancing overall project structure.
2026-10-05 23:02:23 +02:00
konstantin-paulus
77eee77313 Add purchase success poster and enhance success dialog
- Introduced a new poster image for the purchase success dialog.
- Added CSS animations for the poster and button interactions to improve user experience.
- Refactored the `PurchaseSuccess` component to handle purchase details and display animations.
- Updated success URL handling to include purchase information for better tracking.
2026-10-05 16:31:03 +02:00
konstantin-paulus
8ff93b159b Update dependencies and enhance dashboard components
- Added `@trpc/client` and `@trpc/server` dependencies to `package-lock.json` and `package.json`.
- Updated `.env.example` to include the new API URL for Diffusion Studio.
- Refactored dashboard components to utilize the new `@diffusionstudio/api-contract`, replacing legacy backend calls.
- Improved user experience in the dashboard by updating plan and billing information handling.
- Removed deprecated backend code and adjusted related components for better maintainability.
2026-10-05 15:37:48 +02:00
konstantin-paulus
631d457373 Export sourceFiles function for external use and integrate migrateGenerations in compileProject to handle legacy asset migrations. This enhances project compatibility with previous versions. 2026-10-04 11:33:51 +02:00
konstantin-paulus
1a8968a396 Refactor generative AI components and update dependencies
- Removed unused imports and code related to generative assets in various components.
- Updated the `package-lock.json` to remove `@diffusionstudio/api-contract` and `@trpc` dependencies.
- Introduced a placeholder mechanism for generative AI features that are currently being rebuilt.
- Adjusted the CLI and documentation to reflect changes in available commands and features.
- Enhanced the handling of timeouts in the CLI client for media analysis and rendering tasks.
2026-10-04 11:12:49 +02:00
Konstantin Paulus
fefcde9df7
Merge pull request #90 from diffusionstudio/agent-plugins
Agent plugins
2026-10-03 16:30:32 +01:00
konstantin-paulus
c99d8c2d3a Update package versions to 0.209.1 across all modules
- Incremented version numbers in `package.json` and `package-lock.json` for the main editor, CLI, desktop, and web applications to reflect the new release.
2026-10-02 10:27:42 +02:00
konstantin-paulus
c4fbd51f1d Add WINDOW_SHOW channel and integrate into upgrade dialog
- Introduced a new channel `WINDOW_SHOW` to manage window visibility.
- Updated `main-channels.ts` to define the new channel and its request/response structure.
- Integrated the `WINDOW_SHOW` channel in `main.ts` to handle window display requests.
- Modified the `showUpgradeDialog` function in `upgrade-dialog.tsx` to call the new channel when the dialog is opened, enhancing user experience.
2026-10-02 09:47:21 +02:00
konstantin-paulus
371841b253 Implement file attachment handling in agent chat
- Added functionality to pick files from the system and handle dropped attachments in the chat composer.
- Introduced a new `pickAttachments` function to facilitate file selection, enhancing user experience.
- Updated the composer and home view to integrate the new attachment handling, allowing users to add files easily.
- Refactored attachment merging logic to streamline the process of managing attachments in the chat interface.
2026-10-02 09:26:14 +02:00
konstantin-paulus
f2d6f553b3 Refine alt-drag interaction handling in DocumentEditor
- Updated the alt-drag functionality to clarify that it duplicates elements before moving them, enhancing the user experience.
- Introduced a call to `transformSystem` during dragstart when alt is pressed and duplicates are present, ensuring proper state management during interactions.
- Improved documentation to reflect these changes for better understanding of the interaction model.
2026-10-02 09:19:01 +02:00
konstantin-paulus
b59fdff188 Enhance config write handling and claim management
- Introduced a mechanism to manage overlapping config writes, ensuring that only the last write is retained while previous writes are settled.
- Added a claims system to track writes and prevent unnecessary updates, improving performance during rapid changes.
- Updated tests to verify the behavior of config writes and outside edits, ensuring accurate reporting and state management.
2026-10-02 09:10:24 +02:00
konstantin-paulus
ef3a20d4ba Add GitHub workflow for bumping winget package
- Created a new workflow to automate the process of updating the winget package for each published release.
- The workflow retrieves the latest release tag, validates it, and submits updates to the winget-pkgs repository using the Komac tool.
- Includes error handling for draft releases and ensures the installer URL is accessible before submission.
- Requires a WINGET_TOKEN secret for authentication during the submission process.
2026-10-02 08:45:36 +02:00
konstantin-paulus
f1f6d87862 Add prePackage hook for Windows signing validation
- Implemented a prePackage hook in the Forge configuration to check for necessary environment variables for Windows signing.
- Updated the windowsSign function to return undefined instead of throwing an error if required variables are missing, improving error handling during the signing process.
2026-10-01 10:38:37 +02:00
Konstantin Paulus
3a979f1660
Merge pull request #89 from diffusionstudio/tray
Tray
2026-10-01 09:03:36 +01:00
konstantin-paulus
ce9724df2c Update package versions to 0.209.0 across all modules
- Incremented version numbers in `package.json` and `package-lock.json` for the main editor, CLI, desktop, and web applications to reflect the new release.
2026-10-01 10:02:22 +02:00
konstantin-paulus
7215d92631 Update README to reflect new branding message
- Changed the tagline from "The professional video editor built for agents" to "Turn your agent into a professional video editor" to better convey the application's purpose and appeal.
2026-10-01 09:52:52 +02:00
konstantin-paulus
dd961f9ec2 Add tray menu icons and enhance theme support
- Introduced new tray menu icons for various application states (open, hide, ready, busy, project, quit) to improve user experience.
- Enhanced the `AppTray` class to support dynamic icon updates based on the current theme (light/dark).
- Updated the context menu to include icons alongside labels for better visual representation.
- Added a new script command in `package.json` for generating tray menu icons.
2026-10-01 09:23:27 +02:00
konstantin-paulus
d2f0ecb1de Enhance CLI and Desktop Functionality
- Updated the CLI to include a new `window` command for managing the application window state (show/hide).
- Improved the background launch logic to prevent launching the app if it is already running in the background.
- Added new tray icons for different application states (busy, idle, window) to enhance user experience.
- Refactored the `agent-chat` module to improve the handling of the agent chat endpoint and its lifecycle.
- Introduced a `WindowHost` class to manage the main window's lifecycle, ensuring it only exists when needed and integrates with the tray functionality.
- Removed the deprecated `headless` module and adjusted related logic to streamline the application flow.
- Updated the DAPI server to support window management, allowing tools to interact with the main window effectively.
2026-10-01 09:11:07 +02:00
Konstantin Paulus
a69468fb5d
Merge pull request #86 from diffusionstudio/google-font-integration
Release v0.208.0
2026-09-30 11:49:58 +01:00
konstantin-paulus
f7f6ee02a3 Update package versions to 0.208.0 across all modules
- Incremented version numbers in `package.json` and `package-lock.json` for the main editor, CLI, desktop, and web applications to reflect the new release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 12:47:39 +02:00
konstantin-paulus
f2a82581c9 Update Caption Text Styles and Highlight Color
- Changed font family from 'Poppins' to 'Outfit' and adjusted font weights in both `guinea.ts` and `spotlight.ts` for consistency in text styling.
- Updated the highlight color in `spotlight.ts` to improve visual distinction in captions.
2026-09-30 12:43:02 +02:00
konstantin-paulus
11995532b6 Refactor Export Progress Component and Enhance Cancel Functionality
- Updated the `ExportProgress` component to include an alert dialog for confirming export cancellation, improving user experience during export operations.
- Removed unnecessary props from the component, simplifying its interface and enhancing maintainability.
- Adjusted the rendering logic to display audio or video export status based on the `audioOnly` prop.
- Modified the `ExportProvider` to pass the new `audioOnly` state, ensuring accurate progress reporting.
- Streamlined the `RenderOverlayState` to focus on essential properties, enhancing clarity in the export process.
2026-09-30 12:29:16 +02:00
konstantin-paulus
fc63b73214 Add Google Fonts Support and Enhance Font Picker Functionality
- Introduced new options for the `fonts` command to filter by provider and popular fonts, enhancing user experience in font selection.
- Updated the documentation to reflect the inclusion of Google Fonts and local fonts, clarifying how to access and utilize them in projects.
- Implemented a new `FontDropdown` component in the web inspector for improved font selection, allowing users to choose from popular and Google Fonts seamlessly.
- Refactored existing components to integrate the new font selection logic, ensuring consistency across the application.
2026-09-30 11:57:25 +02:00
konstantin-paulus
b06d5b21c7 Remove Tracking Settings Component from Inspector
- Deleted the `TrackingSettings` component and its associated logic from the inspector, streamlining the sidebar functionality.
- Updated the inspector to no longer display tracking settings for shape targets, improving clarity and focus on relevant settings.
2026-09-30 10:49:14 +02:00
konstantin-paulus
f00276fd86 Enhance Animation Documentation and Logic
- Updated the animations documentation to clarify the behavior of presets, emphasizing that they scale or shift the node's authored properties rather than replacing them.
- Modified the `applyAnimation` function to ensure that computed values are compounded correctly for overlapping animations, improving the accuracy of visual effects during animation playback.
2026-09-29 22:21:23 +02:00
konstantin-paulus
d302d4b938 Remove redundant assignment of computed.chars in resetAnimatedValues function to prevent static node issues with text motion overrides. 2026-09-29 20:36:28 +02:00
konstantin-paulus
5310ff0324 Sync lockfile jsx version to 0.207.0 2026-09-29 10:07:43 +02:00
Konstantin Paulus
52e3a2a997
Merge pull request #85 from diffusionstudio/motion-tracking
Motion tracking
2026-09-29 08:48:49 +01:00
808 changed files with 26020 additions and 11404 deletions

72
.github/workflows/bump-winget.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: Bump winget package
# Opens a pull request on microsoft/winget-pkgs for each published release,
# the Windows counterpart of bump-cask.yml. Komac reads the manifest of the
# version already in winget-pkgs, swaps in the new installer URL and its
# checksum, and submits from the token owner's fork of winget-pkgs. The
# package's first version is submitted by hand; this only updates it.
#
# Needs the WINGET_TOKEN secret: a classic personal access token with the
# `public_repo` scope (Komac cannot open the pull request with a
# fine-grained one), whose account has a fork of microsoft/winget-pkgs.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Release tag to submit (vX.Y.Z). Empty means the latest release.
required: false
env:
PACKAGE_ID: DiffusionStudio.DiffusionStudio
KOMAC_VERSION: 2.16.0
KOMAC_SHA256: 7d2707fa6210f2789a3702de49fbd150b736dbf426ee0b9bc8e098736f9fd82d
jobs:
bump-winget:
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- name: Resolve release
id: info
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: |
if [ -z "$TAG" ]; then
TAG=$(curl -sf https://api.github.com/repos/diffusionstudio/editor/releases/latest | jq -r .tag_name)
fi
# Draft releases carry a placeholder tag (untagged-<hash>); never submit that.
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Refusing to bump winget: '$TAG' is not a vX.Y.Z tag" >&2
exit 1
fi
URL="https://github.com/diffusionstudio/editor/releases/download/${TAG}/Diffusion-Studio-x64-Setup.exe"
# Komac downloads the installer to hash it; make sure it is there first (retrying like bump-cask.yml).
curl -sfIL --retry 10 --retry-delay 30 --retry-all-errors -o /dev/null "$URL"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
echo "url=$URL" >> "$GITHUB_OUTPUT"
- name: Install Komac
run: |
curl -sfL -o komac.tar.gz "https://github.com/russellbanks/Komac/releases/download/v${KOMAC_VERSION}/komac-${KOMAC_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
echo "${KOMAC_SHA256} komac.tar.gz" | sha256sum -c -
tar -xzf komac.tar.gz komac
./komac --version
- name: Submit to winget-pkgs
env:
GITHUB_TOKEN: ${{ secrets.WINGET_TOKEN }}
VERSION: ${{ steps.info.outputs.version }}
URL: ${{ steps.info.outputs.url }}
TAG: ${{ steps.info.outputs.tag }}
# On a rerun Komac finds the pull request it opened before and, in CI,
# exits without opening another.
run: |
./komac update "$PACKAGE_ID" \
--version "$VERSION" \
--urls "$URL" \
--release-notes-url "https://github.com/diffusionstudio/editor/releases/tag/${TAG}" \
--submit

3
.gitignore vendored
View File

@ -39,4 +39,5 @@ out/
# AI
skills-lock.json
.agents
.claude
.claude
.gstack/

View File

@ -4,7 +4,7 @@
</a>
</p>
<p align="center">The professional video editor built for agents</p>
<p align="center">Turn your agent into a professional video editor</p>
<p align="center">
<a href="https://www.diffusion.studio/download"><img src="https://img.shields.io/badge/Download-macOS%20%7C%20Windows-161616?style=flat&labelColor=000000" alt="Download for macOS or Windows" /></a>
@ -49,7 +49,6 @@ The agent handles everything from there:
Beyond finishing a cut, it covers:
- **Motion graphics**: explainers, promos, and title sequences
- **Generative assets**: images, video, and voiceover, declared in code and composited into the timeline
- **Clipping**: highlights from a long video, reformatted for social
- **Video understanding**: summaries, scene search, quotes with timestamps
@ -141,10 +140,6 @@ The root is a `<stage>` holding one `<scene>` per frame you cut in:
```tsx
import { For } from "solid-js";
import { generate } from "@diffusionstudio/jsx";
const hero = generate.image({ prompt: "A neon city at night, cinematic", aspectRatio: "16:9" });
const motion = generate.video({ prompt: "slow camera push-in", startFrame: hero, duration: 5 });
const TITLES = [
{ text: "The Grid", start: 0, end: 2.5 },
@ -155,7 +150,7 @@ export default function Project() {
return (
<stage camera={[0.3, 0, 0, 0.3, 85, 150]}>
<scene name="Intro" width={1920} height={1080} fill="black" active>
<video src={motion} start={0} end={5} width={1920} height={1080} />
<video src="footage/city.mp4" start={0} end={5} width={1920} height={1080} />
<For each={TITLES}>
{(t) => (
<text
@ -185,16 +180,16 @@ Everything a mount produces stays a first-class editor node, so a person can pic
Cutting footage requires understanding it. The app exposes the inspection tools an agent needs to work with media it cannot watch — as MCP tools, and as the same commands in a shell:
```sh
diffusion media probe clip.mp4 # container + codec metadata, like ffprobe
diffusion media grab clip.mp4 -t 0 12 45 # decode frames to PNGs
diffusion media filmstrip clip.mp4 # grid of video frames
diffusion media waveform track.mp3 # audio waveform, silence flagged
diffusion media transcribe interview.wav # timed, word-level transcript
diffusion media listen interview.mp4 -p "what is said in the intro?" # ask a multimodal model
diffusion capture intro -t 0 2 4 # the frames a render would produce, by scene id
diffusion probe clip.mp4 # container + codec metadata, like ffprobe
diffusion grab clip.mp4 -t 0 12 45 # decode frames to PNGs
diffusion filmstrip clip.mp4 # grid of video frames
diffusion waveform track.mp3 # audio waveform, silence flagged
diffusion transcribe interview.wav # timed, word-level transcript
diffusion listen interview.mp4 -p "what is said in the intro?" # ask a multimodal model
diffusion capture intro -t 0 2 4 # the frames a render would produce, by scene id
```
Each command is the MCP tool of the same name: `diffusion media grab` is `media_grab`, `--per-sheet` is `perSheet`.
Each command is the MCP tool of the same name: `diffusion grab` is `grab`, `--per-sheet` is `perSheet`.
| Command | Purpose |
| --- | --- |
@ -202,8 +197,8 @@ Each command is the MCP tool of the same name: `diffusion media grab` is `media_
| `diffusion context` | Summary of app state |
| `diffusion capture` | Render frames of a scene, as an export would, to a labelled contact sheet or one PNG per position |
| `diffusion check` | Check a node's subtree for structural mistakes (black-frame gaps, never-visible nodes, failed sources) and report subtree stats |
| `diffusion media …` | Inspect a file by id or path: `probe`, `grab`, `filmstrip`, `waveform`, `transcribe`, `listen` |
| `diffusion models` / `diffusion voices` / `diffusion fonts` | Discover generation models, speech voices, local fonts |
| `diffusion probe` / `grab` / `filmstrip` / `waveform` / `transcribe` / `listen` | Inspect a file by id or path |
| `diffusion fonts` | Discover Google Fonts and local font families |
| `diffusion screenshot` / `diffusion logs` | The app itself: capture the window, read recent console output |
| `diffusion report` | Report a bug in the tools or the app: diagnostics bundled, filed as a GitHub issue via `gh` |
@ -212,8 +207,8 @@ Conventions throughout: every result is one JSON object, the same structured con
## Documentation
- [Tool reference](docs/reference/tools/README.md): every tool and CLI command, its options, and its output
- [JSX reference](docs/reference/jsx/README.md): the composition markup with elements, timing, paints, generative assets, and captions
- [Examples](docs/examples/README.md): runnable compositions, from basic scenes and generative assets to three.js and raw WebGPU
- [JSX reference](docs/reference/jsx/README.md): the composition markup with elements, timing, paints, and captions
- [Examples](docs/examples/README.md): runnable compositions, from basic scenes to three.js and raw WebGPU
## Repository layout
@ -224,7 +219,7 @@ Conventions throughout: every result is one JSON object, the same structured con
| `apps/cli` | `@diffusionstudio/cli` | The `diffusion` CLI (`dapi` alias): a client of the app's MCP server |
| `packages/runtime` | `@diffusionstudio/runtime` | Headless editor runtime: the koota world, traits, actions, systems, media decoding, capture. No DOM, no Solid |
| `packages/reconciler` | `@diffusionstudio/reconciler` | Evaluates a compiled project bundle and reconciles its element tree onto runtime entities, via Solid's universal renderer |
| `packages/jsx` | `@diffusionstudio/jsx` | The authoring API: element vocabulary, types, and generated assets (`generate.*`) |
| `packages/jsx` | `@diffusionstudio/jsx` | The authoring API: element vocabulary and types |
| `packages/assets` | `@diffusionstudio/assets` | A project's asset library: the `assets.yml` manifest, content hashing, probing, resolution |
| `packages/encoder` | `@diffusionstudio/encoder` | Offline video/audio/image encoding over runtime worlds (mediabunny) |
| `packages/koota-solid` | `@diffusionstudio/koota-solid` | Solid bindings for koota, ported from `@koota/react` |

View File

@ -1,7 +1,7 @@
{
"name": "@diffusionstudio/cli",
"private": true,
"version": "0.207.0",
"version": "0.216.0",
"license": "MPL-2.0",
"bin": {
"diffusion": "./dist/index.js",

View File

@ -12,13 +12,14 @@ import type { ToolInput, ToolName, ToolOutput } from "@diffusionstudio/dapi";
export const APP_NAME = "Diffusion Studio";
// Renders and AI generation outlive the 60s default.
// Renders, media analysis and file transfers outlive the 60s default.
const TIMEOUTS: Record<string, number> = {
export: 3_600_000,
capture: 600_000,
media_transcribe: 600_000,
media_listen: 600_000,
media_segment: 3_600_000,
transcribe: 600_000,
listen: 600_000,
generate: 600_000,
job: 600_000,
};
/**

View File

@ -5,7 +5,7 @@
import { existsSync } from "node:fs";
import { isAbsolute, resolve } from "node:path";
import { Command } from "commander";
import { Argument, Command } from "commander";
import { z } from "zod";
import { version } from "../../../package.json";
import { MCP_URL, toolByName } from "@diffusionstudio/dapi";
@ -66,24 +66,31 @@ function assetPath(ref: string): string {
return ref;
}
/** `x,y` as a point, added to the ones given before; a malformed one becomes NaN for the schema to reject. */
const point = (value: string, previous: Array<{ x: number; y: number }> = []): Array<{ x: number; y: number }> => {
const [x = NaN, y = NaN, ...rest] = value.split(",").map(numeric);
return [...previous, rest.length > 0 ? { x: NaN, y: NaN } : { x, y }];
};
/** Parsed JSON, or a failure naming what was being read. */
function json(value: string, what: string): unknown {
try {
return JSON.parse(value);
} catch (e) {
fail(`${what} is not valid JSON: ${(e as Error).message}`);
}
}
/** `x0,y0,x1,y1` as a box; the wrong count of numbers becomes NaN for the schema to reject. */
const box = (value: string): [number, number, number, number] => {
const bounds = value.split(",").map(numeric);
return bounds.length === 4 ? (bounds as [number, number, number, number]) : [NaN, NaN, NaN, NaN];
};
/** Every `{ "path": … }` file reference in a request, resolved as `assetPath` does; the rest untouched. */
function resolveFileRefs(value: unknown): unknown {
if (Array.isArray(value)) return value.map(resolveFileRefs);
if (typeof value !== "object" || value === null) return value;
const entries = Object.entries(value);
if (entries.length === 1 && entries[0]![0] === "path" && typeof entries[0]![1] === "string") return { path: assetPath(entries[0]![1]) };
return Object.fromEntries(entries.map(([key, item]) => [key, resolveFileRefs(item)]));
}
/**
* A mask's destination: a path spelled as one on disk (absolute, or starting
* with `.`) resolves against the working directory; anything else is a
* library path, passed through for the app to resolve in the open project.
* Where generated files go: a path spelled as one on disk
* (absolute, or starting with `.`) resolves against the working directory;
* anything else is a library path, passed through for the app to resolve in
* the open project.
*/
function maskOutput(ref: string): string {
function libraryOrDiskPath(ref: string): string {
return isAbsolute(ref) || ref.startsWith(".") ? resolve(ref) : ref;
}
@ -92,20 +99,22 @@ const program = new Command();
program
.name("diffusion")
.description(
`The Diffusion Studio CLI: understand, generate, and edit footage.
Analyze video/audio/images, generate them with AI, and compose assets.
Use for any media analysis, media generation, or video editing task. No ffmpeg needed.`)
`The Diffusion Studio CLI: understand and edit footage.
Analyze video/audio/images and compose assets.
Use for any media analysis or video editing task. No ffmpeg needed.`)
.version(version);
program
.command("open")
.description(
`Launch ${APP_NAME} (or surface the running instance) and, given a path, open that folder as a project, creating the project files if the folder is not one yet. Prints the project's id, display name, and folder. Run this once before commands that need an open project (capture, check, export, context, and library paths in media commands).`,
`Launch ${APP_NAME} (or surface the running instance) and, given a path, open that folder as a project, creating the project files if the folder is not one yet. Prints the project's id, display name, and folder. Run this once before commands that need an open project.`,
)
.argument("[path]", `${field("open", "dir")} (default: none — just launch the app)`)
.option("-b, --background", "launch or keep the app in the background, without raising a window")
.action(async (path: string | undefined, opts: { background?: boolean }) => {
const launched = await launchApp(opts.background ?? false);
const background = opts.background ?? false;
const running = background && (await ping().then(() => true, (e) => (isAppDown(e) ? false : appError(e))));
const launched = !running && (await launchApp(background));
await (launched ? waitForApp() : ping()).catch(appError);
if (path !== undefined) await run("open", { dir: resolve(path) });
});
@ -152,114 +161,115 @@ program
if (output.issues.some((issue) => issue.severity === "error")) process.exitCode = 1;
});
const media = program
.command("media")
.alias("m")
.description(
"Inspect a media file by path, without adding it to the project: probe metadata, transcribe speech, grab frames, render visual previews, and analyze with multimodal models. Local files work with or without an open project; library paths need one.",
);
media
program
.command("probe")
.description(describe("media_probe"))
.argument("<path>", field("media_probe", "path"))
.action((ref: string) => run("media_probe", { path: assetPath(ref) }));
.description(describe("probe"))
.argument("<path>", field("probe", "path"))
.action((ref: string) => run("probe", { path: assetPath(ref) }));
media
program
.command("transcribe")
.description(describe("media_transcribe"))
.argument("<path>", field("media_transcribe", "path"))
.option("-o, --output <path>", field("media_transcribe", "output"))
.action((ref: string, opts: Omit<ToolInput<"media_transcribe">, "path">) =>
run("media_transcribe", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
.description(describe("transcribe"))
.argument("<path>", field("transcribe", "path"))
.option("-o, --output <path>", field("transcribe", "output"))
.action((ref: string, opts: Omit<ToolInput<"transcribe">, "path">) =>
run("transcribe", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
);
media
program
.command("grab")
.alias("sample")
.description(describe("media_grab"))
.argument("<path>", field("media_grab", "path"))
.option("-t, --times <time...>", field("media_grab", "times"))
.option("-c, --count <n>", field("media_grab", "count"), numeric)
.option("-a, --auto", field("media_grab", "auto"))
.option("-s, --start <time>", field("media_grab", "start"))
.option("-e, --end <time>", field("media_grab", "end"))
.option("-q, --quality <preset>", field("media_grab", "quality"))
.option("-S, --separate", field("media_grab", "separate"))
.option("--per-sheet <n>", field("media_grab", "perSheet"), numeric)
.option("--uncapped", field("media_grab", "uncapped"))
.option("-o, --output <dir>", field("media_grab", "output"))
.action((ref: string, opts: Omit<ToolInput<"media_grab">, "path">) =>
run("media_grab", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
.description(describe("grab"))
.argument("<path>", field("grab", "path"))
.option("-t, --times <time...>", field("grab", "times"))
.option("-c, --count <n>", field("grab", "count"), numeric)
.option("-a, --auto", field("grab", "auto"))
.option("-s, --start <time>", field("grab", "start"))
.option("-e, --end <time>", field("grab", "end"))
.option("-q, --quality <preset>", field("grab", "quality"))
.option("-S, --separate", field("grab", "separate"))
.option("--per-sheet <n>", field("grab", "perSheet"), numeric)
.option("--uncapped", field("grab", "uncapped"))
.option("-o, --output <dir>", field("grab", "output"))
.action((ref: string, opts: Omit<ToolInput<"grab">, "path">) =>
run("grab", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
);
media
program
.command("filmstrip")
.alias("film")
.description(describe("media_filmstrip"))
.argument("<path>", field("media_filmstrip", "path"))
.option("-s, --start <time>", field("media_filmstrip", "start"))
.option("-e, --end <time>", field("media_filmstrip", "end"))
.option("-x, --scale <factor>", field("media_filmstrip", "scale"), numeric)
.option("-o, --output <path>", field("media_filmstrip", "output"))
.action((ref: string, opts: Omit<ToolInput<"media_filmstrip">, "path">) =>
run("media_filmstrip", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
.description(describe("filmstrip"))
.argument("<path>", field("filmstrip", "path"))
.option("-s, --start <time>", field("filmstrip", "start"))
.option("-e, --end <time>", field("filmstrip", "end"))
.option("-x, --scale <factor>", field("filmstrip", "scale"), numeric)
.option("-o, --output <path>", field("filmstrip", "output"))
.action((ref: string, opts: Omit<ToolInput<"filmstrip">, "path">) =>
run("filmstrip", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
);
media
program
.command("waveform")
.alias("wave")
.description(describe("media_waveform"))
.argument("<path>", field("media_waveform", "path"))
.option("-s, --start <time>", field("media_waveform", "start"))
.option("-e, --end <time>", field("media_waveform", "end"))
.option("-x, --scale <factor>", field("media_waveform", "scale"), numeric)
.option("-o, --output <path>", field("media_waveform", "output"))
.action((ref: string, opts: Omit<ToolInput<"media_waveform">, "path">) =>
run("media_waveform", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
.description(describe("waveform"))
.argument("<path>", field("waveform", "path"))
.option("-s, --start <time>", field("waveform", "start"))
.option("-e, --end <time>", field("waveform", "end"))
.option("-x, --scale <factor>", field("waveform", "scale"), numeric)
.option("-o, --output <path>", field("waveform", "output"))
.action((ref: string, opts: Omit<ToolInput<"waveform">, "path">) =>
run("waveform", { path: assetPath(ref), ...opts, output: opts.output && resolve(opts.output) }),
);
media
program
.command("listen")
.description(describe("media_listen"))
.argument("<path>", field("media_listen", "path"))
.option("-p, --prompt <str>", field("media_listen", "prompt"))
.option("-s, --start <time>", field("media_listen", "start"))
.option("-e, --end <time>", field("media_listen", "end"))
.action((ref: string, opts: Omit<ToolInput<"media_listen">, "path">) => run("media_listen", { path: assetPath(ref), ...opts }));
.description(describe("listen"))
.argument("<path>", field("listen", "path"))
.option("-p, --prompt <str>", field("listen", "prompt"))
.option("-s, --start <time>", field("listen", "start"))
.option("-e, --end <time>", field("listen", "end"))
.action((ref: string, opts: Omit<ToolInput<"listen">, "path">) => run("listen", { path: assetPath(ref), ...opts }));
media
.command("segment")
.alias("mask")
.description(describe("media_segment"))
.argument("<path>", field("media_segment", "path"))
.requiredOption("-t, --time <time>", field("media_segment", "time"))
.option("-p, --point <x,y>", `${field("media_segment", "points")}; repeat for more`, point)
.option("-x, --exclude <x,y>", `${field("media_segment", "exclude")}; repeat for more`, point)
.option("-b, --box <x0,y0,x1,y1>", field("media_segment", "box"), box)
.option("--preview", field("media_segment", "preview"))
.option("-s, --start <time>", field("media_segment", "start"))
.option("-e, --end <time>", field("media_segment", "end"))
.option("-m, --model <size>", field("media_segment", "model"))
program
.command("generate")
.alias("gen")
.description(describe("generate"))
.addArgument(new Argument("<model>", field("generate", "model")).choices(toolByName("generate").input.shape.model.options))
.argument(
"[fields]",
`the model's other fields as one JSON object, e.g. '{"aspectRatio":"16:9","images":[{"path":"./ref.png"}]}'; a { "path" } that exists relative to the working directory is sent as its absolute path; an "audio" field also takes { "scene": "<id>" }, the scene's mix`,
)
.option("-p, --prompt <text>", "the request's `prompt`, without JSON quoting; wins over one in the fields")
.option(
"-o, --output <path>",
`${field("media_segment", "output")}; a path starting with . resolves against the working directory`,
`${field("generate", "output")}; a path starting with . resolves against the working directory`,
)
.action((ref: string, opts: Omit<ToolInput<"media_segment">, "path"> & { point?: ToolInput<"media_segment">["points"] }) => {
const { point: points, ...rest } = opts;
return run("media_segment", { path: assetPath(ref), ...rest, points, output: opts.output && maskOutput(opts.output) });
.option("--max-credits <n>", field("generate", "maxCredits"), numeric)
.option("--estimate", field("generate", "estimate"))
.action((model: ToolInput<"generate">["model"], fields: string | undefined, opts: { prompt?: string; output?: string; maxCredits?: number; estimate?: boolean }) => {
const parsed = fields === undefined ? {} : json(fields, "fields");
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) fail("fields must be a JSON object.");
const request = resolveFileRefs(parsed) as Record<string, unknown>;
return run("generate", {
...request,
model,
...(opts.prompt === undefined ? {} : { prompt: opts.prompt }),
output: opts.output && libraryOrDiskPath(opts.output),
maxCredits: opts.maxCredits,
estimate: opts.estimate,
});
});
program
.command("models")
.description(describe("models"))
.argument("[type]", field("models", "type"))
.action((type: ToolInput<"models">["type"]) => run("models", { type }));
program
.command("voices")
.description(describe("voices"))
.action(() => run("voices", {}));
.command("job")
.description(`${describe("job")} Exits 1 when the job failed or was canceled.`)
.argument("<id>", field("job", "id"))
.option("--cancel", field("job", "cancel"))
.action(async (id: string, opts: { cancel?: boolean }) => {
const output = await call("job", { id, cancel: opts.cancel }).catch(appError);
console.log(JSON.stringify(output));
if (output.status === "failed" || output.status === "canceled") process.exitCode = 1;
});
program
.command("logs")
@ -276,6 +286,15 @@ program
.option("-o, --output <dir>", field("screenshot", "output"))
.action((opts: ToolInput<"screenshot">) => run("screenshot", { output: opts.output && resolve(opts.output) }));
program
.command("window")
.description(describe("window"))
.argument("[state]", "show (and focus) or hide the window (default: leave it as it is)")
.action((state: string | undefined) => {
if (state !== undefined && state !== "show" && state !== "hide") fail(`Expected show or hide, got "${state}".`);
return run("window", { visible: state === undefined ? undefined : state === "show" });
});
program
.command("report")
.alias("issue")
@ -290,6 +309,8 @@ program
.command("fonts")
.description(describe("fonts"))
.option("-f, --family <pattern>", field("fonts", "family"))
.option("-p, --provider <provider>", field("fonts", "provider"))
.option("--popular", field("fonts", "popular"))
.option("-w, --weights <weights...>", field("fonts", "weights"))
.option("-s, --style <style>", field("fonts", "style"))
.option("-l, --limit <n>", field("fonts", "limit"), numeric)
@ -298,4 +319,8 @@ program
// Explicit argv convention: the packaged wrapper runs this bundle on
// Electron in ELECTRON_RUN_AS_NODE mode, where commander would otherwise
// detect Electron and drop the script path from argv.
program.parse(process.argv, { from: "node" });
// The media commands used to sit under a `media` (`m`) group; drop that word so
// scripts written against it (older projects' npm scripts) keep working.
const argv = ["media", "m"].includes(process.argv[2] ?? "") ? process.argv.toSpliced(2, 1) : process.argv;
program.parse(argv, { from: "node" });

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<path d="M6.5 2.5l1.25 3.25L11 7 7.75 8.25 6.5 11.5 5.25 8.25 2 7l3.25-1.25z"/><path d="M12 10l.6 1.4 1.4.6-1.4.6L12 14l-.6-1.4L10 12l1.4-.6z" fill="#000" stroke-width="0.75"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<mask id="gap"><rect width="16" height="16" fill="#fff" stroke="none"/><path d="M2.5 2.5l11 11" stroke="#000" stroke-width="3.25"/></mask>
<g mask="url(#gap)"><path d="M1.75 8S4 3.75 8 3.75 14.25 8 14.25 8 12 12.25 8 12.25 1.75 8 1.75 8z"/><circle cx="8" cy="8" r="2"/></g><path d="M2.5 2.5l11 11"/>
</svg>

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="3" width="12" height="10" rx="2"/><path d="M2 6h12"/>
</svg>

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<path d="M2 4.5A1.5 1.5 0 0 1 3.5 3h2.75l1.5 1.5h4.75A1.5 1.5 0 0 1 14 6v5.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 11.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<path d="M8 2v5.5"/><path d="M4.75 4.25a5.25 5.25 0 1 0 6.5 0"/>
</svg>

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">
<circle cx="8" cy="8" r="6"/><path d="M5.5 8.25l1.75 1.75 3.25-3.5"/>
</svg>

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -93,6 +93,13 @@ const config: ForgeConfig = {
}),
],
hooks: {
prePackage: async () => {
if (process.platform === 'win32' && !process.env.SKIP_SIGN && !sign) {
throw new Error(
'Windows signing needs WINDOWS_SIGNTOOL_PATH, WINDOWS_SIGN_DLIB and WINDOWS_SIGN_METADATA; set SKIP_SIGN=1 for an unsigned build.',
);
}
},
preMake: async () => ensure7zip(),
},
};
@ -111,9 +118,7 @@ function windowsSign() {
} = process.env;
if (!signToolPath || !dlib || !metadata) {
throw new Error(
'Windows signing needs WINDOWS_SIGNTOOL_PATH, WINDOWS_SIGN_DLIB and WINDOWS_SIGN_METADATA; set SKIP_SIGN=1 for an unsigned build.',
);
return undefined;
}
return {

View File

@ -1,7 +1,7 @@
{
"name": "@diffusionstudio/desktop",
"private": true,
"version": "0.207.0",
"version": "0.216.0",
"license": "MPL-2.0",
"repository": {
"type": "git",
@ -10,7 +10,7 @@
"main": "dist/main.js",
"scripts": {
"build:preload": "esbuild src/preload.ts --bundle --platform=node --format=cjs --external:electron --outfile=dist/preload.js",
"build:main": "esbuild src/main.ts --bundle --platform=node --format=cjs --external:electron --external:esbuild --external:@babel/core --external:@babel/preset-typescript --external:babel-preset-solid --outfile=dist/main.js",
"build:main": "esbuild src/main.ts --bundle --platform=node --format=cjs --loader:.png=binary --external:electron --external:esbuild --external:@babel/core --external:@babel/preset-typescript --external:babel-preset-solid --outfile=dist/main.js",
"build:native": "node scripts/build-native.mjs",
"build": "npm run check && npm run build:main && npm run build:preload && npm run build:agent-host && npm run build:native",
"build:web": "npm --prefix ../web run build:desktop",
@ -26,7 +26,8 @@
"test": "vitest run",
"build:agent-host": "esbuild ../../packages/agent-chat/src/bin.ts --bundle --platform=node --format=esm --target=node20 --external:electron \"--external:@anthropic-ai/claude-agent-sdk-*\" --banner:js=\"import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);\" --outfile=dist/agent-host.mjs",
"make:ico": "python3 scripts/win-assets.py ico",
"make:spinner": "python3 scripts/win-assets.py spinner"
"make:spinner": "python3 scripts/win-assets.py spinner",
"make:tray-menu": "sh scripts/tray-menu-icons.sh"
},
"devDependencies": {
"@electron-forge/cli": "^7.11.1",

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Regenerates the Windows tray menu icons: assets/tray/menu/<name>.svg ->
# <name>.png (16px) and <name>@2x.png (32px). Black on transparent; the app
# recolors them to match the menu's light or dark theme. macOS uses SF
# Symbols instead and does not need these.
#
# Needs rsvg-convert (brew install librsvg).
set -e
cd "$(dirname "$0")/../assets/tray/menu"
for svg in *.svg; do
name="${svg%.svg}"
rsvg-convert -w 16 -h 16 "$svg" -o "$name.png"
rsvg-convert -w 32 -h 32 "$svg" -o "$name@2x.png"
done

View File

@ -2,12 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// The agent chat host as a utility process: forked from the ESM bundle
// esbuild puts in dist/, configured over parentPort (never argv, which
// every process can read), restarted with backoff when it dies. The
// renderer asks for the endpoint over the existing IPC and talks to the
// host over its own WebSocket from there.
import { app, utilityProcess } from "electron";
import { randomBytes } from "node:crypto";
import { join } from "node:path";
@ -19,6 +13,8 @@ type AgentChatOptions = { dataDir: string; mcpUrl: string | null; version: strin
const DEV_ORIGIN = "http://localhost:5173";
const RESTART_DELAYS_MS = [1000, 2000, 5000, 10_000];
const STOP_GRACE_MS = 3000;
// How long an ask for the endpoint waits for a host it had to start.
const START_WAIT_MS = 10_000;
let child: UtilityProcess | null = null;
let endpoint: { url: string } | null = null;
@ -28,6 +24,8 @@ let restarts = 0;
let restartTimer: ReturnType<typeof setTimeout> | null = null;
let stopped = false;
const waiting = new Set<() => void>();
function spawn(): void {
if (!options || stopped) return;
const path = join(app.getAppPath(), "dist", "agent-host.mjs");
@ -51,6 +49,9 @@ function spawn(): void {
if (message?.type === "listening" && typeof message.url === "string") {
endpoint = { url: message.url };
restarts = 0;
for (const wake of [...waiting]) {
wake();
}
console.log(`[agent-chat] host listening at ${message.url.replace(/token=.*$/, "token=…")}`);
} else if (message?.type === "error") {
console.error(`[agent-chat] host failed to start: ${message.message}`);
@ -72,23 +73,43 @@ function spawn(): void {
});
}
/** Generates the token and forks the host. Call once, after `whenReady`. */
export function startAgentChat(next: AgentChatOptions): void {
/** Generates the token; the host is forked when it is first needed. Call once, after `whenReady`. */
export function configureAgentChat(next: AgentChatOptions): void {
options = next;
token = randomBytes(32).toString("base64url");
stopped = false;
restarts = 0;
spawn();
}
/** Where the host is right now: null while it is (re)starting. */
export function agentChatEndpoint(): { url: string } | null {
return endpoint;
/** Where the host is listening, starting it when it is not running; null when it does not come up in time. */
export function agentChatEndpoint(): Promise<{ url: string } | null> {
if (endpoint || stopped || !options) {
return Promise.resolve(endpoint);
}
// Not running and not about to restart: this is the first ask.
if (!child && !restartTimer) {
spawn();
}
return new Promise((resolve) => {
const wake = () => {
clearTimeout(timer);
waiting.delete(wake);
resolve(endpoint);
};
const timer = setTimeout(wake, START_WAIT_MS);
waiting.add(wake);
});
}
/** Best effort: a host that is down or restarting leaves the chats behind. They aren't trashed with the folder. */
export function deleteProjectChats(projectId: string): void {
if (projectId && endpoint) child?.postMessage({ type: "deleteProject", projectId });
/** Best effort: a host that does not come up leaves the chats behind. They aren't trashed with the folder. */
export async function deleteProjectChats(projectId: string): Promise<void> {
if (!projectId) return;
const running = await agentChatEndpoint();
if (running) {
child?.postMessage({ type: "deleteProject", projectId });
}
}
/** Asks the host to stop (it kills its harness trees), then kills it after a grace period. */

View File

@ -3,84 +3,107 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { app } from "electron";
import { randomUUID } from "node:crypto";
import { join } from "node:path";
import { access, writeFile } from "node:fs/promises";
import { stat, writeFile } from "node:fs/promises";
import type { ClientEventName, TrackedEvent, TrackProps } from "@diffusionstudio/api-contract";
import type { WindowHost } from "./window-host";
const enabled = app.isPackaged || process.env.DIFFUSION_ANALYTICS === "1";
const FLUSH_INTERVAL_MS = 30_000;
const BATCH_MAX = 100;
const QUEUE_MAX = 2_000;
const queue: TrackedEvent[] = [];
let apiUrl: string | null = null;
let token: string | null | undefined;
/** Canvas edits by kind, and source files changed from outside the app, since the last flush. */
let canvasEdits: Record<string, number> = {};
let changedFiles = new Set<string>();
export function configureAnalytics(config: { apiUrl: string; token: string | null }): void {
apiUrl = config.apiUrl;
token = config.token;
}
export function track(name: ClientEventName, props: TrackProps = {}): void {
if (!enabled) return;
// Undefined values would fail validation; JSON leaves them out.
queue.push({
id: randomUUID(),
at: new Date().toISOString(),
name,
props: JSON.parse(JSON.stringify(props)),
});
if (queue.length > QUEUE_MAX) {
queue.splice(0, queue.length - QUEUE_MAX);
}
}
/** Edits the canvas wrote back to the source (move, insert, remove, …). */
export function countCanvasEdits(kinds: string[]): void {
for (const kind of kinds) {
canvasEdits[kind] = (canvasEdits[kind] ?? 0) + 1;
}
}
/** A source file changed from outside the app: an agent or an editor writing code. */
export function countCodeChange(path: string): void {
changedFiles.add(path);
}
/**
* Desktop analytics. The renderer's Umami script never fires inside Electron
* (its `data-domains` gate does not match the `file://` origin), so main
* posts events directly to Umami's send API: the renderer's product events
* arrive over `ANALYTICS_TRACK`, and the install event is sent from here.
*
* Install tracking is proxied by the first launch of a packaged build: one
* event, then a marker file in `userData` to never send it again. Offline
* first launches retry on the next launch.
* Starts the flush and usage timers and records the launch. The first launch of an
* install is recorded once, guarded by a marker file in `userData`; its age
* goes on every `app_opened`, so install-to-sign-up time needs no device id.
*/
export async function startAnalytics(windows: WindowHost): Promise<void> {
if (!enabled) return;
const UMAMI_ENDPOINT = "https://cloud.umami.is/api/send";
const UMAMI_WEBSITE_ID = "e898e381-6ce3-4f5f-a485-8327ec9aa88b";
const HOSTNAME = "desktop.diffusion.studio";
const MARKER_FILE = "install-tracked";
setInterval(flush, FLUSH_INTERVAL_MS);
setInterval(() => (windows.current() && track("app_used")), 60_000);
// Umami discards events whose User-Agent trips its bot filter, which both
// Node's fetch default and Electron's own UA do — send a plain browser UA
// that still attributes the right OS.
function userAgent(): string {
const platform =
process.platform === "darwin"
? "Macintosh; Intel Mac OS X 10_15_7"
: process.platform === "win32"
? "Windows NT 10.0; Win64; x64"
: "X11; Linux x86_64";
return `Mozilla/5.0 (${platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36`;
const marker = join(app.getPath("userData"), "install-tracked");
const installedAt = await stat(marker).then((info) => info.birthtimeMs, () => null);
if (installedAt === null) {
track("app_installed", { arch: process.arch });
await writeFile(marker, new Date().toISOString()).catch(() => { });
}
track("app_opened", { install_age_s: Math.round((Date.now() - (installedAt ?? Date.now())) / 1000) });
}
export type AnalyticsEventData = Record<string, string | number | boolean>;
async function flush(): Promise<void> {
const edits = Object.values(canvasEdits).reduce((sum, n) => sum + n, 0);
if (edits) {
track("canvas_edited", { edits, ...canvasEdits });
}
if (changedFiles.size) {
track("code_changed", { files: changedFiles.size });
}
canvasEdits = {};
changedFiles = new Set();
/** Post one event to Umami. Resolves to whether Umami accepted it; never throws. */
async function sendEvent(name: string, url: string, data: AnalyticsEventData): Promise<boolean> {
if (!queue.length || !apiUrl || token === undefined) return;
const batch = queue.splice(0, BATCH_MAX);
try {
const response = await fetch(UMAMI_ENDPOINT, {
const response = await fetch(`${apiUrl}/api/v2/trpc/events.track`, {
method: "POST",
headers: { "Content-Type": "application/json", "User-Agent": userAgent() },
body: JSON.stringify({
type: "event",
payload: { website: UMAMI_WEBSITE_ID, hostname: HOSTNAME, url, name, data },
}),
headers: { "Content-Type": "application/json", ...(token ? { Authorization: `Bearer ${token}` } : {}) },
body: JSON.stringify({ source: "desktop", appVersion: app.getVersion(), platform: process.platform, events: batch }),
signal: AbortSignal.timeout(10_000),
});
return response.ok;
// Sent, or a batch the API will never take (400): either way it is done.
if (response.ok || response.status === 400) return;
} catch {
// Offline or Umami unreachable.
return false;
}
}
/** A product event from the renderer. Dev builds stay out of the numbers. */
export async function trackEvent(name: string, data: AnalyticsEventData = {}): Promise<void> {
if (!app.isPackaged) return;
await sendEvent(name, "/desktop", {
...data,
platform: process.platform,
version: app.getVersion(),
});
}
export async function trackInstall(): Promise<void> {
if (!app.isPackaged) return;
const marker = join(app.getPath("userData"), MARKER_FILE);
try {
await access(marker);
return;
} catch {
// No marker yet — this is the first (tracked) launch.
// Offline or the API unreachable.
}
const sent = await sendEvent("desktop_install", "/desktop/install", {
platform: process.platform,
arch: process.arch,
version: app.getVersion(),
});
// Not sent — retried on the next launch.
if (sent) await writeFile(marker, new Date().toISOString()).catch(() => {});
queue.unshift(...batch);
}

View File

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// The files on the system clipboard: what a copy in Finder or Explorer (or
// of a recording in a screenshot app) leaves there. The renderer reads
// pictures itself, but the web clipboard API knows nothing of files, and
// outside a paste event this is the only way to them.
import { clipboard } from "electron";
import { fileURLToPath } from "node:url";
/** The files on the clipboard, by path, in the order they were copied. */
export function clipboardPaths(): string[] {
switch (process.platform) {
case "darwin": {
// Every file of a copy is in the filenames list, a plist of paths; the
// file URL type only holds the first.
const plist = clipboard.read("NSFilenamesPboardType");
const paths = [...plist.matchAll(/<string>([^<]*)<\/string>/g)].map((match) => unescapeXml(match[1]!));
if (paths.length) return paths;
const url = clipboard.read("public.file-url");
return url.startsWith("file:") ? [fileURLToPath(url)] : [];
}
case "win32": {
// Only the first file of a copy: the full list is in CF_HDROP, which
// Electron cannot read.
const path = clipboard.readBuffer("FileNameW").toString("utf16le").split("\0")[0];
return path ? [path] : [];
}
default:
return clipboard
.read("text/uri-list")
.split(/\r?\n/)
.filter((line) => line.startsWith("file:"))
.map((url) => fileURLToPath(url));
}
}
function unescapeXml(text: string): string {
return text
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&quot;/g, '"')
.replace(/&apos;/g, "'")
.replace(/&amp;/g, "&");
}

View File

@ -4,6 +4,16 @@
import type { LogEntry, ToolArgs, ToolResult } from "@diffusionstudio/dapi";
/** The main window, as the `window` tool drives it. */
export type AppWindow = {
/** Whether the window is out for the user. */
visible(): boolean;
/** Shows and focuses it, creating it when there is none. */
show(): Promise<void>;
/** Puts it away; the app keeps running in the background. */
hide(): void;
};
/** What a main-process handler gets besides its arguments. */
export type MainContext = {
/** Fires when the caller cancels or goes away. */
@ -12,10 +22,12 @@ export type MainContext = {
logs(): LogEntry[];
/** The app's version. */
version: string;
/** The main window. */
window: AppWindow;
};
/** The tools that need the file system or a child process, not a window. */
export type MainToolName = "logs" | "report";
/** The tools that need the file system, a child process or the window itself, not a renderer. */
export type MainToolName = "logs" | "report" | "window";
export type MainHandler<N extends MainToolName> = (args: ToolArgs<N>, ctx: MainContext) => Promise<ToolResult<N>>;

View File

@ -4,8 +4,9 @@
import { logs } from "./logs";
import { report } from "./report";
import { window } from "./window";
import type { MainHandlers } from "../handler";
/** Every tool main answers itself, keyed by its catalog name. */
export const mainHandlers: MainHandlers = { logs, report };
export const mainHandlers: MainHandlers = { logs, report, window };

View File

@ -11,7 +11,8 @@ import type { MainContext } from "../handler";
const entry = (ts: number, message: string, level: LogEntry["level"] = "info"): LogEntry => ({ ts, level, message, source: "" });
const ctx = (entries: LogEntry[]): MainContext => ({ signal: new AbortController().signal, logs: () => entries, version: "0" });
const noWindow = { visible: () => false, show: async () => {}, hide: () => {} };
const ctx = (entries: LogEntry[]): MainContext => ({ signal: new AbortController().signal, logs: () => entries, version: "0", window: noWindow });
describe("logs", () => {
it("returns the last LOG_TAIL entries when no tail is given", async () => {

View File

@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import type { MainHandler } from "../handler";
export const window: MainHandler<"window"> = async ({ visible }, ctx) => {
if (visible === true) {
await ctx.window.show();
} else if (visible === false) {
ctx.window.hide();
}
return { visible: ctx.window.visible() };
};

View File

@ -14,7 +14,6 @@ import { DapiHttpServer } from "./http";
const PORT = 3200 + Math.floor(Math.random() * 500);
const PATH = "/mcp";
let server: DapiHttpServer;
let firstConnections = 0;
let sessionsCreated = 0;
beforeAll(async () => {
@ -22,7 +21,6 @@ beforeAll(async () => {
host: "127.0.0.1",
port: PORT,
path: PATH,
onFirstConnection: () => void firstConnections++,
createSession() {
sessionsCreated++;
const session = new McpServer({ name: "test", version: "0.0.0" }, { instructions: "Test instructions." });
@ -60,12 +58,11 @@ describe("mcp over http", () => {
await client.close();
});
it("gives each client its own session and reports the first once", async () => {
it("gives each client its own session", async () => {
const before = sessionsCreated;
const a = await connect();
const b = await connect();
expect(sessionsCreated - before).toBe(2);
expect(firstConnections).toBe(1);
await a.close();
await b.close();
});

View File

@ -23,16 +23,8 @@ export type HttpServerDeps = {
path: string;
/** A fresh MCP server with the tools and resources registered, one per session. */
createSession(): McpServer;
/**
* Called once, when the first session initializes — unless that session
* says `?client=chat` in its URL: the in-app chat is watched by the user,
* so it must not switch the app into remote-controlled mode.
*/
onFirstConnection(): void;
};
const CHAT_CLIENT = "chat";
type Session = { transport: StreamableHTTPServerTransport; server: McpServer };
const SESSION_HEADER = "mcp-session-id";
@ -41,7 +33,6 @@ export class DapiHttpServer {
private readonly deps: HttpServerDeps;
private readonly sessions = new Map<string, Session>();
private server: Server | null = null;
private connected = false;
constructor(deps: HttpServerDeps) {
this.deps = deps;
@ -98,14 +89,14 @@ export class DapiHttpServer {
}
// No session: either an `initialize`, which the transport answers with
// a new id, or a stray request it rejects with 400.
await this.open(url.searchParams.get("client")).transport.handleRequest(req, res);
await this.open().transport.handleRequest(req, res);
} catch (error) {
console.error("[dapi] http request failed:", error);
if (!res.headersSent) res.writeHead(500, { "content-type": "text/plain" }).end("Internal error");
}
}
private open(client: string | null): Session {
private open(): Session {
const server = this.deps.createSession();
const hosts = [this.deps.host, "localhost"];
const transport = new StreamableHTTPServerTransport({
@ -114,10 +105,6 @@ export class DapiHttpServer {
allowedHosts: [...hosts, ...hosts.map((host) => `${host}:${this.deps.port}`)],
onsessioninitialized: (id) => {
this.sessions.set(id, session);
if (!this.connected && client !== CHAT_CLIENT) {
this.connected = true;
this.deps.onFirstConnection();
}
},
onsessionclosed: (id) => {
this.sessions.delete(id);

View File

@ -2,10 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join } from "node:path";
import { afterAll, describe, expect, it } from "vitest";
import { afterAll, describe, expect, it, vi } from "vitest";
import { present, toCallToolResult } from "./present";
const dir = mkdtempSync(join(tmpdir(), "dapi-present-"));
@ -25,7 +25,7 @@ describe("present", () => {
});
it("picks a fresh temp directory when none is given", async () => {
const presented = await present("media_grab", { path: "/c.mp4" }, [{ timecode: "0f", png: png(3) }]);
const presented = await present("grab", { path: "/c.mp4" }, [{ timecode: "0f", png: png(3) }]);
const { path } = (presented.output as { images: Array<{ path: string }> }).images[0]!;
expect(path).toMatch(/dapi-grab-.*[\\/]0f\.png$/);
rmSync(join(path, ".."), { recursive: true, force: true });
@ -33,20 +33,20 @@ describe("present", () => {
it("keeps a preview's other fields next to the path", async () => {
const file = join(dir, "wave.png");
const presented = await present("media_waveform", { path: "/c.mp4", output: file }, { png: png(4), silences: [{ start: 0, end: 1 }] });
const presented = await present("waveform", { path: "/c.mp4", output: file }, { png: png(4), silences: [{ start: 0, end: 1 }] });
expect(presented.output).toEqual({ path: file, silences: [{ start: 0, end: 1 }] });
});
it("writes a preview or transcript into an output that names an existing directory", async () => {
const out = join(dir, "into");
mkdirSync(out, { recursive: true });
const preview = await present("media_waveform", { path: "/c.mp4", output: out }, { png: png(7), silences: [] });
const preview = await present("waveform", { path: "/c.mp4", output: out }, { png: png(7), silences: [] });
const previewPath = (preview.output as { path: string }).path;
expect(dirname(previewPath)).toBe(out);
expect(basename(previewPath)).toMatch(/^dapi-waveform-.*\.png$/);
expect(readFileSync(previewPath)).toEqual(Buffer.from(png(7)));
const transcript = await present("media_transcribe", { path: "/c.mp4", output: out }, { segments: [] });
const transcript = await present("transcribe", { path: "/c.mp4", output: out }, { segments: [] });
const transcriptPath = (transcript.output as { path: string }).path;
expect(transcriptPath).toMatch(/dapi-transcript-.*\.json$/);
expect(JSON.parse(readFileSync(transcriptPath, "utf8"))).toEqual({ segments: [] });
@ -64,56 +64,11 @@ describe("present", () => {
it("writes a transcript to a file, unchanged, and returns its path and size", async () => {
const file = join(dir, "talk.json");
const segments = [{ text: "Hi there", words: [{ text: "Hi", start: 0, end: 0.2 }, { text: "there", start: 0.3, end: 0.6 }] }];
const presented = await present("media_transcribe", { path: "/c.mp4", output: file }, { segments });
const presented = await present("transcribe", { path: "/c.mp4", output: file }, { segments });
expect(presented).toEqual({ output: { path: file, segments: 1, words: 2 }, images: [] });
expect(JSON.parse(readFileSync(file, "utf8"))).toEqual({ segments });
});
it("writes a segment's mask where output says and its picture to the temp dir", async () => {
const found = {
model: "tiny" as const, frameRate: 30, start: 0, end: 1, frames: 30, bbox: null, area: 0, score: 1, iou: 0.9, lost: [], weak: [],
};
const file = join(dir, "masks", "skater.mask");
const presented = await present("media_segment", { path: "/c.mp4", time: 0, output: file }, { png: png(8), mask: png(9, 4), ...found });
const output = presented.output as { image: string; path: string };
expect(output).toEqual({ image: output.image, path: file, ...found });
expect(output.image).toMatch(/dapi-segment-.*\.png$/);
expect(readFileSync(file)).toEqual(Buffer.from(png(9, 4)));
expect(presented.images).toEqual([{ path: output.image, png: png(8) }]);
});
it("keeps the path of a mask the app put into the library, and writes none for a preview", async () => {
const found = {
model: "tiny" as const, frameRate: 30, start: 1, end: 1.033, frames: 1, bbox: null, area: 0, score: 1, iou: 0.9, lost: [], weak: [],
};
const stored = await present("media_segment", { path: "/c.mp4", time: 1 }, { png: png(8), path: "/p/assets/masks/a.mask", src: "masks/a.mask", ...found });
expect(stored.output).toMatchObject({ path: "/p/assets/masks/a.mask", src: "masks/a.mask" });
const preview = await present("media_segment", { path: "/c.mp4", time: 1, preview: true }, { png: png(8), ...found });
expect(preview.output).not.toHaveProperty("path");
});
it("has no picture for a track still running in the background", async () => {
const span = { model: "tiny" as const, frameRate: 30, start: 0, end: 2, frames: 60 };
const running = await present("media_segment", { path: "/c.mp4", time: 1 }, { path: "/p/assets/masks/a.mask", src: "masks/a.mask", state: "tracking" as const, ...span });
expect(running).toEqual({ output: { path: "/p/assets/masks/a.mask", src: "masks/a.mask", state: "tracking", ...span }, images: [] });
});
it("writes a done track's contact sheet once, inline only the first time context reports it", async () => {
const row = {
id: "track-1", src: "masks/a.mask", video: "a.mp4", state: "done" as const, progress: 1,
model: "tiny" as const, frameRate: 30, start: 0, end: 2, frames: 60, bbox: null, area: 0, score: 1, iou: 0.9, lost: [], weak: [],
};
const base = { rootDir: "/p", projectDir: "/p/a", currentTime: null, fontFamilies: [], generations: [] };
const first = await present("context", {}, { ...base, masks: [{ ...row, png: png(8) }] });
const image = (first.output as { masks: { image: string }[] }).masks[0]!.image;
expect(image).toMatch(/dapi-segment-.*\.png$/);
expect(first.images).toEqual([{ path: image, png: png(8) }]);
expect(first.output).toEqual({ ...base, masks: [{ ...row, image }] });
const again = await present("context", {}, { ...base, masks: [{ ...row, png: png(8) }] });
expect(again).toEqual({ output: { ...base, masks: [{ ...row, image }] }, images: [] });
});
it("passes other results through untouched", async () => {
expect(await present("check", { id: "x" }, { stats: {}, issues: [] })).toEqual({ output: { stats: {}, issues: [] }, images: [] });
});
@ -134,3 +89,92 @@ describe("toCallToolResult", () => {
expect(toCallToolResult({ output: {}, images: large }).content).toHaveLength(1);
});
});
describe("present a generation job", () => {
const job = (id: string, status: string, assets: Array<Record<string, unknown>>) => ({
job: { id, status, credits: 4, etaSeconds: 10, etaRemainingSeconds: null, error: null, assets },
saveTo: null as string | null,
});
const file = (filename: string) => ({ url: `https://files.test/${filename}`, filename, mimeType: "image/png", size: 8 });
it("passes a job still running through as the API has it", async () => {
const running = job("j-running", "running", []);
expect((await present("job", { id: "j-running" }, running)).output).toEqual(running.job);
});
it("downloads a succeeded job's files once, to the output numbered and with the made extension", async () => {
const fetch = vi.fn(async (url: string) => new Response(new Uint8Array([url.length])));
vi.stubGlobal("fetch", fetch);
try {
const out = join(dir, "generated", "fox.jpg");
const done = { ...job("j-done", "succeeded", [file("red-fox.png"), file("red-fox-2.png")]), saveTo: out };
const first = await present("job", { id: "j-done" }, done);
const again = await present("job", { id: "j-done" }, done);
const assets = (first.output as { assets: Array<Record<string, unknown>> }).assets;
expect(assets.map((asset) => asset.path)).toEqual([join(dir, "generated", "fox-1.png"), join(dir, "generated", "fox-2.png")]);
expect(assets[0]).not.toHaveProperty("url");
expect(assets[0]).toMatchObject({ filename: "red-fox.png", mimeType: "image/png" });
expect(again.output).toEqual(first.output);
expect(fetch).toHaveBeenCalledTimes(2);
} finally {
vi.unstubAllGlobals();
}
});
it("writes a single file at the output, over a file already there", async () => {
vi.stubGlobal("fetch", async () => new Response("new"));
try {
const out = join(dir, "single.png");
writeFileSync(out, "old");
const presented = await present("job", { id: "j-one" }, { ...job("j-one", "succeeded", [file("x.png")]), saveTo: out });
expect((presented.output as { assets: Array<{ path: string }> }).assets[0]!.path).toBe(out);
expect(readFileSync(out, "utf8")).toBe("new");
} finally {
vi.unstubAllGlobals();
}
});
it("saves into a directory of the job's own under the temp dir when no directory is given", async () => {
vi.stubGlobal("fetch", async () => new Response(new Uint8Array([1])));
try {
const presented = await present("generate", { model: "flux-2-klein" }, job("j-temp", "succeeded", [file("a.png")]));
const path = (presented.output as { assets: Array<{ path: string }> }).assets[0]!.path;
expect(path).toMatch(/dapi-generate-j-temp[\\/]a\.png$/);
rmSync(dirname(path), { recursive: true, force: true });
} finally {
vi.unstubAllGlobals();
}
});
it("leaves files the renderer saved into the library as they are", async () => {
const saved = job("j-lib", "succeeded", [{ filename: "a.png", path: "/p/assets/a.png", src: "a.png" }]);
expect((await present("job", { id: "j-lib" }, saved)).output).toEqual(saved.job);
});
it("writes a local job's files from their bytes, to the output, once", async () => {
const out = join(dir, "masks", "skater.mask");
const done = { ...job("local-mask", "succeeded", [{ filename: "Tracking 1.mask", mimeType: "", size: 4, bytes: png(9, 4) }]), saveTo: out };
const first = await present("job", { id: "local-mask" }, done);
writeFileSync(out, "edited since");
const again = await present("job", { id: "local-mask" }, done);
const assets = (first.output as { assets: Array<Record<string, unknown>> }).assets;
expect(assets).toEqual([{ filename: "Tracking 1.mask", mimeType: "", size: 4, path: out }]);
expect(again.output).toEqual(first.output);
expect(readFileSync(out, "utf8")).toBe("edited since");
});
it("writes a local job's picture to the temp dir, inline only the first time, and names it in its details", async () => {
const details = { frameRate: 30, start: 1, end: 1.033, frames: 1, bbox: null, lost: [] };
const preview = { ...job("local-preview", "succeeded", []), image: png(8) };
preview.job = { ...preview.job, details } as typeof preview.job;
const first = await present("generate", { model: "sam-2.1" }, preview);
const image = (first.output as { details: { image: string } }).details.image;
expect(image).toMatch(/dapi-local-preview\.png$/);
expect(first.output).toEqual({ ...preview.job, details: { ...details, image } });
expect(first.images).toEqual([{ path: image, png: png(8) }]);
expect(readFileSync(image)).toEqual(Buffer.from(png(8)));
const again = await present("job", { id: "local-preview" }, preview);
expect(again).toEqual({ output: first.output, images: [] });
rmSync(image, { force: true });
});
});

View File

@ -5,11 +5,13 @@
import { existsSync, realpathSync } from "node:fs";
import { mkdir, mkdtemp, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { basename, dirname, join } from "node:path";
import { randomUUID } from "node:crypto";
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import type { TimecodedImage, ToolArgs, ToolName, ToolOutput, ToolResult } from "@diffusionstudio/dapi";
import { generatedPath } from "@diffusionstudio/dapi";
import type { GenerationResult, TimecodedImage, ToolArgs, ToolName, ToolOutput, ToolResult } from "@diffusionstudio/dapi";
/** A file the tool wrote, kept in memory only long enough to decide whether to inline it. */
export type WrittenImage = { path: string; png: Uint8Array };
@ -38,20 +40,21 @@ export async function present(name: ToolName, args: unknown, result: unknown): P
switch (name) {
case "capture":
return presentImages(result as ToolResult<"capture">, (args as ToolArgs<"capture">).output, "capture");
case "media_grab":
return presentImages(result as ToolResult<"media_grab">, (args as ToolArgs<"media_grab">).output, "grab");
case "media_filmstrip":
return presentPreview(result as ToolResult<"media_filmstrip">, (args as ToolArgs<"media_filmstrip">).output, "filmstrip");
case "media_waveform":
return presentPreview(result as ToolResult<"media_waveform">, (args as ToolArgs<"media_waveform">).output, "waveform");
case "grab":
return presentImages(result as ToolResult<"grab">, (args as ToolArgs<"grab">).output, "grab");
case "filmstrip":
return presentPreview(result as ToolResult<"filmstrip">, (args as ToolArgs<"filmstrip">).output, "filmstrip");
case "waveform":
return presentPreview(result as ToolResult<"waveform">, (args as ToolArgs<"waveform">).output, "waveform");
case "screenshot":
return presentScreenshot(result as ToolResult<"screenshot">, (args as ToolArgs<"screenshot">).output);
case "media_transcribe":
return presentTranscript(result as ToolResult<"media_transcribe">, (args as ToolArgs<"media_transcribe">).output);
case "media_segment":
return presentSegment(result as ToolResult<"media_segment">, (args as ToolArgs<"media_segment">).output);
case "context":
return presentContext(result as ToolResult<"context">);
case "transcribe":
return presentTranscript(result as ToolResult<"transcribe">, (args as ToolArgs<"transcribe">).output);
case "generate":
if ((args as ToolArgs<"generate">).estimate) return { output: result, images: [] };
return presentJob(result as GenerationResult);
case "job":
return presentJob(result as GenerationResult);
default:
return { output: result, images: [] };
}
@ -110,56 +113,73 @@ async function presentScreenshot(result: ToolResult<"screenshot">, output: strin
return { output: presented, images: [{ path, png: result.png }] };
}
async function presentTranscript(transcript: ToolResult<"media_transcribe">, output: string | undefined): Promise<Presented> {
async function presentTranscript(transcript: ToolResult<"transcribe">, output: string | undefined): Promise<Presented> {
const path = await singleFilePath(output, `dapi-transcript-${randomUUID()}.json`);
await writeFile(path, JSON.stringify(transcript, null, 2));
const words = transcript.segments.reduce((sum, segment) => sum + segment.words.length, 0);
const presented: ToolOutput<"media_transcribe"> = { path, segments: transcript.segments.length, words };
const presented: ToolOutput<"transcribe"> = { path, segments: transcript.segments.length, words };
return { output: presented, images: [] };
}
/** Files of succeeded jobs saved to disk, by job id: the first poll that sees a job succeed saves them, the rest reuse the paths. */
const jobFiles = new Map<string, Promise<string[]>>();
/** Pictures of local jobs, by job id: each is written to the temp dir, and shown inline, the first poll it comes with. */
const jobImages = new Map<string, string>();
/**
* The picture always goes to the temp dir; `output` is where the mask goes.
* A mask the renderer put into the project's library comes with its path; one
* that comes as bytes is written here, to `output` or the temp dir. A track
* still running in the background has no picture yet (see `presentContext`).
* A job's files bound for disk are saved once it has succeeded — downloaded
* from their `url`, or written from the `bytes` a local model made — to
* `saveTo` (see `generatedPath`; a file already there is written over, as the
* other tools' outputs are) or under their own names into a directory of the
* job's own under the temp dir, and their `url` or `bytes` is swapped for the
* `path`. Files the renderer saved into the library arrive with their paths.
* A local job's picture goes to the temp dir, named in `details.image`.
*/
async function presentSegment(result: ToolResult<"media_segment">, output: string | undefined): Promise<Presented> {
const { png, mask, ...found } = result;
let path = found.path;
if (mask) {
path = await singleFilePath(output, `dapi-mask-${randomUUID()}.mask`);
await writeFile(path, mask);
}
async function presentJob({ job, saveTo, image }: GenerationResult): Promise<Presented> {
const images: WrittenImage[] = [];
let image: string | undefined;
if (png) {
image = join(tempDir(), `dapi-segment-${randomUUID()}.png`);
await writeFile(image, png);
images.push({ path: image, png });
let shown = job;
if (image) {
let path = jobImages.get(job.id);
if (path === undefined) {
path = join(tempDir(), `dapi-${job.id}.png`);
await writeFile(path, image);
jobImages.set(job.id, path);
images.push({ path, png: image });
}
shown = { ...job, details: { ...job.details, image: path } };
}
const presented: ToolOutput<"media_segment"> = { ...found, ...(image === undefined ? {} : { image }), ...(path === undefined ? {} : { path }) };
return { output: presented, images };
const pending = job.assets.filter((file) => file.url !== undefined || file.bytes !== undefined);
if (job.status !== "succeeded" || pending.length === 0) return { output: shown, images };
let paths = jobFiles.get(job.id);
if (!paths) {
const temp = join(tempDir(), `dapi-generate-${job.id}`);
const targets = job.assets.map((file, i) =>
saveTo === null ? join(temp, basename(file.filename)) : generatedPath(saveTo, file.filename, i, job.assets.length),
);
paths = saveAll(job.assets, targets);
paths.catch(() => jobFiles.delete(job.id));
jobFiles.set(job.id, paths);
}
const written = await paths;
const assets = job.assets.map(({ url: _url, bytes: _bytes, ...file }, i) => ({ ...file, path: written[i] }));
return { output: { ...shown, assets }, images };
}
/** Contact sheets of background tracks already written, by track id: each is written, and shown inline, once. */
const trackSheets = new Map<string, string>();
/** A done track's contact sheet goes to the temp dir the first poll it shows up in, and arrives inline with that poll. */
async function presentContext(result: ToolResult<"context">): Promise<Presented> {
const images: WrittenImage[] = [];
const masks: ToolOutput<"context">["masks"] = [];
for (const { png, ...row } of result.masks) {
let image = trackSheets.get(row.id);
if (png && image === undefined) {
image = join(tempDir(), `dapi-segment-${randomUUID()}.png`);
await writeFile(image, png);
trackSheets.set(row.id, image);
images.push({ path: image, png });
}
masks.push(image === undefined ? row : { ...row, image });
async function saveAll(files: GenerationResult["job"]["assets"], targets: string[]): Promise<string[]> {
for (const [i, file] of files.entries()) {
await mkdir(dirname(targets[i]!), { recursive: true });
await writeFile(targets[i]!, file.bytes ?? (await download(file.url!, file.filename)));
}
return { output: { ...result, masks }, images };
return targets;
}
async function download(url: string, filename: string): Promise<Uint8Array> {
const response = await fetch(url);
if (!response.ok) throw new Error(`Could not download ${filename} (${response.status})`);
return new Uint8Array(await response.arrayBuffer());
}
function screenshotFilename(taken: Date, attempt: number): string {

View File

@ -3,9 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { randomUUID } from "node:crypto";
import { app, BrowserWindow, ipcMain } from "electron";
import { ipcMain } from "electron";
import { DAPI_WIRE, DapiError } from "@diffusionstudio/dapi";
import type { BrowserWindow } from "electron";
import type { DapiCall, DapiCancel, DapiReply } from "@diffusionstudio/dapi";
type InFlight = {
@ -13,15 +14,33 @@ type InFlight = {
reject(error: Error): void;
};
/** Where renderer calls find their window. */
export type RendererHost = {
/** The main window, created hidden when there is none; `fresh` when this call created it. */
acquire(): { window: BrowserWindow; fresh: boolean };
/** The project the editor last had open, to reopen in a window created for a call. */
lastProject(): string | null;
};
/**
* Runs renderer tools from main: one `dapi:call` per request, answered by
* `dapi:reply`, or `dapi:cancel` if the caller gives up. Calls wait for the
* current window to finish loading; a window that reloads or dies fails the
* calls it was answering.
* `dapi:reply`, or `dapi:cancel` if the caller gives up. There may be no
* window when a call arrives — it is only kept while something needs it — so
* a call creates one, and waits for it to load and to reopen the project the
* agent was working on. A window that reloads or dies fails the calls it was
* answering.
*/
export class RendererCalls {
private readonly host: RendererHost;
private readonly inFlight = new Map<string, InFlight>();
private window: BrowserWindow | null = null;
private readonly tracked = new WeakSet<BrowserWindow>();
// Settles once the current window has loaded, and reopened the project
// when it was created for a call. Every call waits on it.
private ready: Promise<BrowserWindow> | null = null;
constructor(host: RendererHost) {
this.host = host;
}
start(): void {
ipcMain.on(DAPI_WIRE.REPLY, (_event, reply: DapiReply) => {
@ -31,14 +50,47 @@ export class RendererCalls {
if (reply.ok) call.resolve(reply.data);
else call.reject(reply.error.code ? new DapiError(reply.error.code, reply.error.message) : new Error(reply.error.message));
});
app.on("browser-window-created", (_event, window) => this.track(window));
const windows = BrowserWindow.getAllWindows();
if (windows.length > 0) this.track(windows[windows.length - 1]!);
}
async call(tool: string, args: unknown, signal: AbortSignal): Promise<unknown> {
const window = await this.ready();
const window = await this.window(tool);
if (window.isDestroyed()) {
throw new Error("The app window closed before replying");
}
return this.send(window, tool, args, signal);
}
// The window to answer on. One created here is tracked, and gets the last
// project reopened — unless the call is itself an `open` — since the calls
// that follow assume the project the agent opened is still open. A project
// that no longer opens is left to the call to report.
private window(tool: string): Promise<BrowserWindow> {
const { window, fresh } = this.host.acquire();
// Loaded before, but it may have reloaded since.
if (!fresh && this.ready) {
return this.ready.then(loaded);
}
this.track(window);
const dir = fresh && tool !== "open" ? this.host.lastProject() : null;
const ready = loaded(window).then(async (loadedWindow) => {
if (dir) {
await this.send(loadedWindow, "open", { dir }, new AbortController().signal).catch((error: Error) =>
console.warn(`[dapi] could not reopen ${dir}: ${error.message}`),
);
}
return loadedWindow;
});
this.ready = ready;
// A window that failed to load is not waited on again: the next call
// finds out afresh.
ready.catch(() => {
if (this.ready === ready) this.ready = null;
});
return ready;
}
private send(window: BrowserWindow, tool: string, args: unknown, signal: AbortSignal): Promise<unknown> {
const id = randomUUID();
return new Promise((resolve, reject) => {
const onAbort = () => {
@ -62,12 +114,13 @@ export class RendererCalls {
}
private track(window: BrowserWindow): void {
this.window = window;
if (this.tracked.has(window)) return;
this.tracked.add(window);
const fail = (why: string) => () => this.failAll(why);
window.webContents.on("did-start-loading", fail("The app reloaded before replying"));
window.webContents.on("render-process-gone", fail("The app's renderer crashed"));
window.on("closed", () => {
if (this.window === window) this.window = null;
this.ready = null;
this.failAll("The app window closed before replying");
});
}
@ -78,33 +131,33 @@ export class RendererCalls {
for (const call of calls) call.reject(new Error(message));
}
// Resolves with the current window once it has finished loading.
private ready(timeoutMs = 30000): Promise<BrowserWindow> {
const window = this.window;
if (!window || window.isDestroyed()) return Promise.reject(new Error("The app has no window"));
if (window.webContents.isCrashed()) return Promise.reject(new Error("The app's renderer crashed"));
if (!window.webContents.isLoading()) return Promise.resolve(window);
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
cleanup();
reject(new Error("The app did not become ready in time"));
}, timeoutMs);
const cleanup = () => {
clearTimeout(timer);
window.webContents.off("did-finish-load", onLoad);
window.webContents.off("did-fail-load", onFail);
};
const onLoad = () => {
cleanup();
resolve(window);
};
const onFail = () => {
cleanup();
reject(new Error("The app failed to load"));
};
window.webContents.on("did-finish-load", onLoad);
window.webContents.on("did-fail-load", onFail);
});
}
}
// Resolves with the window once it has finished loading.
function loaded(window: BrowserWindow, timeoutMs = 30000): Promise<BrowserWindow> {
if (window.isDestroyed()) return Promise.reject(new Error("The app has no window"));
if (window.webContents.isCrashed()) return Promise.reject(new Error("The app's renderer crashed"));
if (!window.webContents.isLoading()) return Promise.resolve(window);
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
cleanup();
reject(new Error("The app did not become ready in time"));
}, timeoutMs);
const cleanup = () => {
clearTimeout(timer);
window.webContents.off("did-finish-load", onLoad);
window.webContents.off("did-fail-load", onFail);
};
const onLoad = () => {
cleanup();
resolve(window);
};
const onFail = () => {
cleanup();
reject(new Error("The app failed to load"));
};
window.webContents.on("did-finish-load", onLoad);
window.webContents.on("did-fail-load", onFail);
});
}

View File

@ -3,15 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { MCP_HOST, MCP_PATH, MCP_PORT, tools } from "@diffusionstudio/dapi";
import { MCP_HOST, MCP_PATH, MCP_PORT, isDapiError, tools } from "@diffusionstudio/dapi";
import { mainHandlers } from "./handlers";
import { DapiHttpServer } from "./http";
import { instructions } from "./docs";
import { RendererCalls } from "./renderer-calls";
import { serveCatalog } from "./tools-session";
import type { TrackProps } from "@diffusionstudio/api-contract";
import type { LogEntry } from "@diffusionstudio/dapi";
import type { MainContext, MainToolName } from "./handler";
import type { AppWindow, MainContext, MainToolName } from "./handler";
import type { RendererHost } from "./renderer-calls";
/**
* The name the server introduces itself with, and so the namespace an agent
@ -25,10 +27,15 @@ export type DapiServerDeps = {
version: string;
/** The app's console buffer, for `logs` and `report`. */
logs(): LogEntry[];
/** Called once, on the first connection: an agent is driving, so the UI may step back. */
onFirstConnection(): void;
/** The main window: where renderer tools run, and what `window` shows and hides. */
window: AppWindow & RendererHost & {
/** Keeps the window from idling out while a call runs; returns the release. */
hold(): () => void;
};
/** The staged docs: INSTRUCTIONS.md, their path, and the skill headers, all for every session. Null when not staged. */
docsDir: string | null;
/** Told about every finished call, as `tool_called` analytics props. */
onToolCall?(props: TrackProps): void;
};
/**
@ -40,13 +47,14 @@ export type DapiServerDeps = {
*/
export class DapiServer {
private readonly deps: DapiServerDeps;
private readonly renderer = new RendererCalls();
private readonly renderer: RendererCalls;
private readonly http: DapiHttpServer;
private instructionsText: string | null = null;
private httpReady: Promise<boolean> = Promise.resolve(false);
constructor(deps: DapiServerDeps) {
this.deps = deps;
this.renderer = new RendererCalls(deps.window);
for (const tool of tools) {
if (tool.environment === "main" && !(tool.name in mainHandlers)) {
throw new Error(`Main-process tool "${tool.name}" has no handler`);
@ -57,7 +65,6 @@ export class DapiServer {
port: MCP_PORT,
path: MCP_PATH,
createSession: () => this.createSession(),
onFirstConnection: () => deps.onFirstConnection(),
});
}
@ -94,16 +101,36 @@ export class DapiServer {
// `name` is the machine identity, and matches the key we write into agent
// configs; `title` is what a client shows a person.
const session = new McpServer({ name: SERVER_NAME, title: "Diffusion Studio", version: this.deps.version }, { instructions: this.instructionsText });
serveCatalog(session, (tool, args, signal) =>
tool.environment === "main" ?
this.runInMain(tool.name as MainToolName, args, signal)
: this.renderer.call(tool.name, args, signal),
);
serveCatalog(session, async (tool, args, signal) => {
const release = this.deps.window.hold();
const startedAt = performance.now();
// The failure's code (`not-found`, `busy`, …), never its message: messages name the user's files.
let error: string | undefined;
try {
return await (tool.environment === "main" ?
this.runInMain(tool.name as MainToolName, args, signal)
: this.renderer.call(tool.name, args, signal));
} catch (thrown) {
error = isDapiError(thrown) ? thrown.code : "error";
throw thrown;
} finally {
release();
const client = session.server.getClientVersion();
this.deps.onToolCall?.({
tool: tool.name,
client: client?.name,
client_version: client?.version,
ok: !error,
error,
duration_ms: Math.round(performance.now() - startedAt),
});
}
});
return session;
}
private runInMain(name: MainToolName, args: unknown, signal: AbortSignal): Promise<unknown> {
const ctx: MainContext = { signal, logs: this.deps.logs, version: this.deps.version };
const ctx: MainContext = { signal, logs: this.deps.logs, version: this.deps.version, window: this.deps.window };
// Each handler takes its own parsed args; the map's union type cannot
// express that pairing, so the call site widens.
return (mainHandlers[name] as (args: unknown, ctx: MainContext) => Promise<unknown>)(args, ctx);

View File

@ -9,6 +9,8 @@ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
import { JSON_SCHEMA_DIALECT, tools } from "@diffusionstudio/dapi";
import { serveCatalog } from "./tools-session";
const CONTEXT = { rootDir: null, projectDir: null, currentTime: null, fontFamilies: [] };
let client: Client;
const calls: Array<{ name: string; args: unknown }> = [];
@ -17,8 +19,8 @@ beforeAll(async () => {
serveCatalog(session, async (tool, args) => {
calls.push({ name: tool.name, args });
switch (tool.name) {
case "voices":
return { voices: [] };
case "context":
return CONTEXT;
case "check":
throw new Error("No project open — run open first");
default:
@ -54,9 +56,9 @@ describe("serveCatalog", () => {
expect(JSON.stringify(bad.content)).toContain("limit");
expect(calls.length).toBe(before);
const result = await client.callTool({ name: "voices", arguments: {} });
expect(result.structuredContent).toEqual({ voices: [] });
expect(calls.at(-1)).toEqual({ name: "voices", args: {} });
const result = await client.callTool({ name: "context", arguments: {} });
expect(result.structuredContent).toEqual(CONTEXT);
expect(calls.at(-1)).toEqual({ name: "context", args: {} });
});
it("returns a handler's failure as a readable error result, not a protocol error", async () => {

View File

@ -6,16 +6,9 @@
// canvas (renderer) and the edit writer (main). Types only, with no Node
// imports, so the renderer's program can include it without Node's types.
import type { InspectValue, PropValue, SerializedAssetRef } from "@diffusionstudio/jsx";
import type { InspectValue, PropValue } from "@diffusionstudio/jsx";
export type { PropValue, SerializedAssetRef };
/**
* A value an edit can carry: what a source spells as a literal, or a
* `generate.*` declaration in its wire form, spelled as the call that
* reproduces it (see `setProp`).
*/
export type EditValue = PropValue | SerializedAssetRef;
export type { PropValue };
export interface SourceContext {
/** Absolute path of the project folder. */
@ -37,7 +30,7 @@ export interface SourceContext {
export interface SourceSet {
kind: "set";
source: string;
props: Record<string, EditValue>;
props: Record<string, PropValue>;
text?: string;
}
@ -54,7 +47,7 @@ export interface SourceInsert {
source: string;
parent: string;
tag: string;
props: Record<string, EditValue>;
props: Record<string, PropValue>;
before?: string;
text?: string;
}
@ -94,7 +87,7 @@ export interface SourceRemove {
* one in `ids`. The first iteration keeps the body's own names, so it carries
* none.
*/
export type SourceIteration = Record<string, { props: Record<string, EditValue>; text?: string; pending?: string }>;
export type SourceIteration = Record<string, { props: Record<string, PropValue>; text?: string; pending?: string }>;
/**
* Replaces the `<For>`/`<Index>` around the element named by `source` with

View File

@ -9,11 +9,11 @@ import { join } from "node:path";
import { IndentationText, Project, SyntaxKind } from "ts-morph";
import { ID_ATTR, INSPECT_TAG, formatSource, isCompositionTag, isLoopTag, isSerializedAssetRef, isTransformType, parseSource } from "@diffusionstudio/jsx";
import { ID_ATTR, INSPECT_TAG, formatSource, isCompositionTag, isLoopTag, parseSource } from "@diffusionstudio/jsx";
import { writeFileAtomic } from "./atomic";
import type { PropValue, SerializedAssetRef } from "@diffusionstudio/jsx";
import type { PropValue } from "@diffusionstudio/jsx";
import type {
ArrowFunction,
FunctionExpression,
@ -28,7 +28,6 @@ import type {
export type * from "./edit-types";
import type {
EditValue,
SourceContext,
SourceEdit,
SourceInsert,
@ -121,8 +120,7 @@ const round = (value: number): number => Math.round(value * 100) / 100;
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
/** A prop value as the JavaScript that would have produced it. */
function literalText(value: PropValue | SerializedAssetRef): string {
if (isSerializedAssetRef(value)) return declarationText(value);
function literalText(value: PropValue): string {
if (typeof value === "string") return JSON.stringify(value);
if (typeof value === "number") return String(round(value));
if (typeof value === "boolean" || value === null) return String(value);
@ -152,46 +150,14 @@ const initializerText = (value: PropValue): string =>
? `"${value}"`
: `{${literalText(value)}}`;
/**
* A declaration's wire form as the call that reproduces it: `generate.<type>`
* over its options, or `transform.<type>` over its input, with declared
* inputs spelled as the nested calls they are.
*/
function declarationText(ref: SerializedAssetRef): string {
const { type, ...options } = ref.$asset;
if (isTransformType(type)) return `transform.${type}(${literalText((options as { input: EditValue }).input)})`;
return `generate.${type}(${literalText(options as Record<string, PropValue>)})`;
}
/** The namespaces a declaration is spelled with: what its file has to import. */
function declarationImports(ref: SerializedAssetRef, names = new Set<string>()): Set<string> {
const { type, ...options } = ref.$asset;
names.add(isTransformType(type) ? "transform" : "generate");
for (const value of Object.values(options)) {
for (const input of Array.isArray(value) ? value : [value]) {
if (isSerializedAssetRef(input)) declarationImports(input, names);
}
}
return names;
}
/**
* Writes a prop onto a tag as one would write it: `muted`, not `muted={true}`,
* and no attribute at all rather than `muted={false}`, since absence is what a
* boolean prop's false reads as. A declaration is spelled as the call that
* reproduces it — the caller makes sure its namespaces are imported (see
* `ensureDeclarationImports`).
* boolean prop's false reads as.
*/
function setProp(tag: JsxTag, name: string, value: EditValue): void {
function setProp(tag: JsxTag, name: string, value: PropValue): void {
const attribute = attributeOf(tag, name);
if (isSerializedAssetRef(value)) {
const initializer = `{${declarationText(value)}}`;
if (attribute) attribute.setInitializer(initializer);
else tag.addAttribute({ name, initializer });
return;
}
if (value === true) {
if (attribute) attribute.removeInitializer();
else tag.addAttribute({ name });
@ -207,45 +173,6 @@ function setProp(tag: JsxTag, name: string, value: EditValue): void {
else tag.addAttribute({ name, initializer: initializerText(value) });
}
/** Where `generate` and `transform` come from — the module every project authors against. */
const DECLARATION_MODULE = "@diffusionstudio/jsx";
/**
* Makes sure the namespaces a declaration is spelled with are in scope once
* it has been written into the file: added to the module's existing import,
* or as an import of their own after the last one — or above the first
* statement, past the file's header comments, when there are no imports at
* all. Idempotent.
*/
function ensureDeclarationImports(sourceFile: SourceFile, ref: SerializedAssetRef): void {
for (const name of declarationImports(ref)) ensureNamedImport(sourceFile, name);
}
function ensureNamedImport(sourceFile: SourceFile, name: string): void {
const declarations = sourceFile.getImportDeclarations();
const importable = declarations.find(
(declaration) =>
declaration.getModuleSpecifierValue() === DECLARATION_MODULE &&
!declaration.isTypeOnly() &&
!declaration.getNamespaceImport(),
);
if (importable) {
const named = importable.getNamedImports();
if (named.some((specifier) => specifier.getName() === name && !specifier.getAliasNode())) return;
importable.addNamedImport(name);
return;
}
const statement = `import { ${name} } from "${DECLARATION_MODULE}";`;
const last = declarations.at(-1);
if (last) sourceFile.insertText(last.getEnd(), `\n${statement}`);
else {
const first = sourceFile.getStatements()[0];
sourceFile.insertText(first ? first.getStart() : 0, `${statement}\n\n`);
}
}
/**
* Text content as JSX spells it: bare when JSX would read it back verbatim,
* otherwise as a string expression (JSX collapses whitespace around line
@ -487,14 +414,8 @@ function reindent(text: string, from: string, to: string): string {
.join("\n");
}
/**
* Whether an expression is a value rather than a way of computing one. A
* declaration call over values is one too: it is what the writer spells a
* declaration as, so it is an initializer the writer may also overwrite.
*/
/** Whether an expression is a value rather than a way of computing one. */
function isLiteral(node: Node): boolean {
if (isDeclarationCall(node)) return true;
if (
node.isKind(SyntaxKind.StringLiteral) ||
node.isKind(SyntaxKind.NumericLiteral) ||
@ -528,29 +449,11 @@ function isLiteral(node: Node): boolean {
return false;
}
/** The namespaces a declaration call is made through. */
const DECLARATION_NAMESPACES = new Set(["generate", "transform"]);
/**
* A `generate.*` or `transform.*` call over literals — a nested declaration
* among them. One whose argument computes anything is authored reactivity,
* like any expression.
*/
function isDeclarationCall(node: Node): boolean {
const call = node.asKind(SyntaxKind.CallExpression);
const callee = call?.getExpression().asKind(SyntaxKind.PropertyAccessExpression);
if (!call || !callee || !callee.getExpression().isKind(SyntaxKind.Identifier)) return false;
if (!DECLARATION_NAMESPACES.has(callee.getExpression().getText())) return false;
const args = call.getArguments();
return args.length === 1 && isLiteral(args[0]!);
}
// ---------------------------------------------------------------------------
// Files
/** Every project source file, project-relative and `/`-separated. */
async function sourceFiles(dir: string, prefix = ""): Promise<string[]> {
export async function sourceFiles(dir: string, prefix = ""): Promise<string[]> {
let entries;
try {
entries = await readdir(prefix ? join(dir, ...prefix.split("/")) : dir, { withFileTypes: true });
@ -858,7 +761,6 @@ class SourceWriter {
// the canvas already shows the edit, and an export and the next open
// render the file, so a prop left as it was would move back.
setProp(tag, name, value);
if (isSerializedAssetRef(value)) ensureDeclarationImports(sourceFile, value);
wrote = true;
}
@ -955,7 +857,6 @@ class SourceWriter {
insertChild(sourceFile, parent, child, before);
for (const [name, value] of Object.entries(edit.props)) {
setProp(findTag(sourceFile, id)!, name, value);
if (isSerializedAssetRef(value)) ensureDeclarationImports(sourceFile, value);
}
ids[edit.source] = formatSource(file, id);
return true;
@ -1195,7 +1096,6 @@ class SourceWriter {
}
for (const [name, value] of Object.entries(record.props)) {
setProp(found(), name, value);
if (isSerializedAssetRef(value)) ensureDeclarationImports(sourceFile, value);
}
const element = elementOf(found());

View File

@ -0,0 +1,64 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Code editors a project folder can be opened in. A project is a folder of
// JSX, so editing it by hand is a real way of working on it, and the app's
// watcher puts whatever the editor saves on the canvas.
import { app } from "electron";
import { execFile, spawn } from "node:child_process";
import { isAbsolute } from "node:path";
export type EditorId = "vscode" | "cursor" | "zed";
export type EditorInfo = { id: EditorId; label: string };
/**
* The editors offered, in menu order. Each is found by the URL scheme it
* registers with the OS when installed: asking who handles it answers both
* whether the editor is there and where, on macOS and Windows alike, without
* knowing where anyone keeps their applications.
*/
const EDITORS: Array<EditorInfo & { protocol: string }> = [
{ id: "vscode", label: "VS Code", protocol: "vscode://" },
{ id: "cursor", label: "Cursor", protocol: "cursor://" },
{ id: "zed", label: "Zed", protocol: "zed://" },
];
/** Where the app handling `protocol` lives (the .app on macOS, the .exe on Windows), or null when none does. */
async function handlerPath(protocol: string): Promise<string | null> {
try {
return (await app.getApplicationInfoForProtocol(protocol)).path || null;
} catch {
return null;
}
}
/** The editors installed here, in menu order. */
export async function installedEditors(): Promise<EditorInfo[]> {
const found = await Promise.all(EDITORS.map(async (editor) => ((await handlerPath(editor.protocol)) ? editor : null)));
return found.filter((editor) => editor !== null).map(({ id, label }) => ({ id, label }));
}
/** Opens the folder `dir` in the editor `id`. */
export async function openInEditor(id: EditorId, dir: string): Promise<void> {
const editor = EDITORS.find((candidate) => candidate.id === id);
if (!editor) throw new Error(`Unknown editor "${id}".`);
if (!isAbsolute(dir)) throw new Error(`The folder must be an absolute path (got "${dir}").`);
const path = await handlerPath(editor.protocol);
if (!path) throw new Error(`${editor.label} is not installed.`);
if (process.platform === "darwin") {
await new Promise<void>((resolve, reject) => {
execFile("/usr/bin/open", ["-a", path, dir], (error) => (error ? reject(error) : resolve()));
});
return;
}
// Windows: the editor's own executable takes a folder to open, and outlives the app.
const child = spawn(path, [dir], { detached: true, stdio: "ignore" });
child.on("error", (error) => console.error(`[editors] could not start ${editor.label}:`, error));
child.unref();
}

View File

@ -1,18 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Whether an agent has connected since launch. Once one has, the UI steps
// back: file writes from tools are not echoed as edits, and the window may
// stay hidden. Set by the MCP server on its first connection; read wherever
// behaviour depends on who is driving.
let headless = false;
export function isHeadless(): boolean {
return headless;
}
export function enableHeadless(): void {
headless = true;
}

View File

@ -0,0 +1,136 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Projects from before generation was removed are pointed at what their
// declarations produced. The keys below are in the shape the generation code
// wrote them: the request, defaults applied, inputs by asset id.
import { tmpdir } from "node:os";
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { migrateGenerations } from "./legacy-generations";
const FILE = "index.tsx";
const asset = (id: string, path: string, key?: string) => ({
id,
path,
source: `assets/${path}`,
type: "IMAGE",
mimeType: "image/png",
createdAt: "2026-01-01T00:00:00.000Z",
...(key ? { generation: { key, id: "run" } } : {}),
});
const HERO_KEY = JSON.stringify({ type: "image", model: "flux", prompt: "A neon city", aspectRatio: "16:9", seed: 7, refIds: [] });
const MOTION_KEY = JSON.stringify({ type: "video", model: "kling", prompt: "push in", aspectRatio: "16:9", duration: 5, audio: false, seed: 3, startFrameId: "hero01" });
const UPSCALE_KEY = JSON.stringify({ type: "upscale", inputId: "photo1" });
const MANIFEST = {
version: 1,
folders: [],
assets: [
asset("hero01", "generated/A neon city.png", HERO_KEY),
asset("motion", "generated/push in.mp4", MOTION_KEY),
asset("photo1", "photos/me.png"),
asset("upsc01", "generated/me (Upscaled).png", UPSCALE_KEY),
asset("capt01", "generated/Captions 1.json", "transcript:v1:intro:123"),
asset("capt02", "generated/Captions 2.json", "transcript:v1:outro:0"),
// A failed generation's record: no bytes, so no answer.
{ id: "fail01", path: "generated/a fox", type: "IMAGE", createdAt: "2026-01-01", generation: { key: "x" }, state: "error" },
],
};
let dir: string;
const written: string[] = [];
beforeEach(async () => {
dir = await mkdtemp(join(tmpdir(), "legacy-generations-test-"));
written.length = 0;
});
afterEach(async () => {
await rm(dir, { recursive: true, force: true });
});
async function migrate(source: string, manifest: unknown = MANIFEST): Promise<string> {
await writeFile(join(dir, FILE), source);
await migrateGenerations({ dir, onWrite: (file) => written.push(file) }, manifest);
return readFile(join(dir, FILE), "utf8");
}
describe("migrateGenerations", () => {
it("points declarations at the assets they made, chains and consts included, and drops the import", async () => {
const text = await migrate(`import { For } from "solid-js";
import { generate, transform } from "@diffusionstudio/jsx";
const hero = generate.image({ prompt: "A neon city", aspectRatio: "16:9", seed: 7 });
const motion = generate.video({ prompt: "push in", startFrame: hero, seed: 3 });
export default () => (
<scene id="intro">
<video id="a" src={motion} />
<image id="b" src={transform.upscale("photos/me.png")} />
</scene>
);
`);
expect(text).toContain(`const hero = "generated/A neon city.png";`);
expect(text).toContain(`const motion = "generated/push in.mp4";`);
expect(text).toContain(`<image id="b" src="generated/me (Upscaled).png" />`);
expect(text).not.toContain("@diffusionstudio/jsx");
expect(text).toContain(`import { For } from "solid-js";`);
expect(written).toEqual([FILE]);
});
it("keeps a declaration nothing matches beside an empty source, so the project still loads", async () => {
const text = await migrate(`import { generate } from "@diffusionstudio/jsx";
export default () => <image id="c" src={generate.image({ prompt: "never made", seed: 1 })} />;
`);
expect(text).toContain(`src={"" /* no generated asset matched; generation was removed: generate.image({ prompt: "never made", seed: 1 }) */}`);
expect(text).not.toContain("import { generate }");
});
it("does not take a key whose recorded fields differ from what the call spells", async () => {
const text = await migrate(`import { generate } from "@diffusionstudio/jsx";
export default () => <image id="c" src={generate.image({ prompt: "A neon city", seed: 8 })} />;
`);
expect(text).not.toContain("A neon city.png");
});
it("gives a src-less caption the transcript of its scene and seed", async () => {
const text = await migrate(`export default () => (
<stage>
<scene id="intro"><captions id="c1" preset="classic" seed={123} /></scene>
<scene id="outro"><Captions id="c2" /></scene>
<scene id="other"><captions id="c3" /></scene>
</stage>
);
`);
expect(text).toContain(`<captions id="c1" preset="classic" src="generated/Captions 1.json" />`);
expect(text).toContain(`<Captions src="generated/Captions 2.json" id="c2" />`);
// No transcript was ever made for this scene: left as it was.
expect(text).toContain(`<captions id="c3" />`);
});
it("writes nothing to a migrated project, or without a readable library", async () => {
const source = `import { generate } from "@diffusionstudio/jsx";
export default () => <image id="c" src={generate.image({ prompt: "A neon city", seed: 7 })} />;
`;
expect(await migrate(source, null)).toBe(source);
expect(written).toEqual([]);
const migrated = await migrate(source);
expect(migrated).toContain(`src="generated/A neon city.png"`);
written.length = 0;
await migrateGenerations({ dir, onWrite: (file) => written.push(file) }, MANIFEST);
expect(written).toEqual([]);
});
});

View File

@ -0,0 +1,509 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* A one-time rewrite of projects written before generation was removed from
* the JSX. Those projects declare assets with `generate.*` / `transform.*`
* calls and caption scenes with a `<captions>` that has no `src`; neither
* loads any more. What they produced is still in the library: every asset a
* generation landed as carries its `generation.key` in `assets.yml`, the
* request as it was sent. So each declaration is matched against those keys
* and replaced by the library path of the asset it made, and each `src`-less
* `<captions>` gets the transcript its scene was given.
*
* Runs before every compile and writes nothing to a project with nothing left
* to migrate. A declaration that matches no asset is replaced by an empty
* source with the call kept beside it in a comment, so the project loads and
* nothing the user wrote is lost. Delete this file once projects from before
* the removal no longer need opening.
*/
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { Project, SyntaxKind } from "ts-morph";
import { ID_ATTR } from "@diffusionstudio/jsx";
import { writeFileAtomic } from "./atomic";
import { sourceFiles } from "./edit";
import type { CallExpression, JsxOpeningElement, JsxSelfClosingElement, Node, SourceFile } from "ts-morph";
import type { SourceContext } from "./edit-types";
/** The module the declarations were imported from. */
const JSX_MODULE = "@diffusionstudio/jsx";
/** Defaults the generation applied, and so baked into its key, when the call left them out. */
const DEFAULTS: Record<string, Record<string, unknown>> = {
image: { aspectRatio: "16:9" },
video: { aspectRatio: "16:9", duration: 5, audio: false },
};
/**
* Fields whose defaults lived in the app's model lists rather than here: when
* the call leaves one out, any value in the key is taken to be the default.
*/
const FREE_WHEN_OMITTED = new Set(["model", "voice"]);
type Namespace = "generate" | "transform";
/** A `generate.*` / `transform.*` call, with its argument read as a value. */
interface Declaration {
namespace: Namespace;
type: string;
node: CallExpression;
argument: unknown;
}
/** A value the source computes rather than spells; a declaration over one cannot be matched. */
const UNKNOWN = Symbol("unknown");
interface ManifestEntry {
id: string;
path: string;
key?: string;
}
/** What the library knows: entries newest first, as the manifest lists them. */
class Library {
private readonly entries: ManifestEntry[];
public constructor(entries: ManifestEntry[]) {
this.entries = entries;
}
/** The id of the asset an input named: an id, or a library path. */
public idOf(input: string): string | undefined {
const path = normalizePath(input);
return this.entries.find((entry) => entry.id === input || entry.path === path)?.id;
}
/** The newest asset whose generation key, parsed, satisfies `matches`. */
public generated(matches: (key: Record<string, unknown>) => boolean): ManifestEntry | undefined {
for (const entry of this.entries) {
if (!entry.key?.startsWith("{")) continue;
try {
const key = JSON.parse(entry.key) as unknown;
if (key && typeof key === "object" && matches(key as Record<string, unknown>)) return entry;
} catch {
// Not a key this migration knows how to read.
}
}
return undefined;
}
/** The transcript a scene was given under `key`. */
public byKey(key: string): ManifestEntry | undefined {
return this.entries.find((entry) => entry.key === key);
}
}
/** Library entries that have bytes and a generation key; anything else is no answer. */
function readEntries(manifest: unknown): ManifestEntry[] {
const assets = (manifest as { assets?: unknown } | null)?.assets;
if (!Array.isArray(assets)) return [];
return assets.flatMap((record): ManifestEntry[] => {
if (!record || typeof record !== "object") return [];
const r = record as Record<string, unknown>;
if (typeof r.id !== "string" || typeof r.path !== "string" || typeof r.source !== "string") return [];
const generation = r.generation as { key?: unknown } | undefined;
const key = typeof generation?.key === "string" ? generation.key : undefined;
return [{ id: r.id, path: normalizePath(r.path), key }];
});
}
const normalizePath = (path: string): string =>
path.replace(/\\/g, "/").split("/").filter((part) => part && part !== ".").join("/");
/** Whether the project might hold anything to migrate; saves parsing the rest. */
const mayNeedMigration = (text: string): boolean => text.includes(JSX_MODULE) || /<captions\b/i.test(text);
/**
* Rewrites every source file of the project that still declares generations
* or `src`-less captions. Returns the project-relative files it wrote.
*/
export async function migrateGenerations(context: SourceContext, manifest: unknown): Promise<string[]> {
// Without a readable library every declaration would look unmatched.
if (!Array.isArray((manifest as { assets?: unknown } | null)?.assets)) return [];
const library = new Library(readEntries(manifest));
const project = new Project({ useInMemoryFileSystem: true, skipLoadingLibFiles: true });
const written: string[] = [];
for (const path of await sourceFiles(context.dir)) {
const absolute = join(context.dir, ...path.split("/"));
let text: string;
try {
text = await readFile(absolute, "utf8");
} catch {
continue;
}
if (!mayNeedMigration(text)) continue;
const next = migrateText(project, path, text, library);
if (next === text) continue;
context.onWrite?.(path, next);
await writeFileAtomic(absolute, next);
written.push(path);
}
if (written.length) console.log(`[projects] migrated generated assets in ${written.join(", ")}`);
return written;
}
/** The file's text with its declarations and captions migrated; the same text when there is nothing to do. */
function migrateText(project: Project, path: string, text: string, library: Library): string {
const sourceFile = project.createSourceFile(`/${path}`, text, { overwrite: true });
try {
// A file mid-edit is not one to rewrite.
if (project.getProgram().getSyntacticDiagnostics(sourceFile).length) return text;
const edits = [...declarationEdits(sourceFile, library), ...captionEdits(sourceFile, library)];
if (!edits.length) return text;
let next = text;
for (const edit of outermost(edits).sort((a, b) => b.start - a.start)) {
next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
}
return dropUnusedImports(project, path, next);
} finally {
project.removeSourceFile(sourceFile);
}
}
interface TextEdit {
start: number;
end: number;
text: string;
}
/** Edits not inside another: replacing an outer call takes the calls inside it along. */
function outermost(edits: TextEdit[]): TextEdit[] {
return edits.filter((edit) => !edits.some((other) => other !== edit
&& other.start <= edit.start && edit.end <= other.end
&& (other.start !== edit.start || other.end !== edit.end)));
}
// ---------------------------------------------------------------------------
// Declarations
/** The local names `generate` and `transform` were imported under. */
function namespaces(sourceFile: SourceFile): Map<string, Namespace> {
const names = new Map<string, Namespace>();
for (const declaration of sourceFile.getImportDeclarations()) {
if (declaration.getModuleSpecifierValue() !== JSX_MODULE) continue;
for (const specifier of declaration.getNamedImports()) {
const imported = specifier.getName();
if (imported !== "generate" && imported !== "transform") continue;
names.set(specifier.getAliasNode()?.getText() ?? imported, imported);
}
}
return names;
}
function declarationEdits(sourceFile: SourceFile, library: Library): TextEdit[] {
const names = namespaces(sourceFile);
if (!names.size) return [];
const declarations = new Map<CallExpression, Declaration>();
const read = (node: Node, seen: Set<Node>): unknown => readValue(node, names, declarations, seen);
for (const call of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)) {
read(call, new Set());
}
const paths = new Map<Declaration, string | undefined>();
const resolve = (declaration: Declaration): string | undefined => {
if (!paths.has(declaration)) paths.set(declaration, match(declaration, library, resolve));
return paths.get(declaration);
};
return [...declarations.values()].map((declaration) => {
const path = resolve(declaration);
return replacement(declaration.node, path, path === undefined ? declaration.node.getText() : undefined);
});
}
/**
* A node read as the value it spells: literals, arrays, object literals, a
* const it names (followed in this file), or a declaration. `UNKNOWN` for
* anything the source computes.
*/
function readValue(
node: Node,
names: Map<string, Namespace>,
declarations: Map<CallExpression, Declaration>,
seen: Set<Node>,
): unknown {
const read = (child: Node): unknown => readValue(child, names, declarations, seen);
if (node.isKind(SyntaxKind.ParenthesizedExpression)) return read(node.getExpression());
if (node.isKind(SyntaxKind.AsExpression) || node.isKind(SyntaxKind.SatisfiesExpression)) return read(node.getExpression());
if (node.isKind(SyntaxKind.StringLiteral) || node.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)) return node.getLiteralValue();
if (node.isKind(SyntaxKind.NumericLiteral)) return node.getLiteralValue();
if (node.isKind(SyntaxKind.TrueKeyword)) return true;
if (node.isKind(SyntaxKind.FalseKeyword)) return false;
if (node.isKind(SyntaxKind.NullKeyword)) return null;
if (node.isKind(SyntaxKind.Identifier) && node.getText() === "undefined") return undefined;
if (node.isKind(SyntaxKind.PrefixUnaryExpression) && node.getOperatorToken() === SyntaxKind.MinusToken) {
const operand = read(node.getOperand());
return typeof operand === "number" ? -operand : UNKNOWN;
}
if (node.isKind(SyntaxKind.ArrayLiteralExpression)) {
const items = node.getElements().map(read);
return items.includes(UNKNOWN) ? UNKNOWN : items;
}
if (node.isKind(SyntaxKind.ObjectLiteralExpression)) {
const object: Record<string, unknown> = {};
for (const property of node.getProperties()) {
if (property.isKind(SyntaxKind.PropertyAssignment)) {
const name = property.getNameNode();
if (name.isKind(SyntaxKind.ComputedPropertyName)) return UNKNOWN;
const key = name.isKind(SyntaxKind.StringLiteral) ? name.getLiteralValue() : name.getText();
object[key] = read(property.getInitializerOrThrow());
} else if (property.isKind(SyntaxKind.ShorthandPropertyAssignment)) {
object[property.getName()] = read(property.getNameNode());
} else {
return UNKNOWN;
}
}
return Object.values(object).includes(UNKNOWN) ? UNKNOWN : object;
}
// A const, followed to its initializer once: a cycle reads as unknown.
if (node.isKind(SyntaxKind.Identifier)) {
const initializer = constInitializer(node);
if (!initializer || seen.has(initializer)) return UNKNOWN;
seen.add(initializer);
return read(initializer);
}
if (node.isKind(SyntaxKind.CallExpression)) {
const known = declarations.get(node);
if (known) return known;
const callee = node.getExpression().asKind(SyntaxKind.PropertyAccessExpression);
const namespace = callee && names.get(callee.getExpression().getText());
if (!callee || !namespace || !callee.getExpression().isKind(SyntaxKind.Identifier)) return UNKNOWN;
const [argument] = node.getArguments();
const declaration: Declaration = {
namespace,
type: callee.getName(),
node,
argument: argument ? read(argument) : UNKNOWN,
};
declarations.set(node, declaration);
return declaration;
}
return UNKNOWN;
}
/** The initializer of the top-level or block-scoped `const` an identifier names, in its own file. */
function constInitializer(identifier: Node): Node | undefined {
const symbol = identifier.getSymbol();
const declaration = symbol?.getDeclarations()[0]?.asKind(SyntaxKind.VariableDeclaration);
if (!declaration || declaration.getVariableStatement()?.getDeclarationKind() !== "const") return undefined;
if (!declaration.getNameNode().isKind(SyntaxKind.Identifier)) return undefined;
return declaration.getInitializer();
}
const isDeclaration = (value: unknown): value is Declaration =>
typeof value === "object" && value !== null && "namespace" in value && "node" in value;
/**
* The library path of the asset a declaration made, or undefined when no
* generation key matches it. Inputs are matched first, by id, which is how
* the key recorded them.
*/
function match(
declaration: Declaration,
library: Library,
resolve: (declaration: Declaration) => string | undefined,
): string | undefined {
const idOf = (input: unknown): string | undefined => {
if (typeof input === "string") return library.idOf(input);
if (isDeclaration(input)) {
const path = resolve(input);
return path === undefined ? undefined : library.idOf(path);
}
return undefined;
};
const { type, argument } = declaration;
if (declaration.namespace === "transform") {
const inputId = idOf(argument);
if (inputId === undefined) return undefined;
return library.generated((key) => key.type === type && key.inputId === inputId && Object.keys(key).length === 2)?.path;
}
if (!argument || typeof argument !== "object" || isDeclaration(argument) || Array.isArray(argument)) return undefined;
const options = argument as Record<string, unknown>;
if (typeof options.prompt !== "string") return undefined;
// What the key must hold, field by field; `undefined` means it must not hold the field.
const expected: Record<string, unknown> = { type, ...DEFAULTS[type] };
for (const [name, value] of Object.entries(options)) {
if (name === "refs" || name === "startFrame" || name === "endFrame") continue;
expected[name] = value;
}
expected.seed = options.seed;
switch (type) {
case "image": {
const refs = Array.isArray(options.refs) ? options.refs : [];
const refIds = refs.map(idOf);
if (refIds.includes(undefined)) return undefined;
expected.refIds = refIds;
break;
}
case "video": {
for (const [option, field] of [["startFrame", "startFrameId"], ["endFrame", "endFrameId"]] as const) {
if (options[option] === undefined) {
expected[field] = undefined;
continue;
}
const id = idOf(options[option]);
if (id === undefined) return undefined;
expected[field] = id;
}
break;
}
case "audio":
expected.duration = options.duration;
break;
case "voice":
break;
default:
return undefined;
}
return library.generated((key) => Object.entries(expected).every(([name, value]) => {
if (value === undefined) return FREE_WHEN_OMITTED.has(name) || !(name in key);
return JSON.stringify(key[name]) === JSON.stringify(value);
}))?.path;
}
/**
* The edit putting `path` where the call was: an attribute's `{call}` becomes
* `"path"`, anything else the string literal. With no path, an empty source
* stands in and the call is kept beside it in a comment.
*/
function replacement(call: CallExpression, path: string | undefined, unmatched?: string): TextEdit {
const comment = unmatched === undefined
? ""
: ` /* no generated asset matched; generation was removed: ${unmatched.replace(/\*\//g, "* /")} */`;
const literal = JSON.stringify(path ?? "");
const expression = call.getParent()?.asKind(SyntaxKind.JsxExpression);
if (expression?.getParent()?.isKind(SyntaxKind.JsxAttribute)) {
if (!comment && path !== undefined && !/["&\p{Cc}\u2028\u2029]/u.test(path)) {
return { start: expression.getStart(), end: expression.getEnd(), text: literal };
}
return { start: call.getStart(), end: call.getEnd(), text: literal + comment };
}
return { start: call.getStart(), end: call.getEnd(), text: literal + comment };
}
// ---------------------------------------------------------------------------
// Captions
type JsxTag = JsxOpeningElement | JsxSelfClosingElement;
const lower = (tag: JsxTag): string => tag.getTagNameNode().getText().toLowerCase();
const idOf = (tag: JsxTag): string | undefined =>
tag.getAttribute(ID_ATTR)?.asKind(SyntaxKind.JsxAttribute)?.getInitializer()?.asKind(SyntaxKind.StringLiteral)?.getLiteralValue();
/**
* A `<captions>` without a `src` used to transcribe its scene, keyed by the
* scene's id and the caption's `seed`. The transcript is in the library under
* that key; the caption is pointed at it and loses the `seed`.
*/
function captionEdits(sourceFile: SourceFile, library: Library): TextEdit[] {
const edits: TextEdit[] = [];
const tags: JsxTag[] = [
...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),
...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),
];
for (const tag of tags) {
if (lower(tag) !== "captions") continue;
const attributes = tag.getAttributes();
if (tag.getAttribute("src") || attributes.some((attribute) => attribute.isKind(SyntaxKind.JsxSpreadAttribute))) continue;
const sceneId = enclosingSceneId(tag);
if (sceneId === undefined) continue;
const seedAttribute = tag.getAttribute("seed")?.asKind(SyntaxKind.JsxAttribute);
let seed = 0;
if (seedAttribute) {
const value = seedAttribute.getInitializer()?.asKind(SyntaxKind.JsxExpression)?.getExpression();
const literal = value?.asKind(SyntaxKind.NumericLiteral)?.getLiteralValue();
if (literal === undefined) continue;
seed = literal;
}
const transcript = library.byKey(`transcript:v1:${sceneId}:${seed}`);
if (!transcript) continue;
const src = `src=${JSON.stringify(transcript.path)}`;
if (seedAttribute) {
edits.push({ start: seedAttribute.getStart(), end: seedAttribute.getEnd(), text: src });
} else {
const at = tag.getTagNameNode().getEnd();
edits.push({ start: at, end: at, text: ` ${src}` });
}
}
return edits;
}
/** The id of the `<scene>` element a tag sits inside, in the same JSX tree. */
function enclosingSceneId(tag: JsxTag): string | undefined {
for (const ancestor of tag.getAncestors()) {
const opening = ancestor.asKind(SyntaxKind.JsxElement)?.getOpeningElement();
if (opening && lower(opening) === "scene") return idOf(opening);
}
return undefined;
}
// ---------------------------------------------------------------------------
// Imports
/** Takes `generate` / `transform` out of the imports once nothing uses them. */
function dropUnusedImports(project: Project, path: string, text: string): string {
const sourceFile = project.createSourceFile(`/${path}`, text, { overwrite: true });
try {
for (const declaration of sourceFile.getImportDeclarations()) {
if (declaration.getModuleSpecifierValue() !== JSX_MODULE) continue;
let removed = false;
for (const specifier of declaration.getNamedImports()) {
const name = specifier.getName();
if (name !== "generate" && name !== "transform") continue;
const local = specifier.getAliasNode()?.getText() ?? name;
const used = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier)
.some((identifier) => identifier.getText() === local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));
if (used) continue;
specifier.remove();
removed = true;
}
// Only an import this emptied goes; one that imported nothing by name was never ours.
if (removed && !declaration.getNamedImports().length && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) {
declaration.remove();
}
}
return sourceFile.getFullText();
} finally {
project.removeSourceFile(sourceFile);
}
}

View File

@ -12,6 +12,8 @@
import type { LogEntry, ScreenshotResult } from "@diffusionstudio/dapi";
import type { SourceEdit, WriteResult } from "./edit-types";
import type { AgentId } from "./mcp-config";
import type { EditorId, EditorInfo } from "./editors";
import type { MissingProjectChoice, SaveAction } from "./projects";
export const MAIN_WIRE = {
REQUEST: "main:request",
@ -30,26 +32,33 @@ export const MAIN_CHANNELS = {
// Renderer→Main requests
APP_OPEN_EXTERNAL: "app:open-external",
APP_SHOW_IN_FOLDER: "app:show-in-folder",
ANALYTICS_TRACK: "analytics:track",
APP_EDITORS_LIST: "app:editors-list",
APP_OPEN_IN_EDITOR: "app:open-in-editor",
ANALYTICS_CONFIGURE: "analytics:configure",
AUTH_GET_PENDING_CALLBACK: "auth:get-pending-callback",
CHECKOUT_GET_PENDING_CALLBACK: "checkout:get-pending-callback",
WINDOW_IS_FULLSCREEN: "window:is-fullscreen",
WINDOW_SET_COLOR_MODE: "window:set-color-mode",
WINDOW_CAPTURE: "window:capture",
WINDOW_SET_BUSY: "window:set-busy",
WINDOW_SHOW: "window:show",
CLIPBOARD_PATHS: "clipboard:paths",
FILE_TRANSFER: "file:transfer",
FILE_WRITE_OPEN: "file:write-open",
FILE_WRITE_CHUNK: "file:write-chunk",
FILE_WRITE_CLOSE: "file:write-close",
FILE_WRITE_ABORT: "file:write-abort",
LOGS_GET: "logs:get",
PROJECTS_PICK_ROOT: "projects:pick-root",
PROJECTS_PICK_FOLDER: "projects:pick-folder",
PROJECTS_DEFAULT_ROOT: "projects:default-root",
PROJECTS_SCAN: "projects:scan",
PROJECTS_GET: "projects:get",
PROJECTS_INIT: "projects:init",
PROJECTS_RESOLVE: "projects:resolve",
PROJECTS_FIND_MOVED: "projects:find-moved",
PROJECTS_ASK_MISSING: "projects:ask-missing",
PROJECTS_CREATE: "projects:create",
PROJECTS_PICK_SAVE: "projects:pick-save",
PROJECTS_SAVE: "projects:save",
PROJECTS_MOVE: "projects:move",
PROJECTS_RENAME: "projects:rename",
PROJECTS_DUPLICATE: "projects:duplicate",
PROJECTS_DELETE: "projects:delete",
@ -91,7 +100,7 @@ export type ProjectInfo = {
* since — `PROJECTS_RESOLVE` is what gives one out.
*/
id: string;
/** Folder name. Renaming the project moves it, so it is not the identity. */
/** Folder name. The user can move or rename it, so it is not the identity. */
name: string;
/** Human name from package.json `displayName` (falls back to the folder name). */
displayName: string;
@ -103,6 +112,11 @@ export type ProjectInfo = {
modifiedAt: string;
/** birthtime of the folder, ISO string. */
createdAt: string;
/**
* Whether the folder is a draft's: in the app's drafts folder, named after
* the id, until the user saves it somewhere of their choosing.
*/
draft: boolean;
};
export type CompileResult =
@ -110,6 +124,8 @@ export type CompileResult =
export type { SourceEdit, WriteResult };
export type { AgentId };
export type { EditorId, EditorInfo };
export type { MissingProjectChoice };
// One agent the settings page lists: whether it is set up on this machine,
// whether its config already carries the app's MCP entry, and — for the
@ -175,10 +191,9 @@ export type MainRequestMap = {
request: { url: string };
response: void;
};
// A product event, posted to Umami by main (the renderer's script is inert
// in Electron).
[MAIN_CHANNELS.ANALYTICS_TRACK]: {
request: { event: string; data?: Record<string, string | number | boolean> };
// Where main sends events and as whom: on launch and every auth change.
[MAIN_CHANNELS.ANALYTICS_CONFIGURE]: {
request: { apiUrl: string; token: string | null };
response: void;
};
[MAIN_CHANNELS.AUTH_GET_PENDING_CALLBACK]: {
@ -192,6 +207,9 @@ export type MainRequestMap = {
[MAIN_CHANNELS.WINDOW_IS_FULLSCREEN]: { request: void; response: boolean };
[MAIN_CHANNELS.WINDOW_SET_COLOR_MODE]: { request: { mode: "light" | "dark" }; response: void };
[MAIN_CHANNELS.WINDOW_CAPTURE]: { request: void; response: ScreenshotResult };
[MAIN_CHANNELS.WINDOW_SET_BUSY]: { request: { busy: boolean }; response: void };
[MAIN_CHANNELS.WINDOW_SHOW]: { request: void; response: void };
[MAIN_CHANNELS.CLIPBOARD_PATHS]: { request: void; response: string[] };
[MAIN_CHANNELS.FILE_TRANSFER]: {
request: { selector: string; absolutePath: string };
response: void;
@ -217,25 +235,20 @@ export type MainRequestMap = {
request: { path: string };
response: void;
};
[MAIN_CHANNELS.LOGS_GET]: { request: void; response: LogEntry[] };
[MAIN_CHANNELS.PROJECTS_PICK_ROOT]: {
// The code editors installed here that a folder can be opened in.
[MAIN_CHANNELS.APP_EDITORS_LIST]: {
request: void;
response: string | null;
response: EditorInfo[];
};
[MAIN_CHANNELS.APP_OPEN_IN_EDITOR]: {
request: { id: EditorId; dir: string };
response: void;
};
[MAIN_CHANNELS.LOGS_GET]: { request: void; response: LogEntry[] };
[MAIN_CHANNELS.PROJECTS_PICK_FOLDER]: {
request: void;
response: string | null;
};
[MAIN_CHANNELS.PROJECTS_DEFAULT_ROOT]: {
request: void;
response: string | null;
};
// Every project folder directly under `root`: what the app puts on its
// list when `root` is chosen as the projects root.
[MAIN_CHANNELS.PROJECTS_SCAN]: {
request: { root: string };
response: ProjectInfo[];
};
[MAIN_CHANNELS.PROJECTS_GET]: {
request: { dir: string };
response: ProjectInfo | null;
@ -248,11 +261,35 @@ export type MainRequestMap = {
request: { dir: string };
response: ProjectInfo | null;
};
// The project `id` in a folder beside `dir`, which no longer holds it (a
// folder renamed or moved in Finder); null when none does.
[MAIN_CHANNELS.PROJECTS_FIND_MOVED]: {
request: { dir: string; id: string };
response: ProjectInfo | null;
};
// Asks what to do about a project whose folder can't be found.
[MAIN_CHANNELS.PROJECTS_ASK_MISSING]: {
request: { displayName: string; dir: string };
response: MissingProjectChoice;
};
// A new project, as a draft called "Untitled" until it is saved.
[MAIN_CHANNELS.PROJECTS_CREATE]: {
request: { root: string; displayName: string };
request: void;
response: ProjectInfo;
};
// Where to save a draft, or move a saved project; `name` fills the picker.
[MAIN_CHANNELS.PROJECTS_PICK_SAVE]: {
request: { dir: string; name: string; startIn: string | null; action: SaveAction };
response: string | null;
};
[MAIN_CHANNELS.PROJECTS_SAVE]: {
request: { dir: string; target: string };
response: ProjectInfo;
};
[MAIN_CHANNELS.PROJECTS_MOVE]: {
request: { dir: string; target: string };
response: ProjectInfo;
};
// Renames the project: `displayName` in the record, and the folder with it.
[MAIN_CHANNELS.PROJECTS_RENAME]: {
request: { dir: string; displayName: string };
response: ProjectInfo;

View File

@ -8,31 +8,37 @@ import { existsSync } from "node:fs";
import { mkdir, open, rename, unlink } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import type { FileHandle } from "node:fs/promises";
import { updateElectronApp } from "update-electron-app";
import type { IUpdateInfo } from "update-electron-app";
import { makeUserNotifier, updateElectronApp } from "update-electron-app";
import { tempPathFor } from "./atomic";
import { DapiServer } from "./dapi/server";
import { agentChatEndpoint, deleteProjectChats, startAgentChat, stopAgentChat } from "./agent-chat";
import { agentChatEndpoint, configureAgentChat, deleteProjectChats, stopAgentChat } from "./agent-chat";
import { cliStatus, installCli, refreshCliShim, uninstallCli } from "./cli-install";
import { applyMcp, healMcpRegistrations, mcpStatus } from "./mcp-install";
import { enableHeadless } from "./headless";
import { trackEvent, trackInstall } from "./analytics";
import { configureAnalytics, countCanvasEdits, startAnalytics, track } from "./analytics";
import { setupAppMenu } from "./menu";
import { clipboardPaths } from "./clipboard";
import { installedEditors, openInEditor } from "./editors";
import { AppTray } from "./tray";
import { WindowHost } from "./window-host";
import { handleSquirrelEvent } from "./squirrel";
import { mainBridge } from "./main-manager";
import { MAIN_CHANNELS } from "./main-channels";
import {
compileProject,
createProject,
defaultRoot,
deleteProject,
duplicateProject,
getProject,
askAboutMissingProject,
findMovedProject,
initProject,
pickFolder,
pickRoot,
pickSaveLocation,
renameProject,
resolveProject,
scanProjects,
saveProject,
moveProject,
unwatchAll,
listEntries,
realPathEntry,
@ -52,6 +58,7 @@ import type { DeepLinkChannel } from "./main-channels";
import type { LogEntry } from "@diffusionstudio/dapi";
const DEV_URL = "http://localhost:5173";
const WINDOW_IDLE_MS = 10 * 60 * 1000;
const AUTH_PROTOCOL = "diffusion";
const MACOS_CORNER_RADIUS = 18;
const MACOS_BACKDROP = { blur: 80, red: 0.07, green: 0.07, blue: 0.07, alpha: 0.9 };
@ -105,13 +112,50 @@ function setColorMode(mode: "dark" | "light") {
mainWindow.setTitleBarOverlay({ ...WINDOWS_OVERLAY_COLORS[mode], height: WINDOWS_OVERLAY_HEIGHT });
}
if (app.isPackaged && !squirrelLaunch && !process.argv.includes("--hidden")) {
updateElectronApp({ repo: "diffusionstudio/editor" });
// A downloaded update is offered while the user has the window out; one that
// lands while the app runs in the background waits for the next show, since
// the app rarely quits on its own to apply it.
const notifyUser = makeUserNotifier();
let pendingUpdate: IUpdateInfo | null = null;
function offerUpdate() {
if (!pendingUpdate || !windows.visible()) return;
const info = pendingUpdate;
pendingUpdate = null;
notifyUser(info);
}
if (app.isPackaged && !squirrelLaunch) {
updateElectronApp({
repo: "diffusionstudio/editor",
onNotifyUser: function (info) {
pendingUpdate = info;
offerUpdate();
},
});
}
const openWrites = new Map<string, { handle: FileHandle; path: string; temp: string; reserved: boolean }>();
let mainWindow: BrowserWindow | null = null;
let lastProject: string | null = null;
const windows = new WindowHost({
create: createWindow,
idleMs: WINDOW_IDLE_MS,
onChange: () => {
tray.refresh();
offerUpdate();
},
});
const tray = new AppTray({
visible: () => windows.visible(),
active: () => windows.active(),
project: () => lastProject,
show: () => void windows.show(),
hide: () => windows.hide(),
});
// Deep links that arrived before the renderer could take them, keyed by the
// channel they belong to so auth and checkout never drain each other's link.
@ -133,12 +177,20 @@ function docsDir(): string | null {
}
// The MCP server agents and the diffusion CLI talk to. Started once the app is
// ready; the first connection switches the app into headless mode.
// ready; renderer tools create the window when there is none.
const dapi = new DapiServer({
version: app.getVersion(),
logs: () => logBuffer,
docsDir: docsDir(),
onFirstConnection: enableHeadless,
window: {
visible: () => windows.visible(),
show: () => windows.show(),
hide: () => windows.hide(),
acquire: () => windows.acquire(),
hold: () => windows.hold(),
lastProject: () => lastProject,
},
onToolCall: (props) => track("tool_called", props),
});
function pushLog(level: LogEntry["level"], message: string, source: string) {
@ -220,7 +272,8 @@ async function setFileInputFiles(selector: string, absolutePath: string) {
});
}
function createWindow(show = true) {
// The main window, not shown: WindowHost decides when it is.
function createWindow(): BrowserWindow {
const options: Electron.BrowserWindowConstructorOptions = {
show: false,
@ -260,10 +313,6 @@ function createWindow(show = true) {
mainWindow.once("ready-to-show", () => {
applyCornerRadius(MACOS_CORNER_RADIUS);
applyBackdrop();
if (show) {
mainWindow?.show();
}
});
mainWindow.on("show", () => {
@ -281,6 +330,7 @@ function createWindow(show = true) {
});
mainWindow.on("closed", () => {
mainWindow = null;
unwatchAll();
});
if (!app.isPackaged) {
@ -288,6 +338,8 @@ function createWindow(show = true) {
} else {
mainWindow.loadFile(join(app.getAppPath(), "web", "index.html"));
}
return mainWindow;
}
if (process.defaultApp && process.argv.length >= 2) {
@ -301,29 +353,31 @@ if (process.defaultApp && process.argv.length >= 2) {
if (squirrelLaunch) {
// Update.exe is at work; handleSquirrelEvent quits the app when it is done.
} else if (app.requestSingleInstanceLock()) {
if (isHiddenLaunch(process.argv)) {
app.dock?.hide();
}
app.on("second-instance", (_event, argv) => {
const url = findProtocolUrl(argv);
if (url) deliverDeepLink(url);
const hidden = isHiddenLaunch(argv);
if (mainWindow && !mainWindow.isDestroyed()) {
if (hidden) return;
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.show();
mainWindow.focus();
} else {
createWindow(!hidden);
if (url) {
deliverDeepLink(url);
}
if (!isHiddenLaunch(argv)) {
windows.show();
}
});
app.on("open-url", (event, url) => {
event.preventDefault();
deliverDeepLink(url);
windows.show();
});
mainBridge.handle(MAIN_CHANNELS.APP_OPEN_EXTERNAL, ({ url }) => shell.openExternal(url));
mainBridge.handle(MAIN_CHANNELS.APP_SHOW_IN_FOLDER, ({ path }) => shell.showItemInFolder(path));
mainBridge.handle(MAIN_CHANNELS.ANALYTICS_TRACK, ({ event, data }) => trackEvent(event, data));
mainBridge.handle(MAIN_CHANNELS.APP_EDITORS_LIST, () => installedEditors());
mainBridge.handle(MAIN_CHANNELS.APP_OPEN_IN_EDITOR, ({ id, dir }) => openInEditor(id, dir));
mainBridge.handle(MAIN_CHANNELS.ANALYTICS_CONFIGURE, (config) => configureAnalytics(config));
mainBridge.handle(MAIN_CHANNELS.AUTH_GET_PENDING_CALLBACK, () =>
takePendingDeepLink(MAIN_CHANNELS.AUTH_CALLBACK),
);
@ -332,6 +386,8 @@ if (squirrelLaunch) {
);
mainBridge.handle(MAIN_CHANNELS.WINDOW_IS_FULLSCREEN, () => mainWindow?.isFullScreen() ?? false);
mainBridge.handle(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, ({ mode }) => setColorMode(mode));
mainBridge.handle(MAIN_CHANNELS.WINDOW_SET_BUSY, ({ busy }) => windows.setBusy(busy));
mainBridge.handle(MAIN_CHANNELS.WINDOW_SHOW, () => windows.show());
mainBridge.handle(MAIN_CHANNELS.WINDOW_CAPTURE, async () => {
if (!mainWindow || mainWindow.isDestroyed()) throw new Error("No main window");
const image = await mainWindow.webContents.capturePage(undefined, { stayHidden: true });
@ -340,6 +396,7 @@ if (squirrelLaunch) {
// A plain Uint8Array over the PNG, so the renderer sees bytes and not a Buffer.
return { png: new Uint8Array(png.buffer, png.byteOffset, png.byteLength), width, height };
});
mainBridge.handle(MAIN_CHANNELS.CLIPBOARD_PATHS, () => clipboardPaths());
mainBridge.handle(MAIN_CHANNELS.LOGS_GET, () => logBuffer);
mainBridge.handle(MAIN_CHANNELS.AGENT_CHAT_ENDPOINT, () => agentChatEndpoint());
mainBridge.handle(MAIN_CHANNELS.MCP_STATUS, () => mcpStatus());
@ -347,25 +404,40 @@ if (squirrelLaunch) {
mainBridge.handle(MAIN_CHANNELS.CLI_STATUS, () => cliStatus());
mainBridge.handle(MAIN_CHANNELS.CLI_INSTALL, () => installCli());
mainBridge.handle(MAIN_CHANNELS.CLI_UNINSTALL, () => uninstallCli());
mainBridge.handle(MAIN_CHANNELS.PROJECTS_PICK_ROOT, () => pickRoot(mainWindow));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_PICK_FOLDER, () => pickFolder(mainWindow));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_DEFAULT_ROOT, () => defaultRoot(mainWindow));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_SCAN, ({ root }) => scanProjects(root));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_GET, ({ dir }) => getProject(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_INIT, ({ dir }) => initProject(mainWindow, dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_RESOLVE, ({ dir }) => resolveProject(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_CREATE, ({ root, displayName }) =>
createProject(root, displayName),
mainBridge.handle(MAIN_CHANNELS.PROJECTS_FIND_MOVED, ({ dir, id }) => findMovedProject(dir, id));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_ASK_MISSING, ({ displayName, dir }) =>
askAboutMissingProject(mainWindow, displayName, dir),
);
mainBridge.handle(MAIN_CHANNELS.PROJECTS_CREATE, () => createProject());
mainBridge.handle(MAIN_CHANNELS.PROJECTS_PICK_SAVE, ({ dir, name, startIn, action }) =>
pickSaveLocation(mainWindow, dir, name, startIn, action),
);
mainBridge.handle(MAIN_CHANNELS.PROJECTS_SAVE, ({ dir, target }) => saveProject(dir, target));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_MOVE, ({ dir, target }) => moveProject(dir, target));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_RENAME, ({ dir, displayName }) => renameProject(dir, displayName));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_DUPLICATE, ({ dir }) => duplicateProject(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_DELETE, ({ dir }) => deleteProject(dir).then(deleteProjectChats));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_COMPILE, ({ dir }) => compileProject(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_WRITE, ({ dir, edits }) => writeProject(dir, edits));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_WATCH, ({ dir }, event) =>
watchProject(BrowserWindow.fromWebContents(event.sender), dir),
);
mainBridge.handle(MAIN_CHANNELS.PROJECTS_UNWATCH, ({ dir }) => unwatchProject(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_WRITE, ({ dir, edits }) => {
countCanvasEdits(edits.map((edit) => edit.kind));
return writeProject(dir, edits);
});
mainBridge.handle(MAIN_CHANNELS.PROJECTS_WATCH, ({ dir }, event) => {
lastProject = dir;
tray.refresh();
watchProject(BrowserWindow.fromWebContents(event.sender), dir);
});
mainBridge.handle(MAIN_CHANNELS.PROJECTS_UNWATCH, ({ dir }) => {
if (lastProject === dir) {
lastProject = null;
tray.refresh();
}
unwatchProject(dir);
});
mainBridge.handle(MAIN_CHANNELS.PROJECTS_MANIFEST_READ, ({ dir }) => readManifest(dir));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_MANIFEST_WRITE, ({ dir, manifest }) => writeManifest(dir, manifest));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_CONFIG_READ, ({ dir }) => readConfig(dir));
@ -455,45 +527,38 @@ if (squirrelLaunch) {
if (url) deliverDeepLink(url);
dapi.start();
// The chat's sessions get the MCP server by URL; `?client=chat` keeps the
// app from switching into remote-controlled mode for them (see dapi/http).
// The chat's sessions get the MCP server by URL.
dapi.mcpUrl().then((url) =>
startAgentChat({
configureAgentChat({
dataDir: join(app.getPath("userData"), "agent-chat"),
mcpUrl: url ? `${url}?client=chat` : null,
mcpUrl: url,
version: app.getVersion(),
}),
);
refreshCliShim();
healMcpRegistrations();
trackInstall();
createWindow(!isHiddenLaunch(process.argv));
startAnalytics(windows);
tray.start();
// Opened by a person (Finder, Dock, Start menu): show the editor
if (!isHiddenLaunch(process.argv)) {
windows.show();
}
});
app.on("before-quit", () => {
unwatchAll();
stopAgentChat();
dapi.stop();
tray.destroy();
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
// No window is no reason to quit: the app keeps serving agents from the
// tray, and the window is destroyed whenever it idles out. Only Quit ends it.
app.on("window-all-closed", () => { });
app.on("activate", () => {
if (!mainWindow || mainWindow.isDestroyed()) {
createWindow();
return;
}
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.show();
mainWindow.focus();
});
// The Dock icon, or launching the app again while it runs.
app.on("activate", () => windows.show());
} else {
app.quit();
}

View File

@ -0,0 +1,98 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// A new project is a draft: made without asking, in the app's own folder,
// named after its id — until it is saved, which moves it where the user said
// and names it after the folder they chose.
import { tmpdir } from "node:os";
import { mkdir, mkdtemp, readdir, readFile, rm } from "node:fs/promises";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
let userData = "";
vi.mock("electron", () => ({
app: { isPackaged: false, getPath: (name: string) => (name === "userData" ? userData : tmpdir()) },
dialog: {},
shell: {},
ipcMain: { on: () => { } },
}));
const { createProject, draftsRoot, duplicateProject, moveProject, readManifest, saveProject, writeManifest } =
await import("./projects");
let root: string;
beforeEach(async () => {
root = await mkdtemp(join(tmpdir(), "drafts-test-"));
userData = join(root, "userData");
});
afterEach(async () => {
await rm(root, { recursive: true, force: true });
});
describe("drafts", () => {
it("creates a draft in the drafts folder, named after its id", async () => {
const project = await createProject();
expect(project.draft).toBe(true);
expect(project.dir).toBe(join(draftsRoot(), project.id));
expect(project.name).toBe(project.id);
expect(project.displayName).toBe("Untitled");
expect(project.entry).toBe("index.tsx");
});
it("duplicates a draft as a draft with an id of its own", async () => {
const source = await createProject();
const copy = await duplicateProject(source.dir);
expect(copy.draft).toBe(true);
expect(copy.id).not.toBe(source.id);
expect(copy.dir).toBe(join(draftsRoot(), copy.id));
});
it("saves a draft by moving it and naming it after the folder", async () => {
const draft = await createProject();
const target = join(root, "Saved", "My Ad");
const saved = await saveProject(draft.dir, target);
expect(saved).toMatchObject({ id: draft.id, dir: target, name: "My Ad", displayName: "My Ad", draft: false });
expect(await readdir(draftsRoot())).toEqual([]);
const pkg = JSON.parse(await readFile(join(target, "package.json"), "utf8"));
expect(pkg.projectId).toBe(draft.id);
});
it("lands a write asked for before the save in the saved folder", async () => {
const draft = await createProject();
const target = join(root, "My Ad");
const manifest = { version: 1, folders: [], assets: [{ id: "a" }] };
const writing = writeManifest(draft.dir, manifest);
await saveProject(draft.dir, target);
await writing;
expect(await readManifest(target)).toEqual(manifest);
expect(await readdir(draftsRoot())).toEqual([]);
});
it("refuses a folder that exists, and a project that is not a draft", async () => {
const draft = await createProject();
const taken = join(root, "taken");
await mkdir(taken);
await expect(saveProject(draft.dir, taken)).rejects.toThrow(/already exists/);
const saved = await saveProject(draft.dir, join(root, "saved"));
await expect(saveProject(saved.dir, join(root, "again"))).rejects.toThrow(/saved already/);
});
it("moves a saved project, keeping its name, and refuses to move a draft", async () => {
const draft = await createProject();
await expect(moveProject(draft.dir, join(root, "elsewhere"))).rejects.toThrow(/Save the draft/);
const saved = await saveProject(draft.dir, join(root, "My Ad"));
const target = join(root, "Archive", "Ad Folder");
const moved = await moveProject(saved.dir, target);
expect(moved).toMatchObject({ id: draft.id, dir: target, name: "Ad Folder", displayName: "My Ad", draft: false });
expect(await readdir(root)).not.toContain("My Ad");
});
});

View File

@ -0,0 +1,51 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// A project folder renamed or moved in Finder is found again next to where it
// was, by the id in its record.
import { tmpdir } from "node:os";
import { mkdir, mkdtemp, rename, rm } from "node:fs/promises";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("electron", () => ({
app: { isPackaged: false, getPath: () => tmpdir() },
dialog: {},
shell: {},
ipcMain: { on: () => { } },
}));
const { findMovedProject, initProject } = await import("./projects");
let root: string;
beforeEach(async () => {
root = await mkdtemp(join(tmpdir(), "locate-test-"));
});
afterEach(async () => {
await rm(root, { recursive: true, force: true });
});
describe("findMovedProject", () => {
it("finds a project renamed in place by its id", async () => {
const project = await initProject(null, join(root, "golden-river"));
await initProject(null, join(root, "another"));
await rename(project.dir, join(root, "My Ad"));
const found = await findMovedProject(project.dir, project.id);
expect(found).toMatchObject({ id: project.id, dir: join(root, "My Ad") });
});
it("finds nothing when the folder left its parent, or the parent is gone", async () => {
const project = await initProject(null, join(root, "golden-river"));
await mkdir(join(root, "elsewhere", "deeper"), { recursive: true });
await rename(project.dir, join(root, "elsewhere", "deeper", "My Ad"));
expect(await findMovedProject(project.dir, project.id)).toBeNull();
expect(await findMovedProject(join(root, "gone", "golden-river"), project.id)).toBeNull();
expect(await findMovedProject(project.dir, "")).toBeNull();
});
});

View File

@ -16,12 +16,13 @@ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
import type { PluginItem, TransformOptions } from "@babel/core";
import type { BuildOptions, Plugin } from "esbuild";
import { countCodeChange } from "./analytics";
import { isTempPath, TEMP_PREFIX, writeFileAtomic } from "./atomic";
import { windowsCloudSyncKind } from "./cloud-sync-windows";
import { isHeadless } from "./headless";
import { mainBridge } from "./main-manager";
import { MAIN_CHANNELS } from "./main-channels";
import { applyEdits, editLabel, stampProject } from "./edit";
import { migrateGenerations } from "./legacy-generations";
import { canonicalizeTagsPlugin, inspectPlugin, sourcePlugin } from "./source";
import type { CompileResult, FsEntry, FsStat, ProjectInfo, SourceEdit, WriteResult } from "./main-channels";
import type { SourceContext } from "./edit";
@ -97,7 +98,8 @@ async function writePackage(dir: string, pkg: PackageJson): Promise<void> {
// Identity
// A project is named twice: `displayName` is what the user calls it and the
// folder is what the disk calls it, and renaming moves both. Neither can be
// folder is what the disk calls it, and either can change apart from the
// other (the app renames the one, the user moves the other). Neither can be
// the project's identity, so the record carries an id that nothing renames —
// it is what the app's URLs point at, and what the editor keys the open world
// by. Top level rather than inside `diffusion`, which `writeConfig` replaces
@ -152,54 +154,121 @@ async function describe(dir: string): Promise<ProjectInfo | null> {
entry,
modifiedAt: file.mtime.toISOString(),
createdAt: folder.birthtime.toISOString(),
draft: isDraft(dir),
};
}
export const getProject = (dir: string): Promise<ProjectInfo | null> => describe(dir);
// ---------------------------------------------------------------------------
// Drafts
// A new project starts as a draft: a folder the app makes without asking,
// in a place of its own, named after the id. Saving it (⌘S) is when the user
// says where it goes and what the folder is called — the folder moves there,
// and from then on it is an ordinary project.
/**
* The folder projects go in when the user has not picked one. `~/Movies` on
* macOS, `Videos` elsewhere — chosen because it is the one media folder the
* sync services leave alone: iCloud's "Desktop & Documents Folders" covers
* only those two, and OneDrive's Known Folder Move only Desktop, Documents,
* and Pictures. It also needs no macOS permission prompt, which Documents and
* Desktop do. Created on demand, so a user who never makes a project never
* gets the folder.
*
* Null when it turns out to be synced after all and the user would rather
* pick somewhere else — the caller falls back to `pickRoot`.
* The folder drafts live in. Inside the app's own data, which nothing syncs —
* neither iCloud nor OneDrive reaches `Application Support` or `AppData` —
* and which needs no permission prompt. On Windows the Local AppData rather
* than the Roaming one, which a roaming profile would carry, media and all,
* from machine to machine.
*/
export async function defaultRoot(window: BrowserWindow | null): Promise<string | null> {
export function draftsRoot(): string {
const local = process.platform === "win32" ? process.env.LOCALAPPDATA : undefined;
const base = local ? join(local, basename(app.getPath("userData"))) : app.getPath("userData");
return join(base, "Drafts");
}
/** Whether `dir` is a draft's folder: directly inside `draftsRoot`. */
function isDraft(dir: string): boolean {
const parent = dirname(resolve(dir));
const root = draftsRoot();
return process.platform === "win32" ? parent.toLowerCase() === root.toLowerCase() : parent === root;
}
/**
* Where the save picker starts when no project has been saved yet: a folder
* under `~/Movies` on macOS, `Videos` elsewhere — the one media folder the
* sync services leave alone (iCloud's "Desktop & Documents Folders" covers
* only those two, OneDrive's Known Folder Move only Desktop, Documents, and
* Pictures), and one that needs no macOS permission prompt. Created on
* demand, so a user who never saves a project never gets the folder.
*/
async function defaultSaveFolder(): Promise<string> {
const dir = join(app.getPath("videos"), "Diffusion Studio");
if (!(await confirmCloudLocation(window, dir, "Choose another folder"))) return null;
await mkdir(dir, { recursive: true });
return dir;
}
export async function pickRoot(window: BrowserWindow | null): Promise<string | null> {
const options: Electron.OpenDialogOptions = {
title: "Choose projects folder",
defaultPath: app.getPath("videos"),
properties: ["openDirectory", "createDirectory"],
/** Characters no folder name can hold on one platform or another. */
const UNSAFE_NAME = /[\\/:*?"<>|]+/g;
/** Why the project in `dir` cannot be saved or moved as `target`, or null when it can. */
async function saveProblem(dir: string, target: string): Promise<string | null> {
if (await exists(target)) {
return `"${basename(target)}" already exists in ${basename(dirname(target))}. Choose another name.`;
}
const inside = relative(resolve(dir), resolve(target));
if (!inside.startsWith("..") && !isAbsolute(inside)) return "A project can't be saved inside itself.";
if (isDraft(target)) return "Choose a folder outside the drafts folder.";
return null;
}
/** What the save picker is asked for: saving a draft, or moving a saved project. */
export type SaveAction = "save" | "move";
/**
* Asks where to save the draft in `dir`, or where to move the project there:
* the folder it will become, or null when the user cancels. Starts in
* `startIn` — the parent of the last project saved — with `name` filled in.
* A name that is taken is refused rather than replaced, and a synced folder
* is warned about; either way the picker comes back, since the user came here
* to save.
*/
export async function pickSaveLocation(
window: BrowserWindow | null,
dir: string,
name: string,
startIn: string | null,
action: SaveAction = "save",
): Promise<string | null> {
const start = startIn && (await stat(startIn).catch(() => null))?.isDirectory() ? startIn : await defaultSaveFolder();
const folder = name.replace(UNSAFE_NAME, "-").trim() || basename(dir);
const options: Electron.SaveDialogOptions = {
title: action === "move" ? "Move project" : "Save project",
buttonLabel: action === "move" ? "Move" : "Save",
defaultPath: join(start, folder),
properties: ["createDirectory", "showOverwriteConfirmation"],
};
// Declining a synced folder reopens the picker rather than dropping the
// user back to the dashboard: they came here to choose one.
while (true) {
const { canceled, filePaths } = window
? await dialog.showOpenDialog(window, options)
: await dialog.showOpenDialog(options);
if (canceled || !filePaths[0]) return null;
if (await confirmCloudLocation(window, filePaths[0], "Choose another folder")) {
return filePaths[0];
const { canceled, filePath } = window
? await dialog.showSaveDialog(window, options)
: await dialog.showSaveDialog(options);
if (canceled || !filePath) return null;
options.defaultPath = filePath;
const problem = await saveProblem(dir, filePath);
if (problem) {
const message: Electron.MessageBoxOptions = {
type: "warning",
message: action === "move" ? "Can't move here" : "Can't save here",
detail: problem,
};
if (window) await dialog.showMessageBox(window, message);
else await dialog.showMessageBox(message);
continue;
}
if (await confirmCloudLocation(window, filePath, "Choose another folder")) return filePath;
}
}
/**
* A folder to open as a single project, wherever it lives. Unlike `pickRoot`
* this leaves the projects root alone, and it does not vet the location: the
* folder goes through `initProject`, which asks about a synced one there.
* A folder to open as a single project, wherever it lives. It does not vet
* the location: the folder goes through `initProject`, which asks about a
* synced one there.
*/
export async function pickFolder(window: BrowserWindow | null): Promise<string | null> {
const options: Electron.OpenDialogOptions = {
@ -344,8 +413,8 @@ export async function cloudSyncKind(path: string): Promise<string | null> {
/**
* Whether to go ahead with `path`: true when nothing syncs it, and when the
* user has been told what syncing does to a project and wants it anyway.
* Headless runs are never asked — there is nobody to ask — and proceed with
* the warning in the log.
* Nobody is asked while the window is hidden — an agent is driving and there
* is nobody to ask — and the project goes ahead with the warning in the log.
*/
async function confirmCloudLocation(
window: BrowserWindow | null,
@ -355,7 +424,7 @@ async function confirmCloudLocation(
const kind = await cloudSyncKind(path);
if (!kind) return true;
if (isHeadless()) {
if (!window?.isVisible()) {
console.warn(`[projects] ${path} is synced by ${kind}; projects there may misbehave`);
return true;
}
@ -380,24 +449,52 @@ async function confirmCloudLocation(
return response === 1;
}
/** Direct child folders of `root` that could hold a project, in a stable order. */
async function childDirs(root: string): Promise<string[]> {
const entries = await readdir(root, { withFileTypes: true });
return entries
.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules")
.map((entry) => entry.name)
.sort()
.map((name) => join(root, name));
/**
* The project `id` in a folder beside `dir`, which no longer holds it: one
* renamed in Finder, or moved to another folder next to it. Found by the id in
* its record, which goes wherever the folder goes. Null when no sibling holds
* it, or `dir`'s parent is gone too. Reads only.
*/
export async function findMovedProject(dir: string, id: string): Promise<ProjectInfo | null> {
if (!id) return null;
const parent = dirname(dir);
let entries;
try {
entries = await readdir(parent, { withFileTypes: true });
} catch {
return null;
}
for (const entry of entries) {
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
const candidate = join(parent, entry.name);
if (recordedId(await readPackage(candidate)) === id) return describe(candidate);
}
return null;
}
/**
* Every direct child folder of `root` that holds an entry file. The one
* search of the disk for projects there is: the app runs it when a projects
* root is chosen, to put the projects already in it on its list. Reads only.
*/
export async function scanProjects(root: string): Promise<ProjectInfo[]> {
const projects = await Promise.all((await childDirs(root)).map(describe));
return projects.filter((project): project is ProjectInfo => project !== null);
/** What the user wants done about a project whose folder can't be found. */
export type MissingProjectChoice = "locate" | "remove" | "cancel";
/** Tells the user the project's folder is gone, and asks what to do about it. */
export async function askAboutMissingProject(
window: BrowserWindow | null,
displayName: string,
dir: string,
): Promise<MissingProjectChoice> {
const options: Electron.MessageBoxOptions = {
type: "warning",
message: `Can't find "${displayName}"`,
detail: `It was in ${dir}. It may have been moved, renamed or deleted, or be on a disk that isn't connected.`,
buttons: ["Locate...", "Remove from List", "Cancel"],
defaultId: 0,
cancelId: 2,
};
const { response } = window
? await dialog.showMessageBox(window, options)
: await dialog.showMessageBox(options);
if (response === 0) return "locate";
if (response === 1) return "remove";
return "cancel";
}
/**
@ -416,17 +513,6 @@ export async function resolveProject(dir: string): Promise<ProjectInfo | null> {
// ---------------------------------------------------------------------------
// Scaffold
/** Folder-safe project name: "Golden River 15 Aug" -> "golden-river-15-aug". */
function folderName(name: string): string {
return (
name
.toLowerCase()
.replace(/[^a-z0-9._-]+/g, "-")
.replace(/^[-.]+|[-.]+$/g, "")
.slice(0, 64) || "project"
);
}
/** `base`, or `base-2`, `base-3`... when the folder is taken. */
async function freeFolder(root: string, base: string): Promise<string> {
let name = base;
@ -451,22 +537,19 @@ const SOLID_VERSION = "^1.9.10";
/**
* The diffusion surface as npm scripts: the CLI is how a project is inspected and
* cut, so its commands belong in the record of the project they act on —
* `npm run` prints the menu, `npm run <name> -- <args>` runs one. Named after
* the command rather than its path (`grab`, not `media:grab`): the `media`
* subcommands have no top-level namesakes to collide with.
* `npm run` prints the menu, `npm run <name> -- <args>` runs one, named after
* the command.
*/
const SCRIPTS: Record<string, string> = {
open: "diffusion open .",
context: "diffusion context",
capture: "diffusion capture",
probe: "diffusion media probe",
transcribe: "diffusion media transcribe",
grab: "diffusion media grab",
filmstrip: "diffusion media filmstrip",
waveform: "diffusion media waveform",
listen: "diffusion media listen",
models: "diffusion models",
voices: "diffusion voices",
probe: "diffusion probe",
transcribe: "diffusion transcribe",
grab: "diffusion grab",
filmstrip: "diffusion filmstrip",
waveform: "diffusion waveform",
listen: "diffusion listen",
fonts: "diffusion fonts",
logs: "diffusion logs",
screenshot: "diffusion screenshot",
@ -551,10 +634,10 @@ a new session.
| Path | What it is |
| ---- | ---------- |
| \`index.tsx\` | The entry. Its default export renders the composition. |
| \`package.json\` | The project record: \`projectId\` (its identity, kept across renames), \`displayName\` (the name shown in the app), \`main\` (the entry), \`diffusion\` (how each scene is exported), and the diffusion commands as scripts. |
| \`package.json\` | The project record: \`projectId\` (its identity, kept across renames), \`displayName\` (the name shown in the app), \`main\` (the entry), \`diffusion\` (how each scene is exported, and whether the stage has ever had anything on it), and the diffusion commands as scripts. |
| \`tsconfig.json\` | Types for the composition tags, through \`jsxImportSource\`. |
| \`assets.yml\` | The asset library: for every asset its library path, where its bytes are, and what it was found to be; for a generation without bytes, where it stands. Written by the app; hand edits are read on the next load. |
| \`assets/\` | The library's files: put one here and it is taken in while the app watches, and the app writes its own here too — generations under \`assets/generated/\`. Media imported through the app is linked where it lies instead, never copied. |
| \`assets.yml\` | The asset library: for every asset its library path, where its bytes are, and what it was found to be. Written by the app; hand edits are read on the next load. |
| \`assets/\` | The library's files: put one here and it is taken in while the app watches, and the app writes its own here too. Media imported through the app is linked where it lies instead, never copied. |
| \`cache/\` | Derived data (thumbnails, waveforms). Disposable, and not checked in. |
## Authoring
@ -600,10 +683,6 @@ export default function Project() {
and the gradient paints, \`<stroke>\`, \`<shadow>\`, \`<effect>\`.
- \`src\` takes a library path (\`"b-roll/drone.mp4"\` — the portable form, it
survives the file being relinked), an asset id, a URL, or an absolute path.
- Generated assets are declared rather than fetched: \`src={generate.image({ prompt })}\`,
and \`generate.video\`, \`generate.voice\`, \`generate.audio\`. They are produced on
mount, in dependency order. \`diffusion context\` reports where each stands:
generating, failed with the reason, or done with the asset path it landed as.
- Solid is fully available while mounting: \`<For>\`, \`<Show>\`, \`createMemo\`, and
\`useTicker()\` for values that follow the playhead.
- npm packages work as they normally do. The folder is a real npm package, so
@ -623,24 +702,22 @@ All of them talk to the running app, except \`fonts\`.
| Script | Command | What it does |
| ------ | ------- | ------------ |
| \`open\` | \`diffusion open .\` | Launch the app with this project open. |
| \`context\` | \`diffusion context\` | Which project the app has open, where its playhead sits, its fonts, where its generations stand. |
| \`context\` | \`diffusion context\` | Which project the app has open, where its playhead sits, its fonts, its background mask tracks. |
| \`capture\` | \`diffusion capture <id>\` | Render frames of a scene, as an export would, to labelled PNG contact sheets. |
| \`probe\` | \`diffusion media probe <id\\|path>\` | Container and per-track metadata, without decoding. |
| \`transcribe\` | \`diffusion media transcribe <id\\|path>\` | Timed speech transcript, word by word. |
| \`grab\` | \`diffusion media grab <id\\|path>\` | Decode frames of a video to labelled PNG contact sheets. |
| \`filmstrip\` | \`diffusion media filmstrip <id\\|path>\` | Thumbnail grid across a window of a video. |
| \`waveform\` | \`diffusion media waveform <id\\|path>\` | Loudness over time, with the silences marked. |
| \`listen\` | \`diffusion media listen <id\\|path>\` | Ask a multimodal model what is in an audio track. |
| \`models\` | \`diffusion models [type]\` | Generation models and their per-model constraints. |
| \`voices\` | \`diffusion voices\` | Speech voices for \`generate.voice\`. |
| \`fonts\` | \`diffusion fonts\` | Local font families, valid as \`fontFamily\`. |
| \`probe\` | \`diffusion probe <id\\|path>\` | Container and per-track metadata, without decoding. |
| \`transcribe\` | \`diffusion transcribe <id\\|path>\` | Timed speech transcript, word by word. |
| \`grab\` | \`diffusion grab <id\\|path>\` | Decode frames of a video to labelled PNG contact sheets. |
| \`filmstrip\` | \`diffusion filmstrip <id\\|path>\` | Thumbnail grid across a window of a video. |
| \`waveform\` | \`diffusion waveform <id\\|path>\` | Loudness over time, with the silences marked. |
| \`listen\` | \`diffusion listen <id\\|path>\` | Ask a multimodal model what is in an audio track. |
| \`fonts\` | \`diffusion fonts\` | Google Fonts and local font families, valid as \`fontFamily\`. |
| \`logs\` | \`diffusion logs\` | Recent console output from the app. |
| \`screenshot\` | \`diffusion screenshot\` | The whole app window as a PNG. |
| \`report\` | \`diffusion report <title>\` | File a bug against the editor, with diagnostics attached. |
## Reference
- [JSX reference](https://github.com/diffusionstudio/editor/blob/main/docs/reference/jsx/README.md): elements, timing, paints, generation, captions
- [JSX reference](https://github.com/diffusionstudio/editor/blob/main/docs/reference/jsx/README.md): elements, timing, paints, captions
- [Tool reference](https://github.com/diffusionstudio/editor/blob/main/docs/reference/tools/README.md): every tool and command, its options and its output
- [Examples](https://github.com/diffusionstudio/editor/tree/main/docs/examples): runnable compositions to read
`;
@ -750,82 +827,59 @@ export async function initProject(window: BrowserWindow | null, dir: string): Pr
return project;
}
/** What a new project is called until it is saved under a name of the user's. */
const DRAFT_NAME = "Untitled";
/**
* Creates a fresh project folder under `root`, named after `displayName`. A
* taken name is numbered rather than refused: the folder is a label, the id
* inside it is the project.
* Creates a fresh project as a draft: a folder in `draftsRoot` named after
* the id it is given here, so creating one asks nothing. `saveProject` is
* what gives it a place and a name of the user's choosing.
*/
export async function createProject(root: string, displayName: string): Promise<ProjectInfo> {
const dir = join(root, await freeFolder(root, folderName(displayName)));
export async function createProject(): Promise<ProjectInfo> {
const id = nanoid();
const dir = join(draftsRoot(), id);
await mkdir(dir, { recursive: true });
await scaffold(dir, displayName);
// The record first, so the scaffold keeps the id the folder is named after.
await writePackage(dir, { ...packageJson(DRAFT_NAME, DRAFT_NAME), projectId: id });
await scaffold(dir, DRAFT_NAME);
const project = await describe(dir);
if (!project) throw new Error("Failed to scaffold the project.");
return project;
}
/**
* Renames the project: the human name in the record, and the folder with it,
* so what the user sees in Finder keeps matching what they see in the app.
* This is the only thing here that moves a folder — nothing syncs the two
* behind the user's back — and it costs the project neither its identity nor
* its links, both of which are the id.
* Renames the project: the human name in the record, and nothing else. The
* folder keeps its name — moving it is the user's to do, by hand — and the id
* the project goes by is untouched either way.
*/
export async function renameProject(dir: string, displayName: string): Promise<ProjectInfo> {
const pkg = (await readPackage(dir)) ?? packageJson(basename(dir), displayName);
const name = displayName.trim() || basename(dir);
await writePackage(dir, { ...pkg, displayName: name });
await writePackage(dir, { ...pkg, displayName: displayName.trim() || basename(dir) });
const project = await describe(await renameFolder(dir, name));
const project = await describe(dir);
if (!project) throw new Error("Not a project folder.");
return project;
}
/**
* Moves the project folder to match `displayName`; answers where it ended up.
* Best effort by design: the folder can be locked, open elsewhere, or on a
* volume that will not have it, and none of that should cost the user the
* name they just typed.
* Copies the folder next to itself as `<name>-copy` (numbered when taken); a
* draft's copy is a draft too, named after its own id.
*/
async function renameFolder(dir: string, displayName: string): Promise<string> {
const root = dirname(dir);
const base = folderName(displayName);
const current = basename(dir);
// Already named after it, numbered suffix and all: moving `my-clip-2` to
// `my-clip` (or to `my-clip-3`) shuffles folders that are equally right.
if (current === base || (current.startsWith(`${base}-`) && /^\d+$/.test(current.slice(base.length + 1)))) {
return dir;
}
try {
const target = join(root, await freeFolder(root, base));
// The watcher holds the old path, and the renderer re-watches the new one
// as soon as it hears where the project went.
unwatchProject(dir);
await rename(dir, target);
return target;
} catch {
return dir;
}
}
/** Copies the folder next to itself as `<name>-copy` (numbered when taken). */
export async function duplicateProject(dir: string): Promise<ProjectInfo> {
const source = await describe(dir);
if (!source) throw new Error("Not a project folder.");
const id = nanoid();
const root = dirname(dir);
const target = join(root, await freeFolder(root, `${source.name}-copy`));
const target = source.draft ? join(root, id) : join(root, await freeFolder(root, `${source.name}-copy`));
await cp(dir, target, { recursive: true, errorOnExist: true, force: false });
// The record came along with everything else, id included, and two folders
// answering to one id is the thing the id exists to prevent. The folder is
// already named for the copy, so the record is written here rather than
// through `renameProject` (which would move it again).
// answering to one id is the thing the id exists to prevent.
const pkg = await readPackage(target);
await writePackage(target, {
...(pkg ?? packageJson(basename(target), source.displayName)),
projectId: nanoid(),
projectId: id,
displayName: `${source.displayName} (Copy)`,
});
const project = await describe(target);
@ -833,11 +887,61 @@ export async function duplicateProject(dir: string): Promise<ProjectInfo> {
return project;
}
/** Moves the folder to the trash; resolves with the id it had ("" for none), for what is kept outside it. */
/**
* Saves the draft in `dir` as `target`: moves its folder there and names the
* project after it — the name the user typed in the save picker, which is
* the draft's own unless they changed it. Writes still on their way into the
* draft land first; whoever has it open lets go of the folder before asking
* (see `ProjectProvider` in the web app), and opens it again where it went.
*/
export async function saveProject(dir: string, target: string): Promise<ProjectInfo> {
if (!isDraft(dir)) throw new Error("This project is saved already.");
await moveFolder(dir, target);
return renameProject(target, basename(target));
}
/**
* Moves the saved project in `dir` to `target`, as saving moves a draft —
* but it keeps its name, which is the user's already. A draft is saved
* rather than moved.
*/
export async function moveProject(dir: string, target: string): Promise<ProjectInfo> {
if (isDraft(dir)) throw new Error("Save the draft instead of moving it.");
await moveFolder(dir, target);
const project = await describe(target);
if (!project) throw new Error("Failed to move the project.");
return project;
}
/** Moves the project folder `dir` to `target`, once whatever is on its way into it has landed. */
async function moveFolder(dir: string, target: string): Promise<void> {
if (!isAbsolute(target)) throw new Error(`The project folder must be an absolute path (got "${target}").`);
const problem = await saveProblem(dir, target);
if (problem) throw new Error(problem);
await settleWrites(dir);
unwatchProject(dir);
await mkdir(dirname(target), { recursive: true });
try {
await rename(dir, target);
} catch (error) {
// Another volume: there is no moving a folder there, only copying it.
if ((error as NodeJS.ErrnoException).code !== "EXDEV") throw error;
await cp(dir, target, { recursive: true, errorOnExist: true, force: false });
await rm(dir, { recursive: true, force: true });
}
}
/**
* Moves the folder to the trash; resolves with the id it had ("" for none), for what is kept outside it.
* A folder that is already gone counts as deleted, so the project can still come off the list.
*/
export async function deleteProject(dir: string): Promise<string> {
const id = recordedId(await readPackage(dir));
unwatchProject(dir);
await shell.trashItem(dir);
if (await exists(dir)) {
await shell.trashItem(dir);
}
return id;
}
@ -912,6 +1016,11 @@ export async function compileProject(dir: string): Promise<CompileResult> {
// of the scaffold is the dashboard's (see `initProject`).
await ensureRecord(dir);
// Projects from before generation was removed declare assets the JSX can
// no longer load; they are pointed at what those declarations produced.
// Writes nothing to a project with nothing left to migrate.
await migrateGenerations(sourceContext(dir), await readManifest(dir).catch(() => null));
// Names every element before it is numbered, so the ids this compile hands
// the canvas are durable ones. A fully keyed project is not written to.
await stampProject(sourceContext(dir));
@ -953,13 +1062,47 @@ export async function compileProject(dir: string): Promise<CompileResult> {
* (see `noteContent`).
*/
export async function writeProject(dir: string, edits: SourceEdit[]): Promise<WriteResult> {
const finish = startWrite(dir);
try {
return await applyEdits(sourceContext(dir), edits);
} catch (error) {
return { skipped: edits.map(editLabel), error: error instanceof Error ? error.message : String(error) };
} finally {
finish();
}
}
/**
* Writes into a project that have not finished yet, by folder. Saving a draft
* moves its folder, and waits these out first (see `settleWrites`): one that
* lost the race would fail, or put a file back in the folder that just left.
* A write starts before its first await, so one asked for before the save is
* always among them.
*/
const writes = new Map<string, Set<Promise<void>>>();
/** Marks a write into `dir` as running; call what it returns when the write is done. */
function startWrite(dir: string): () => void {
let release!: () => void;
const done = new Promise<void>((resolve) => (release = resolve));
const running = writes.get(dir) ?? new Set<Promise<void>>();
writes.set(dir, running);
running.add(done);
return () => {
release();
running.delete(done);
if (!running.size && writes.get(dir) === running) {
writes.delete(dir);
}
};
}
/** Settles once every write into `dir` asked for so far has, however it went. */
async function settleWrites(dir: string): Promise<void> {
await Promise.allSettled([...(writes.get(dir) ?? []), configWrites.get(dir)]);
}
// ---------------------------------------------------------------------------
// Assets
@ -995,11 +1138,16 @@ export async function readManifest(dir: string): Promise<unknown> {
* claimed first so the watcher does not hand it back as a change.
*/
export async function writeManifest(dir: string, manifest: unknown): Promise<void> {
const path = join(dir, MANIFEST_FILE);
const text = `# Diffusion Studio asset library. Edited by the app; hand edits are read on the next load.
const finish = startWrite(dir);
try {
const path = join(dir, MANIFEST_FILE);
const text = `# Diffusion Studio asset library. Edited by the app; hand edits are read on the next load.
${stringifyYaml(manifest, { lineWidth: 0 })}`;
noteContent(path, text);
await writeFileAtomic(path, text);
noteContent(path, text);
await writeFileAtomic(path, text);
} finally {
finish();
}
}
// ---------------------------------------------------------------------------
@ -1014,17 +1162,37 @@ export async function readConfig(dir: string): Promise<unknown> {
return pkg?.[CONFIG_FIELD] ?? null;
}
/** Settles when the config write last asked for is done, by project. */
const configWrites = new Map<string, Promise<void>>();
/**
* Replaces the project's config in its package.json (removes the field for
* null), leaving the rest of the record alone. The watcher is told to keep
* quiet about it, like the manifest: the app already shows these values.
*
* One at a time, in the order asked: each reads the record the last one left,
* and the file ends up holding the config the app was given last rather than
* whichever write happened to finish last.
*/
export async function writeConfig(dir: string, config: unknown): Promise<void> {
const pkg = (await readPackage(dir)) ?? packageJson(basename(dir), basename(dir));
const next: PackageJson = { ...pkg };
if (config === null || config === undefined) delete next[CONFIG_FIELD];
else next[CONFIG_FIELD] = config;
await writePackage(dir, next);
const previous = configWrites.get(dir);
let release!: () => void;
const done = new Promise<void>((resolve) => (release = resolve));
configWrites.set(dir, done);
try {
await previous;
const pkg = (await readPackage(dir)) ?? packageJson(basename(dir), basename(dir));
const next: PackageJson = { ...pkg };
if (config === null || config === undefined) delete next[CONFIG_FIELD];
else next[CONFIG_FIELD] = config;
await writePackage(dir, next);
} finally {
release();
if (configWrites.get(dir) === done) {
configWrites.delete(dir);
}
}
}
/** Entries of a directory; [] when it is missing or not a directory. */
@ -1122,8 +1290,8 @@ const watchers = new Map<string, FSWatcher>();
/**
* What the app believes is on disk, by absolute path: a digest of the content
* of every file it has written, and of every change it has already been told
* about. The watcher stays on — anything else may be editing these files, and
* of every file whose write has been answered for (see `claimed`), and of
* every change it has already been told about. The watcher stays on — anything else may be editing these files, and
* should still reach the canvas — but the app's own writes must not come back
* as a change, or every key stamp and every dragged rect would cost a
* recompile and a remount of the scene the user is looking at.
@ -1137,6 +1305,36 @@ const watchers = new Map<string, FSWatcher>();
*/
const known = new Map<string, string>();
/**
* Writes claimed that no event has answered for yet, oldest first, by absolute
* path. More than one at a time: a slider writes the config on every move, so
* the next write is claimed before the event for the last one is answered,
* and that event must still be recognized as ours. One that matches settles
* every claim made before it, which can no longer land after it.
*/
const claimed = new Map<string, string[]>();
/** Claims kept per path; past this the oldest is taken to have been answered. */
const CLAIMS_MAX = 32;
function claim(path: string, digest: string): void {
const claims = claimed.get(path) ?? [];
claims.push(digest);
if (claims.length > CLAIMS_MAX) claims.shift();
claimed.set(path, claims);
}
/** Whether `current` is what a claimed write put at `path`; settles it if so. */
function settleClaim(path: string, current: string): boolean {
const claims = claimed.get(path);
const index = claims?.indexOf(current) ?? -1;
if (index < 0) return false;
claims!.splice(0, index + 1);
if (!claims!.length) claimed.delete(path);
known.set(path, current);
return true;
}
/** Digests for what has no content: a file that is not there, and a folder. */
const ABSENT = "";
const FOLDER = "folder";
@ -1173,9 +1371,9 @@ async function digestOf(path: string): Promise<string> {
* round, and self-correcting either way.
*/
export function noteContent(path: string, text: string | null): void {
if (text === null) known.set(path, ABSENT);
if (text === null) claim(path, ABSENT);
else if (Buffer.byteLength(text) > DIGEST_MAX) known.delete(path);
else known.set(path, digest(text));
else claim(path, digest(text));
}
/**
@ -1189,9 +1387,12 @@ export function noteContent(path: string, text: string | null): void {
* exactly what an event will find at `as`.
*/
export async function noteRenamed(temp: string, as: string): Promise<void> {
known.set(as, await digestOf(temp));
claim(as, await digestOf(temp));
}
/** The files a change to which counts as code being written, for analytics. */
const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
export function watchProject(window: BrowserWindow | null, dir: string): void {
if (watchers.has(dir)) return;
@ -1203,6 +1404,11 @@ export function watchProject(window: BrowserWindow | null, dir: string): void {
const watcher = watch(dir, { recursive: true }, (_event, filename) => {
if (!filename) return;
// macOS's recursive FSEvents watch fires an extra notification for the
// watched folder itself alongside the real one for whatever changed
// inside it — and again once more, asynchronously, after the folder is
// removed and the watcher closed. Neither names an actual project file.
if (filename === basename(dir)) return;
// Project-relative and `/`-separated; installs churn node_modules constantly.
const path = filename.split(sep).join("/");
if (path.startsWith("node_modules/") || path === "node_modules") return;
@ -1215,8 +1421,10 @@ export function watchProject(window: BrowserWindow | null, dir: string): void {
queue = queue
.then(async () => {
const current = await digestOf(file);
if (known.get(file) === current) return;
if (settleClaim(file, current) || known.get(file) === current) return;
known.set(file, current);
if (SOURCE_FILE.test(path) && current !== ABSENT) countCodeChange(path);
mainBridge.emit(window, MAIN_CHANNELS.PROJECTS_CHANGED, { dir, path });
})
.catch(() => { });
@ -1232,6 +1440,7 @@ export function unwatchProject(dir: string): void {
// remember: the next watch starts from a fresh load of the project anyway.
const prefix = dir.endsWith(sep) ? dir : dir + sep;
for (const path of known.keys()) if (path.startsWith(prefix)) known.delete(path);
for (const path of claimed.keys()) if (path.startsWith(prefix)) claimed.delete(path);
}
export function unwatchAll(): void {

View File

@ -21,7 +21,7 @@ vi.mock("electron", () => ({
ipcMain: { on: () => { } },
}));
const { noteContent, noteRenamed, unwatchProject, watchProject, writeManifest } = await import("./projects");
const { noteContent, noteRenamed, readConfig, unwatchProject, watchProject, writeConfig, writeManifest } = await import("./projects");
let dir: string;
let changed: string[] = [];
@ -181,4 +181,37 @@ describe("watchProject", () => {
await settle();
expect(changed).toEqual([]);
});
// A slider in the export settings writes the config on every move, so the
// next write is claimed before the event for the last one is answered.
it("says nothing about config writes that overlap, and keeps the last", async () => {
await writeFile(join(dir, "package.json"), `${JSON.stringify({ name: "p" }, null, 2)}\n`, "utf8");
await waitFor("package.json");
changed = [];
const writes: Promise<void>[] = [];
for (let bitrate = 1; bitrate <= 40; bitrate++) {
writes.push(writeConfig(dir, { export: { intro: { video: { bitrate } } } }));
await settle(8);
}
await Promise.all(writes);
await settle();
expect(changed).toEqual([]);
expect(await readConfig(dir)).toEqual({ export: { intro: { video: { bitrate: 40 } } } });
});
it("reports an outside edit that lands between two of the app's own", async () => {
const file = join(dir, "index.tsx");
noteContent(file, "ours\n");
noteContent(file, "ours again\n");
await writeFileAtomic(file, "ours\n");
await writeFile(file, "theirs\n", "utf8");
await waitFor("index.tsx");
changed = [];
await writeFileAtomic(file, "ours again\n");
await settle();
expect(changed).toEqual([]);
});
});

View File

@ -28,10 +28,12 @@ const COMPOSITION_COMPONENTS = new Map<string, string>(
// These composition names also exist in SVG. An SVG fragment is DOM content
// only while it has an SVG container in the same JSX tree; elsewhere the tag
// keeps its composition meaning.
const AMBIGUOUS_SVG_TAGS: ReadonlySet<string> = new Set(["rect", "text", "image"]);
// keeps its composition meaning. `<mask>` and `<clipPath>` are SVG containers
// too, but as such they only ever sit in an `<svg>`, so they are not counted
// as one: a composition `<mask>` keeps the shapes under it composition ones.
const AMBIGUOUS_SVG_TAGS: ReadonlySet<string> = new Set(["rect", "ellipse", "polygon", "path", "text", "image", "mask", "clipPath"]);
const SVG_CONTAINERS: ReadonlySet<string> = new Set([
"svg", "g", "defs", "symbol", "marker", "mask", "clipPath", "pattern",
"svg", "g", "defs", "symbol", "marker", "pattern",
"filter", "linearGradient", "radialGradient", "textPath", "tspan", "switch",
]);

203
apps/desktop/src/tray.ts Normal file
View File

@ -0,0 +1,203 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// The app's one permanent presence: agents use the app in the background, so
// the menu bar (macOS) or notification area (Windows) is where it shows that
// it is running, that an agent is working in it, and where the user opens
// the editor or quits.
import { basename } from "node:path";
import { app, Menu, nativeImage, nativeTheme, Tray } from "electron";
import idle1x from "../assets/tray/idleTemplate.png";
import idle2x from "../assets/tray/idleTemplate@2x.png";
import busy1x from "../assets/tray/busyTemplate.png";
import busy2x from "../assets/tray/busyTemplate@2x.png";
import win1x from "../assets/tray/win.png";
import win2x from "../assets/tray/win@2x.png";
import menuOpen1x from "../assets/tray/menu/open.png";
import menuOpen2x from "../assets/tray/menu/open@2x.png";
import menuHide1x from "../assets/tray/menu/hide.png";
import menuHide2x from "../assets/tray/menu/hide@2x.png";
import menuReady1x from "../assets/tray/menu/ready.png";
import menuReady2x from "../assets/tray/menu/ready@2x.png";
import menuBusy1x from "../assets/tray/menu/busy.png";
import menuBusy2x from "../assets/tray/menu/busy@2x.png";
import menuProject1x from "../assets/tray/menu/project.png";
import menuProject2x from "../assets/tray/menu/project@2x.png";
import menuQuit1x from "../assets/tray/menu/quit.png";
import menuQuit2x from "../assets/tray/menu/quit@2x.png";
import type { NativeImage } from "electron";
export type AppTrayDeps = {
/** Whether the window is out for the user. */
visible(): boolean;
/** Whether a tool call is running. */
active(): boolean;
/** The project the editor last had open. */
project(): string | null;
show(): void;
hide(): void;
};
// Calls come in bursts of short ones; the icon stays busy this long after the
// last so it does not flicker between them.
const BUSY_LINGER = 1500;
function image(x1: Uint8Array, x2: Uint8Array, template: boolean): NativeImage {
const icon = nativeImage.createFromBuffer(Buffer.from(x1), { scaleFactor: 1 });
icon.addRepresentation({ scaleFactor: 2, buffer: Buffer.from(x2) });
icon.setTemplateImage(template);
return icon;
}
type MenuIcon = "open" | "hide" | "ready" | "busy" | "project" | "quit";
// macOS draws SF Symbols in the menu's own color. Elsewhere the icons are
// black masks (scripts/tray-menu-icons.sh) recolored to the menu's text.
const SYMBOLS: Record<MenuIcon, string> = {
open: "macwindow",
hide: "eye.slash",
ready: "checkmark.circle",
busy: "sparkles",
project: "folder",
quit: "power",
};
const MASKS: Record<MenuIcon, [Uint8Array, Uint8Array]> = {
open: [menuOpen1x, menuOpen2x],
hide: [menuHide1x, menuHide2x],
ready: [menuReady1x, menuReady2x],
busy: [menuBusy1x, menuBusy2x],
project: [menuProject1x, menuProject2x],
quit: [menuQuit1x, menuQuit2x],
};
/** A mask's pixels filled with `rgb`, keeping its alpha; bitmaps are premultiplied BGRA. */
function tinted(png: Uint8Array, [r, g, b]: number[]) {
const mask = nativeImage.createFromBuffer(Buffer.from(png));
const { width, height } = mask.getSize();
const buffer = mask.toBitmap();
for (let i = 0; i < buffer.length; i += 4) {
const a = buffer[i + 3] / 255;
buffer[i] = Math.round(b * a);
buffer[i + 1] = Math.round(g * a);
buffer[i + 2] = Math.round(r * a);
}
return { buffer, width, height };
}
function menuIcon(name: MenuIcon, dark: boolean): NativeImage {
if (process.platform === "darwin") return nativeImage.createMenuSymbol(SYMBOLS[name]);
const color = dark ? [242, 242, 242] : [28, 28, 28];
const icon = nativeImage.createEmpty();
MASKS[name].forEach((png, i) => icon.addRepresentation({ scaleFactor: i + 1, ...tinted(png, color) }));
return icon;
}
export class AppTray {
private readonly deps: AppTrayDeps;
private tray: Tray | null = null;
private idleIcon: NativeImage | null = null;
private busyIcon: NativeImage | null = null;
private busy = false;
private lingerTimer: NodeJS.Timeout | null = null;
private wasVisible = false;
private toldStillRunning = false;
private menuIcons = new Map<string, NativeImage>();
constructor(deps: AppTrayDeps) {
this.deps = deps;
}
/** Puts the icon up; call once the app is ready. */
start(): void {
if (process.platform === "darwin") {
// Template images: macOS tints them to fit the menu bar.
this.idleIcon = image(idle1x, idle2x, true);
this.busyIcon = image(busy1x, busy2x, true);
} else {
this.idleIcon = this.busyIcon = image(win1x, win2x, false);
}
this.tray = new Tray(this.idleIcon);
// macOS opens the menu on click; elsewhere the menu is the right click
// and a click opens the editor.
if (process.platform !== "darwin") this.tray.on("click", () => this.deps.show());
nativeTheme.on("updated", this.onThemeUpdated);
this.refresh();
}
/** Brings the icon and menu up to date; call whenever what they show changes. */
refresh(): void {
const tray = this.tray;
if (!tray) return;
this.updateBusy();
const visible = this.deps.visible();
const project = this.deps.project();
const status = this.busy ? "An agent is working…" : "Ready for agents";
tray.setImage(this.busy ? this.busyIcon! : this.idleIcon!);
tray.setToolTip(`${app.name} — ${status}`);
tray.setContextMenu(
Menu.buildFromTemplate([
visible ?
{ label: `Hide ${app.name}`, icon: this.icon("hide"), click: () => this.deps.hide() }
: { label: `Open ${app.name}`, icon: this.icon("open"), click: () => this.deps.show() },
{ type: "separator" },
{ label: status, icon: this.icon(this.busy ? "busy" : "ready"), enabled: false },
...(project ?
[{ label: `Project: ${basename(project)}`, icon: this.icon("project"), enabled: false }]
: []),
{ type: "separator" },
{ label: `Quit ${app.name}`, icon: this.icon("quit"), click: () => app.quit() },
]),
);
// Windows has no Dock to hint that closing the window did not quit; say
// so once, the first time it goes away.
if (process.platform === "win32" && this.wasVisible && !visible && !this.toldStillRunning) {
this.toldStillRunning = true;
tray.displayBalloon({
iconType: "info",
title: `${app.name} is still running`,
content: "Agents can keep using it in the background. Open it again from here.",
});
}
this.wasVisible = visible;
}
destroy(): void {
if (this.lingerTimer) clearTimeout(this.lingerTimer);
nativeTheme.off("updated", this.onThemeUpdated);
this.tray?.destroy();
this.tray = null;
}
private readonly onThemeUpdated = () => this.refresh();
/** The menu icon for the current theme, made once and reused. */
private icon(name: MenuIcon): NativeImage {
const dark = nativeTheme.shouldUseDarkColors;
const key = `${name}:${dark}`;
let icon = this.menuIcons.get(key);
if (!icon) this.menuIcons.set(key, (icon = menuIcon(name, dark)));
return icon;
}
private updateBusy(): void {
if (this.deps.active()) {
if (this.lingerTimer) clearTimeout(this.lingerTimer);
this.lingerTimer = null;
this.busy = true;
} else if (this.busy && !this.lingerTimer) {
this.lingerTimer = setTimeout(() => {
this.lingerTimer = null;
this.busy = false;
this.refresh();
}, BUSY_LINGER);
}
}
}

View File

@ -13,3 +13,10 @@ declare module "@babel/preset-typescript" {
const preset: unknown;
export default preset;
}
// The tray icons, bundled into main.js as bytes (`--loader:.png=binary`):
// the packaged app ships dist/ and web/ only.
declare module "*.png" {
const bytes: Uint8Array;
export default bytes;
}

View File

@ -0,0 +1,145 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { EventEmitter } from "node:events";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const appEvents = new EventEmitter();
const updaterEvents = new EventEmitter();
const dock = { show: vi.fn(async () => { }), hide: vi.fn() };
vi.mock("electron", () => ({
app: { on: (event: string, listener: () => void) => appEvents.on(event, listener), dock, focus: () => { } },
autoUpdater: { on: (event: string, listener: () => void) => updaterEvents.on(event, listener) },
}));
const { WindowHost } = await import("./window-host");
/** Just enough of a BrowserWindow: visibility, close and destroy. */
class FakeWindow extends EventEmitter {
destroyed = false;
isVisibleNow = false;
isDestroyed = () => this.destroyed;
isVisible = () => this.isVisibleNow;
isFullScreen = () => false;
isMinimized = () => false;
show = () => void (this.isVisibleNow = true);
hide = () => void (this.isVisibleNow = false);
focus = () => { };
restore = () => { };
close(): void {
const event = { defaultPrevented: false, preventDefault: () => void (event.defaultPrevented = true) };
this.emit("close", event);
if (!event.defaultPrevented) this.destroy();
}
destroy(): void {
if (this.destroyed) return;
this.destroyed = true;
this.emit("closed");
}
}
const IDLE = 60_000;
let created: FakeWindow[];
let host: InstanceType<typeof WindowHost>;
beforeEach(() => {
vi.useFakeTimers();
appEvents.removeAllListeners();
updaterEvents.removeAllListeners();
created = [];
host = new WindowHost({
create: () => {
const window = new FakeWindow();
created.push(window);
// Painted right away, so `show` does not wait.
queueMicrotask(() => window.emit("ready-to-show"));
return window as never;
},
idleMs: IDLE,
onChange: () => { },
});
});
afterEach(() => {
vi.useRealTimers();
});
describe("WindowHost", () => {
it("creates the window only when something needs it, and reuses it", () => {
expect(host.current()).toBeNull();
expect(host.acquire().fresh).toBe(true);
expect(host.acquire().fresh).toBe(false);
expect(created).toHaveLength(1);
expect(host.visible()).toBe(false);
});
it("destroys a hidden window once it has sat unused for the idle time", () => {
host.acquire();
vi.advanceTimersByTime(IDLE - 1);
expect(host.current()).not.toBeNull();
vi.advanceTimersByTime(1);
expect(host.current()).toBeNull();
expect(host.acquire().fresh).toBe(true);
});
it("keeps the window while a call holds it, and counts idle time from the release", () => {
host.acquire();
const release = host.hold();
expect(host.active()).toBe(true);
vi.advanceTimersByTime(IDLE * 2);
expect(host.current()).not.toBeNull();
release();
release();
expect(host.active()).toBe(false);
vi.advanceTimersByTime(IDLE - 1);
expect(host.current()).not.toBeNull();
vi.advanceTimersByTime(1);
expect(host.current()).toBeNull();
});
it("keeps the window while the renderer reports work of its own", () => {
host.acquire();
host.setBusy(true);
vi.advanceTimersByTime(IDLE * 2);
expect(host.current()).not.toBeNull();
host.setBusy(false);
vi.advanceTimersByTime(IDLE);
expect(host.current()).toBeNull();
});
it("never idles out a window the user has open, and gives the app a Dock icon while it is", async () => {
await host.show();
expect(host.visible()).toBe(true);
expect(dock.show).toHaveBeenCalled();
vi.advanceTimersByTime(IDLE * 2);
expect(host.current()).not.toBeNull();
});
it("hides the window when the user closes it, and idles it out from there", async () => {
await host.show();
const window = created[0]!;
window.close();
expect(window.isDestroyed()).toBe(false);
expect(host.visible()).toBe(false);
expect(dock.hide).toHaveBeenCalled();
vi.advanceTimersByTime(IDLE);
expect(window.isDestroyed()).toBe(true);
});
it("lets the window close when the app quits", async () => {
await host.show();
appEvents.emit("before-quit");
created[0]!.close();
expect(created[0]!.isDestroyed()).toBe(true);
expect(host.current()).toBeNull();
});
it("lets the window close when an update quits the app to install", async () => {
await host.show();
updaterEvents.emit("before-quit-for-update");
created[0]!.close();
expect(created[0]!.isDestroyed()).toBe(true);
});
});

View File

@ -0,0 +1,177 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// The main window's lifecycle. The app runs in the background while agents
// use it — a tray icon, no Dock icon, no window — and the window, and with it
// the renderer that answers most tools, only exists while something needs
// it: a tool call, or the user. Hidden and unused for long enough, it is torn
// down again, and the app is back to its main process alone.
//
// Everything that shows, hides or needs the window comes through here, so
// the Dock icon (macOS) follows whether the window is showing, and closing
// the window hides it rather than ending what the renderer is doing.
import { app, autoUpdater } from "electron";
import type { BrowserWindow } from "electron";
export type WindowHostDeps = {
/** A new main window, not shown; loading starts right away. */
create(): BrowserWindow;
/** How long a hidden window may sit unused before it is destroyed. */
idleMs: number;
/** Whether the window is showing, or whether calls are running, changed. */
onChange(): void;
};
/** Longest a first show waits for the page to paint before showing it anyway. */
const FIRST_PAINT_TIMEOUT = 5000;
export class WindowHost {
private readonly deps: WindowHostDeps;
private window: BrowserWindow | null = null;
private painted: Promise<void> = Promise.resolve();
// Whether the user should be seeing the window: set by `show`, cleared by
// `hide`. Not `isVisible()`, which a minimize or ⌘H also clears — neither
// of those is the user putting the window away, so neither lets it idle
// out or takes the Dock icon.
private shown = false;
private holds = 0;
private busy = false;
private idleTimer: NodeJS.Timeout | null = null;
private quitting = false;
constructor(deps: WindowHostDeps) {
this.deps = deps;
app.on("before-quit", () => {
this.quitting = true;
});
// quitAndInstall closes the windows before `before-quit`; a close turned
// into a hide there would leave the app running and the update unapplied.
autoUpdater.on("before-quit-for-update", () => {
this.quitting = true;
});
}
/** The window, if there is one. */
current(): BrowserWindow | null {
return this.window && !this.window.isDestroyed() ? this.window : null;
}
/** Whether the window is out for the user (minimized counts). */
visible(): boolean {
return this.shown && this.current() !== null;
}
/** Whether any call is holding the window. */
active(): boolean {
return this.holds > 0;
}
/** The window, created hidden when there is none; `fresh` when this call created it. */
acquire(): { window: BrowserWindow; fresh: boolean } {
const existing = this.current();
if (existing) return { window: existing, fresh: false };
const window = this.deps.create();
this.window = window;
this.painted = new Promise((resolve) => {
window.once("ready-to-show", () => resolve());
setTimeout(resolve, FIRST_PAINT_TIMEOUT);
});
// Closing puts the window away; only quitting ends it (and idling out,
// which destroys it without a `close`).
window.on("close", (event) => {
if (this.quitting) return;
event.preventDefault();
this.hide();
});
window.on("closed", () => {
if (this.window !== window) return;
this.window = null;
this.shown = false;
this.busy = false;
this.clearIdle();
this.deps.onChange();
});
this.scheduleIdle();
return { window, fresh: true };
}
/** Shows and focuses the window, creating it when there is none. */
async show(): Promise<void> {
const { window } = this.acquire();
this.shown = true;
this.clearIdle();
// Before the window: shown by an app without a Dock icon, it would not
// come to the front.
if (process.platform === "darwin") await app.dock?.show();
await this.painted;
if (window.isDestroyed()) return;
if (window.isMinimized()) window.restore();
window.show();
window.focus();
if (process.platform === "darwin") app.focus({ steal: true });
this.deps.onChange();
}
/** Puts the window away. It stays loaded until it idles out. */
hide(): void {
const window = this.current();
if (!window) return;
// Hiding a full-screen window leaves its empty Space behind.
if (window.isFullScreen()) {
window.once("leave-full-screen", () => this.hide());
window.setFullScreen(false);
return;
}
this.shown = false;
window.hide();
if (process.platform === "darwin") app.dock?.hide();
this.scheduleIdle();
this.deps.onChange();
}
/** Keeps the window from idling out until the returned release is called. */
hold(): () => void {
this.holds++;
this.clearIdle();
if (this.holds === 1) this.deps.onChange();
let released = false;
return () => {
if (released) return;
released = true;
this.holds--;
this.scheduleIdle();
if (this.holds === 0) this.deps.onChange();
};
}
/** Work the renderer started itself (an export from the UI) that must not be cut off. */
setBusy(busy: boolean): void {
this.busy = busy;
if (busy) this.clearIdle();
else this.scheduleIdle();
}
private scheduleIdle(): void {
this.clearIdle();
if (!this.idle()) return;
this.idleTimer = setTimeout(() => {
this.idleTimer = null;
if (this.idle()) this.current()?.destroy();
}, this.deps.idleMs);
}
private idle(): boolean {
return this.current() !== null && !this.shown && this.holds === 0 && !this.busy;
}
private clearIdle(): void {
if (this.idleTimer) clearTimeout(this.idleTimer);
this.idleTimer = null;
}
}

View File

@ -1,8 +1,4 @@
VITE_SUPABASE_URL=https://mpvhvyxuqfcemfnwiaiq.supabase.co
VITE_SUPABASE_ANON_KEY=sb_publishable_V-K9coUWXVy8dsZPGKDw-g_d1JzJf8u
VITE_UMAMI_WEBSITE_ID=e898e381-6ce3-4f5f-a485-8327ec9aa88b
VITE_UMAMI_SCRIPT_URL=https://cloud.umami.is/script.js
VITE_UMAMI_DOMAINS=diffusion.studio,app.diffusion.studio
VITE_API_URL=https://api.diffusion.studio

View File

@ -1,7 +1,7 @@
{
"name": "@diffusionstudio/web",
"private": true,
"version": "0.207.0",
"version": "0.216.0",
"license": "MPL-2.0",
"type": "module",
"scripts": {
@ -14,7 +14,7 @@
},
"dependencies": {
"@diffusionstudio/agent-chat": "*",
"@diffusionstudio/api-contract": "^0.1.0",
"@diffusionstudio/api-contract": "^0.5.0",
"@diffusionstudio/assets": "*",
"@diffusionstudio/dapi": "*",
"@diffusionstudio/encoder": "*",
@ -30,8 +30,8 @@
"@solid-primitives/resize-observer": "^2.1.3",
"@solidjs/router": "^0.15.4",
"@supabase/supabase-js": "^2.99.2",
"@trpc/client": "^11.10.0",
"@trpc/server": "^11.10.0",
"@trpc/client": "^11.19.0",
"@trpc/server": "^11.19.0",
"animejs": "^4.4.1",
"cmdk-solid": "^1.1.2",
"colord": "^2.9.3",

View File

@ -2,28 +2,31 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Dropping files and folders onto a composer. Nothing is read, copied or
// uploaded: an attachment is a path the agent reads where it is, so drops
// only work where the shell can say where a file lives (the desktop app).
// Shared by the home view and the chat composer.
import { Show, createSignal } from "solid-js";
import { toast } from "somoto";
import { pickFiles } from "@diffusionstudio/assets";
import { Icon } from "@/components/ui/icon";
import { RemoveButton } from "@/components/ui/remove-button";
import { cx } from "@/lib/cva";
import { client, hasHost } from "./connection";
/**
* A file or folder dropped onto a composer. Only what the tile and the
* handoff need: the name to label it, the kind and extension to draw it, and
* the path to send — null off the desktop, where the browser will not say
* where a dropped file lives.
* where a dropped file lives. An image picked, dropped or pasted also carries
* an object URL for its thumbnail; one rebuilt from a path does not.
*/
export type Attachment = {
key: string;
name: string;
kind: "file" | "folder";
path: string | null;
preview?: string;
};
/** The paths worth sending: attachments the shell could locate. */
@ -52,19 +55,81 @@ export function droppedAttachments(event: DragEvent): Attachment[] {
const file = item.getAsFile();
if (!file) continue;
const path = window.desktop?.getPathForFile(file) || null;
const name = entry?.name || file.name;
result.push({
key: path ?? `${name}:${file.size}:${file.lastModified}`,
name,
kind: entry?.isDirectory ? "folder" : "file",
path,
});
result.push(fileAttachment(file, entry?.isDirectory ? "folder" : "file", entry?.name || file.name));
}
return result;
}
/** A file picked or dropped without the entry API, which only a drop has. */
function fileAttachment(file: File, kind: Attachment["kind"] = "file", name = file.name, path = window.desktop?.getPathForFile(file) || null): Attachment {
const preview = kind === "file" && file.type.startsWith("image/") ? URL.createObjectURL(file) : undefined;
return { key: path ?? `${name}:${file.size}:${file.lastModified}`, name, kind, path, ...(preview ? { preview } : {}) };
}
/**
* The files on the clipboard. None when the paste is text: rich text from a
* document app carries a picture of itself alongside, and that is not what
* the user meant to paste.
*/
function pastedFiles(event: ClipboardEvent): File[] {
const data = event.clipboardData;
if (!data || data.types.includes("text/rtf")) return [];
return Array.from(data.files);
}
/**
* Pasted files as attachments. A file copied in the Finder has a path and is
* sent as it is; a screenshot or an image copied from a page is only bytes,
* so it is uploaded to the agent host, which may not share this disk, and
* the path it was written to is what gets sent.
*/
async function pastedAttachments(files: File[]): Promise<Attachment[]> {
return Promise.all(
files.map(async (file) => {
const path = window.desktop?.getPathForFile(file) || null;
if (path) return file.type.startsWith("image/") ? fileAttachment(file, "file", file.name, path) : attachmentFromPath(path);
if (!hasHost()) return fileAttachment(file);
const saved = await client.request("attachments.upload", { name: file.name, data: await base64(file) });
return fileAttachment(file, "file", file.name, saved.path);
}),
);
}
/** A file's bytes as base64, without the data URL's prefix. */
function base64(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const url = reader.result as string;
resolve(url.slice(url.indexOf(",") + 1));
};
reader.onerror = () => reject(reader.error);
reader.readAsDataURL(file);
});
}
/**
* A paste handler for a composer: files go to `onPaste`, text is left to the
* textarea. A paste that fails to save is a toast, not a lost image.
*/
export function createPasteHandler(onPaste: (pasted: Attachment[]) => void) {
return (event: ClipboardEvent) => {
const files = pastedFiles(event);
if (files.length === 0) return;
event.preventDefault();
pastedAttachments(files).then(onPaste, (error: Error) =>
toast.error("Could not paste the file", { description: error.message }),
);
};
}
/** Files chosen from the system picker, as attachments; folders can only be dropped. */
export async function pickAttachments(): Promise<Attachment[]> {
const files = await pickFiles({ accept: "" });
return files.map((file) => fileAttachment(file));
}
/** The same file dropped twice is one attachment, not two tiles. */
export function mergeAttachments(current: Attachment[], dropped: Attachment[]): Attachment[] {
const known = new Set(current.map((entry) => entry.key));
@ -134,7 +199,7 @@ export function DropOverlay(props: { radius?: string }) {
shape-rendering="crispEdges"
/>
</svg>
<Icon name="attachment" class="size-6 text-muted-foreground" />
<Icon name="attachment" class="text-muted-foreground" />
<span class="text-xs font-450 text-muted-foreground">Drop files or folders here</span>
</div>
</div>
@ -148,9 +213,9 @@ type AttachmentTileProps = {
};
/**
* One dropped file or folder: a grey square with a folder mark, or the file's
* type in the middle. There is no thumbnail to show — nothing is loaded — so
* the name is in the tooltip and the remove button appears on hover, as it
* One attached file or folder: the image itself when there is one to show,
* else a grey square with a folder mark, or the file's type in the middle.
* The name is in the tooltip and the remove button appears on hover, as it
* does on the generation composer's reference images.
*/
export function AttachmentTile(props: AttachmentTileProps) {
@ -161,14 +226,21 @@ export function AttachmentTile(props: AttachmentTileProps) {
>
<div class="grid size-full place-items-center overflow-hidden rounded-lg bg-input text-muted-foreground">
<Show
when={props.attachment.kind === "folder"}
when={props.attachment.preview}
fallback={
<span class="max-w-9 truncate px-0.5 text-[9px] font-450 uppercase tracking-wide">
{fileType(props.attachment.name)}
</span>
<Show
when={props.attachment.kind === "folder"}
fallback={
<span class="max-w-9 truncate px-0.5 text-[9px] font-450 uppercase tracking-wide">
{fileType(props.attachment.name)}
</span>
}
>
<Icon name="navigation.folder" />
</Show>
}
>
<Icon name="navigation.folder" class="size-6" />
{(src) => <img src={src()} alt="" draggable={false} class="size-full object-cover" />}
</Show>
</div>
<RemoveButton

View File

@ -8,11 +8,12 @@
import { For, Show, createEffect } from "solid-js";
import { Button } from "@/components/ui/button";
import { Icon } from "@/components/ui/icon";
import type { ModelRef } from "@diffusionstudio/agent-chat";
import { AttachmentTile, DropOverlay, createDropZone, mergeAttachments, type Attachment } from "./attachments";
import { AttachmentTile, DropOverlay, createDropZone, createPasteHandler, mergeAttachments, pickAttachments, type Attachment } from "./attachments";
import { ModelPicker } from "./model-picker";
const MAX_HEIGHT_PX = 160;
@ -37,7 +38,9 @@ type ComposerProps = {
export function Composer(props: ComposerProps) {
let textarea: HTMLTextAreaElement | undefined;
const drop = createDropZone((dropped) => props.onAttachments(mergeAttachments(props.attachments, dropped)));
const attach = (added: Attachment[]) => props.onAttachments(mergeAttachments(props.attachments, added));
const drop = createDropZone(attach);
const paste = createPasteHandler(attach);
const canSend = () => !props.running && !props.blocked && props.model !== null && (props.text.trim().length > 0 || props.attachments.length > 0);
@ -52,6 +55,16 @@ export function Composer(props: ComposerProps) {
resize();
});
// The panel mounts whenever the Chat tab comes up: land in the box, ready
// to type. It may still be disabled while the host connects, and a disabled
// box can't take focus — so focus it the first time it is enabled.
let focused = false;
createEffect(() => {
if (focused || props.blocked !== null) return;
focused = true;
textarea?.focus();
});
// Enter sends, shift+enter breaks the line — and the editor's shortcuts
// have no business reading what is typed here. While a turn runs Enter
// does nothing: there is no queue.
@ -71,6 +84,7 @@ export function Composer(props: ComposerProps) {
onDragEnter={drop.onDragEnter}
onDragLeave={drop.onDragLeave}
onDrop={drop.onDrop}
onPaste={paste}
>
<Show when={props.attachments.length > 0}>
{/* The remove buttons overhang the tiles' corners, and a scrolling
@ -91,6 +105,7 @@ export function Composer(props: ComposerProps) {
<textarea
ref={textarea}
data-chat-composer
value={props.text}
onInput={(event) => props.onText(event.currentTarget.value)}
onKeyDown={handleKeyDown}
@ -99,36 +114,48 @@ export function Composer(props: ComposerProps) {
placeholder={props.blocked ?? "Do anything"}
disabled={props.blocked !== null}
rows={1}
class="max-h-40 min-h-7 w-full resize-none overflow-auto bg-transparent p-1 text-[12px] leading-5 text-foreground outline-none placeholder:text-muted-foreground selection:bg-selection selection:text-selection-foreground disabled:cursor-default"
class="max-h-40 min-h-7 w-full resize-none overflow-auto bg-transparent p-1 text-xs leading-5 text-foreground outline-none placeholder:text-muted-foreground selection:bg-selection selection:text-selection-foreground disabled:cursor-default"
/>
<div class="flex min-h-4 items-center justify-between gap-1">
<ModelPicker value={props.model} onSelect={props.onModel} class="min-w-0" />
<Show
when={props.running}
fallback={
<Button
variant="ghost"
size="icon-square"
onClick={async () => attach(await pickAttachments())}
aria-label="Add files"
title="Add files"
class="text-muted-foreground hover:bg-muted"
>
<Icon name="plus-add" />
</Button>
<div class="flex min-w-0 items-center gap-1.5">
<ModelPicker value={props.model} onSelect={props.onModel} class="min-w-0" />
<Show
when={props.running}
fallback={
<button
type="button"
onClick={() => canSend() && props.onSend()}
disabled={!canSend()}
aria-label="Send"
title={sendTitle()}
class="grid size-7 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground transition-opacity hover:bg-primary-hover disabled:pointer-events-none disabled:opacity-40 focus-ring"
>
<Icon name="arrow-top" />
</button>
}
>
<button
type="button"
onClick={() => canSend() && props.onSend()}
disabled={!canSend()}
aria-label="Send"
title={sendTitle()}
class="grid size-7 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground transition-opacity hover:bg-primary-hover disabled:pointer-events-none disabled:opacity-40 focus-ring"
onClick={props.onStop}
aria-label="Stop"
title="Stop"
class="grid size-7 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground hover:bg-primary-hover focus-ring"
>
<Icon name="arrow-top" />
<Icon name="stop" />
</button>
}
>
<button
type="button"
onClick={props.onStop}
aria-label="Stop"
title="Stop"
class="grid size-7 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground hover:bg-primary-hover focus-ring"
>
<Icon name="stop" />
</button>
</Show>
</Show>
</div>
</div>
<Show when={drop.dragging()}>

View File

@ -33,7 +33,7 @@ export function HeaderActions(props: HeaderActionsProps) {
>
<Icon name="plus-add" />
</TooltipTrigger>
<TooltipContent>New chat</TooltipContent>
<TooltipContent shortcut="⇧⌘L">New chat</TooltipContent>
</Tooltip>
</div>
);

View File

@ -76,10 +76,10 @@ export function HistoryMenu(props: HistoryMenuProps) {
{(chat) => (
<DropdownMenuItem tone="neutral" class="group/row" onSelect={() => props.onOpen(chat.id)}>
<Show when={chat.status === "running"}>
<Icon name="spinner-loader" class="animate-spin size-6 -mr-1 shrink-0" />
<Icon name="spinner-loader" class="animate-spin -mr-1 shrink-0" />
</Show>
<Show when={chat.status === "waiting"}>
<Icon name="dot" class="size-6 -mr-1 shrink-0 text-primary" />
<Icon name="dot" class="-mr-1 shrink-0 text-primary" />
</Show>
<span class="min-w-0 flex-1 truncate" title={chat.title}>
{chat.title}
@ -90,7 +90,7 @@ export function HistoryMenu(props: HistoryMenuProps) {
</span>
</Show>
<Show when={chat.id === props.chatId}>
<Icon name="confirm-check" class="size-6 -mr-1 shrink-0 group-hover/row:hidden" />
<Icon name="confirm-check" class="-mr-1 shrink-0 group-hover/row:hidden" />
</Show>
<button
type="button"
@ -102,7 +102,7 @@ export function HistoryMenu(props: HistoryMenuProps) {
>
<Icon
name="close-remove-small"
class="absolute left-1/2 top-1/2 size-6 -translate-x-1/2 -translate-y-1/2 text-inherit!"
class="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-inherit!"
/>
</button>
</DropdownMenuItem>

View File

@ -26,7 +26,9 @@ export {
DropOverlay,
attachmentPaths,
createDropZone,
createPasteHandler,
droppedAttachments,
mergeAttachments,
pickAttachments,
type Attachment,
} from "./attachments";

View File

@ -55,7 +55,7 @@ export function ReasoningItem(props: { item: Of<"reasoning"> }) {
aria-expanded={open()}
onClick={() => expandable() && setOpen(!open())}
>
<Icon name={open() ? "chevron-down" : "chevron-right"} class="size-6" />
<Icon name={open() ? "chevron-down" : "chevron-right"} />
<span>Thinking</span>
</button>
<Show when={open()}>
@ -80,13 +80,13 @@ export function ToolItem(props: { item: Of<"tool"> }) {
onClick={() => expandable() && setOpen(!open())}
>
<Show when={props.item.status === "running"}>
<Icon name="spinner-loader" class="size-6 shrink-0 animate-spin" />
<Icon name="spinner-loader" class="shrink-0 animate-spin" />
</Show>
<Show when={props.item.status === "done"}>
<Icon name="confirm-check" class="size-6 shrink-0" />
<Icon name="confirm-check" class="shrink-0" />
</Show>
<Show when={props.item.status === "failed"}>
<Icon name="close-remove-small" class="size-6 shrink-0 text-destructive" />
<Icon name="close-remove-small" class="shrink-0 text-destructive" />
</Show>
<span class="shrink-0 font-450" classList={{ "agent-shimmer": props.item.status === "running" }}>
{props.item.title}

View File

@ -2,9 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// One dropdown for harness and model: Claude Code's models, then Codex's,
// fed by the host's probes. A harness that is not ready is one disabled row
// that says why, never hidden, so the picker also says what this works with.
// One dropdown for harness and model, two levels deep: Claude Code and
// Codex first, each opening onto its models, fed by the host's probes. A
// harness that is not ready is one disabled row that says why, never hidden,
// so the picker also says what this works with.
import { For, Show } from "solid-js";
@ -12,13 +13,17 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuGroupLabel,
DropdownMenuItem,
DropdownMenuItemDetail,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";
import { Icon } from "@/components/ui/icon";
import { cx } from "@/lib/cva";
import type { HarnessId, HarnessInfo, ModelRef } from "@diffusionstudio/agent-chat";
@ -52,66 +57,69 @@ export function ModelPicker(props: ModelPickerProps) {
const harnesses = () => chatState.harnesses;
return (
<DropdownMenu placement="bottom-start" onOpenChange={(open) => open && refreshHarnesses()}>
<DropdownMenu placement="bottom-end" onOpenChange={(open) => open && refreshHarnesses()}>
<DropdownMenuTrigger
as="button"
type="button"
as={Button}
variant="ghost"
aria-label="Choose the agent and model"
class={`flex h-7 shrink-0 items-center rounded-md pl-0.5 pr-2 text-xs font-450 text-muted-foreground hover:bg-muted focus-ring ${props.class ?? ""}`}
class={cx("text-muted-foreground hover:bg-muted data-[expanded]:bg-muted", props.class)}
>
<span class="grid size-6 shrink-0 place-items-center overflow-clip">
<Icon name={harnessIcon(props.value?.harness)} />
</span>
<span class="max-w-40 truncate">{modelLabel(props.value)}</span>
</DropdownMenuTrigger>
<DropdownMenuPortal>
<DropdownMenuContent class="w-56">
<Show when={harnesses().length === 0}>
<DropdownMenuGroup>
<DropdownMenuContent class="w-48">
<DropdownMenuGroup>
<Show when={harnesses().length === 0}>
<DropdownMenuItem disabled>
<span class="min-w-0 flex-1 truncate text-muted-foreground">
{chatState.connection === "unavailable" ? "Chat runs in the desktop app" : "Connecting…"}
</span>
</DropdownMenuItem>
</DropdownMenuGroup>
</Show>
<For each={harnesses()}>
{(harness, index) => (
<>
<Show when={index() > 0}>
<DropdownMenuSeparator />
</Show>
<DropdownMenuGroup>
<DropdownMenuGroupLabel>{harness.label}</DropdownMenuGroupLabel>
<Show when={harness.status === "ready" && harness.detail}>
{/* "Update Claude Code": the harness works, but is older than we test against. */}
<p class="px-2 pb-1 text-[10px] leading-3.5 text-muted-foreground">{harness.detail}</p>
</Show>
<Show
when={harness.status === "ready"}
fallback={
<DropdownMenuItem disabled>
</Show>
<For each={harnesses()}>
{(harness) => (
<Show
when={harness.status === "ready"}
fallback={
<DropdownMenuItem disabled>
<Icon name={harnessIcon(harness.id)} />
<span class="min-w-0 flex-1 truncate">{harness.label}</span>
<DropdownMenuItemDetail class="truncate">{unavailableLabel(harness)}</DropdownMenuItemDetail>
</DropdownMenuItem>
}
>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<span class="flex items-center gap-1">
<Icon name={harnessIcon(harness.id)} />
<span class="min-w-0 flex-1 truncate text-muted-foreground">{unavailableLabel(harness)}</span>
</DropdownMenuItem>
}
>
<For each={harness.models}>
{(model) => (
<DropdownMenuItem onSelect={() => props.onSelect({ harness: harness.id, model: model.id })}>
<Icon name={harnessIcon(harness.id)} />
<span class="min-w-0 flex-1 truncate">{model.label}</span>
<Show when={props.value?.harness === harness.id && props.value?.model === model.id}>
<Icon name="confirm-check" class="size-6" />
</Show>
</DropdownMenuItem>
)}
</For>
</Show>
</DropdownMenuGroup>
</>
)}
</For>
<span class="min-w-0 truncate">{harness.label}</span>
</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent class="w-48">
<Show when={harness.detail}>
{/* "Update Claude Code": the harness works, but is older than we test against. */}
<p class="px-2 text-[10px] leading-3.5 text-muted-foreground">{harness.detail}</p>
</Show>
<DropdownMenuGroup>
<For each={harness.models}>
{(model) => (
<DropdownMenuItem onSelect={() => props.onSelect({ harness: harness.id, model: model.id })}>
<span class="min-w-0 flex-1 truncate">{model.label}</span>
<Show when={props.value?.harness === harness.id && props.value?.model === model.id}>
<Icon name="confirm-check" />
</Show>
</DropdownMenuItem>
)}
</For>
</DropdownMenuGroup>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
</Show>
)}
</For>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>

View File

@ -16,7 +16,7 @@ export function runningLabel(last: Item | undefined): string {
export function RunningIndicator(props: { last: Item | undefined }) {
return (
<div class="flex h-6 items-center text-[11px] text-muted-foreground" role="status" aria-live="polite">
<Icon name="spinner-loader" class="size-6 shrink-0 animate-spin" />
<Icon name="spinner-loader" class="shrink-0 animate-spin" />
<span class="agent-ellipsis">{runningLabel(props.last)}</span>
</div>
);

View File

@ -28,6 +28,7 @@ import {
import type { Transcript } from "@diffusionstudio/agent-chat";
import { store as settings } from "@/init";
import { track } from "@/lib/analytics";
import { createStoredSignal } from "@/lib/store";
import { projectRoute } from "@/hooks/use-project-route";
import type { ProjectInfo } from "@/projects";
@ -301,6 +302,13 @@ export type SendOptions = {
/** Sends a turn; resolves with the chat id as soon as the host accepted it. */
export async function send(options: SendOptions): Promise<string> {
const key = draftKey(options.projectId, options.chatId);
track("prompt_sent", {
new_chat: !options.chatId,
harness: options.model.harness,
model: options.model.model,
length: options.text.length,
attachments: options.attachments.length,
});
const optimistic: Item = {
id: `optimistic-${Date.now()}`,
kind: "user",
@ -383,7 +391,14 @@ export async function startChat(options: StartChatOptions): Promise<void> {
// is written directly: the editor reads it when it mounts.
settings.define<boolean>("layout.uiVisible", true).value = true;
try {
await send({ projectId, cwd: options.project.dir, chatId: null, text: options.text, attachments: options.attachments, model: options.model });
await send({
projectId,
cwd: options.project.dir,
chatId: null,
text: options.text,
attachments: options.attachments,
model: options.model,
});
} catch (error) {
setActiveChat(projectId, null);
setState("drafts", draftKey(projectId, null), {

View File

@ -4,16 +4,18 @@
import { Router, HashRouter, Route, useLocation } from '@solidjs/router';
import { ColorModeProvider } from '@kobalte/core';
import { Show, createEffect, type JSX } from 'solid-js';
import { Show, createEffect, createMemo, type JSX } from 'solid-js';
import { Toaster } from "@/components/ui/sonner";
import { AppContextMenu } from "@/components/app-context-menu";
import { AuthProvider, useAuth } from '@/context/auth';
import { CommandsProvider } from '@/context/commands';
import { CommandPalette, ReloadWindowCommand } from '@/components/commands';
import { PersistRoute } from '@/lib/persist-route';
import { useColorMode } from "@kobalte/core";
import { mainBridge } from "@/lib/ipc";
import { MAIN_CHANNELS } from "@desktop/main-channels";
import { EditorApi } from '@/dapi';
import { renderOverlay } from '@/context/render';
import { UpgradeDialog } from '@/components/upgrade-dialog';
import { PurchaseSuccess } from '@/components/purchase-success';
import { ScreenTooSmall } from '@/components/screen-too-small';
@ -62,6 +64,20 @@ function TitleBarColorMode() {
return null;
}
// A render goes on when the user closes the window, which only hides it;
// main is told, so the hidden window is not torn down under it once idle.
function ReportRendering() {
const rendering = createMemo(() => renderOverlay() !== null);
createEffect(() => {
if (window.desktop) {
mainBridge.call(MAIN_CHANNELS.WINDOW_SET_BUSY, { busy: rendering() });
}
});
return null;
}
function EnvironmentOverlays() {
const location = useLocation();
const onCheckoutPage = () => location.pathname.startsWith('/checkout');
@ -80,19 +96,22 @@ function App() {
<RouterComponent
root={(props) => (
<ColorModeProvider initialColorMode="dark">
<AppContextMenu>
<AuthProvider>
<AuthProvider>
<CommandsProvider>
{props.children}
<CommandPalette />
<ReloadWindowCommand />
<BootSplash />
<UpgradeDialog />
<PurchaseSuccess />
<EditorApi />
</AuthProvider>
</AppContextMenu>
</CommandsProvider>
</AuthProvider>
<Toaster />
<EnvironmentOverlays />
<PersistRoute />
<TitleBarColorMode />
<ReportRendering />
</ColorModeProvider>
)}
>

View File

@ -0,0 +1,109 @@
# Icons
Every `*.svg` in this folder is an icon. `<Icon name="trash" />` ([icon.tsx](../../components/ui/icon.tsx)) renders `trash.svg` at **25×25 px**. The file name is the icon name.
The icons are drawn on a **25×25 pixel grid** so they render sharp on 1x screens. The icons in the
[Figma UI library](https://www.figma.com/design/aLnWQdH3C7hqlQVYnsac9s/Diffusion-Studio---UI-Library?node-id=2270-51319&m=dev)
are 24×24 components (`icon.24.<name>`), so an icon has to be redrawn when it comes over, not just exported.
## Why 25 and not 24
The icons are mostly 1px lines. A 1px line is only sharp when it fills one pixel column exactly, i.e. when its
centerline sits on a half pixel (`x = 12.5` covers pixels 12–13). In a 24 frame the center is 12, so a centered
line covers half of pixel 11 and half of pixel 12 and renders as a 2px grey smear. In a 25 frame the center is
12.5, so centered 1px lines are sharp.
The Figma exports have two more problems:
- **Lines are outlined.** Each 1px stroke comes out as a filled shape with two parallel edges.
- **Odd scales.** Many icons were scaled, so their strokes are 0.8, 0.93 or 1.1 px instead of 1 px.
Neither can be fixed by just shifting the icon. Redraw it as clean 1px strokes instead.
## Converting a Figma icon
### 1. Export it
In Figma, select the icon component (e.g. `icon.24.trash`). Then either right-click → **Copy/Paste as → Copy as SVG**, or use **Export → SVG** in Dev Mode. You get something like:
```svg
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1331 5.93335C9.87541 5.93335 9.66647 6.14229 9.66647 6.40002C9.66647 6.65775 9.87541 6.86668 10.1331 6.86668H13.8665C14.1242 6.86668 14.3331 6.65775 14.3331 6.40002C14.3331 6.14229 14.1242 5.93335 13.8665 5.93335H10.1331ZM7.7998 8.26668C7.7998 8.00895 8.00874 7.80002 8.26647 7.80002H9.66647H14.3331H15.7331C15.9908 7.80002 16.1998 8.00895 16.1998 8.26668C16.1998 8.52441 15.9908 8.73335 15.7331 8.73335H15.2665V16.2C15.2665 16.7155 14.8486 17.1333 14.3331 17.1333H9.66647C9.15101 17.1333 8.73314 16.7155 8.73314 16.2V8.73335H8.26647C8.00874 8.73335 7.7998 8.52441 7.7998 8.26668ZM9.66647 8.73335H14.3331V16.2H9.66647V8.73335Z" fill="currentColor"/>
</svg>
```
### 2. Read the geometry
Work out what the outline is made of: the **centerline** of each stroke and the stroke width. Each pair of
parallel edges is one stroke, and its centerline is halfway between them. For the trash icon:
| Part | Edges in the 24 frame | Centerline | Width |
| --- | --- | --- | --- |
| Handle | y 5.93–6.87, x 9.67–14.33, round ends | y 6.4, x 10.13–13.87 | 0.93 |
| Lid | y 7.8–8.73, x 7.8–16.2, round ends | y 8.27, x 8.27–15.73 | 0.93 |
| Can sides | x 8.73–9.67 and 14.33–15.27 | x 9.2 and 14.8 | 0.93 |
| Can bottom | y 16.2–17.13, rounded outer corners | y 16.67 | 0.93 |
The 0.93 width means this icon was scaled; it becomes 1.
### 3. Redraw it in the 25 frame
Add 0.5 to every coordinate (12 → 12.5), then snap following these rules:
- **1px strokes on half pixels.** Every stroke is `stroke="currentColor"` with the default width of 1, and horizontal and vertical centerlines on `.5`. A stroked rect therefore has `.5` x/y and whole-number width/height: `<rect x="6.5" y="6.5" width="12" height="12"/>`.
- **Solid shapes on whole pixels.** Genuinely filled shapes (a solid triangle, a lock body) keep `fill="currentColor"`, with their straight edges on whole numbers.
- **Symmetric stays symmetric.** Mirror about `x = 12.5` / `y = 12.5`. A centered line goes on 12.5; a centered box has an odd outer size (e.g. 7…18 = 11, or 6…19 = 13).
- **Even stays even.** Repeated bars, dots or holes stay the same size with equal gaps. If the original spacing can't be both even and sharp (e.g. 2.5 px), use the nearest whole spacing that is.
- **Uniform weight.** Strokes of about 0.75–1.25 px all become 1 px, diagonals and curves included. Don't mix weights unless the design clearly does.
- **Stay close.** Move each part by at most ~0.5 px (1 px if the rules above need it). Keep corner radii, round vs square caps and joins (`stroke-linecap="round"`, `stroke-linejoin="round"`), opacity layers and arrowhead angles.
- **Diagonals and curves.** These can't be fully sharp. Run 45° lines through pixel centers (`.5, .5` points). Give circles centered on 12.5 a whole-number radius so their top, bottom, left and right edges are sharp.
For the trash icon:
| Part | Centerline + 0.5 | Snapped |
| --- | --- | --- |
| Handle | y 6.9, x 10.63–14.37 | `M10.5 6.5H14.5` (4 long, centered) |
| Lid | y 8.77, x 8.77–16.23 | `M8.5 8.5H16.5` (8 long, centered) |
| Sides | x 9.7 and 15.3 | x 9.5 and 15.5 (symmetric about 12.5) |
| Bottom | y 17.17 | y 17.5, corner radius 0.5 |
```svg
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.5 6.5H14.5M8.5 8.5H16.5M9.5 8.5V17C9.5 17.2761 9.7239 17.5 10 17.5H15C15.2761 17.5 15.5 17.2761 15.5 17V8.5" stroke="currentColor" stroke-linecap="round"/>
</svg>
```
### 4. Clean up
The root element is always `<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">`, with no
`width`/`height`. Beyond that:
- **Colors.** Use `currentColor` instead of Figma's hard-coded colors, so the icon follows the text color. Keep a fixed color only when the design really needs one.
- **No wrappers.** Remove `transform`s, `clipPath`s that don't clip anything, masks, `<g>` wrappers and Figma ids.
- **Short coordinates.** Use absolute path commands and at most 4 decimals.
### 5. Check it at 1x
Render the icon at 25 px with a device pixel ratio of 1 and zoom in with nearest-neighbour scaling:
```bash
rsvg-convert -w 25 -h 25 -b white trash.svg | magick - -filter point -resize 1600% /tmp/trash-1x.png
```
Straight lines should be solid single-pixel rows and columns, with no grey row next to them. Only diagonals and curves
may show grey pixels. Compare the result with the Figma original next to it at the same zoom; apart from the sharpness,
they should look the same.
### 6. Add it
Save the file as `<name>.svg`, using the Figma name without `icon.24.` (`icon.24.trash` → `trash.svg`). Then use it as
`<Icon name="trash" />`. Remove icons from this folder once nothing references them.
## Exceptions
A few icons stay on their own grid on purpose:
- **Brand logos** (`agent.*`, `editor.*`, `claude`, `codex`, `social.*`, `diffusion-logo*`) are moved to the 25 frame without reshaping.
- **The `large-*` provider logos** are left as exported.
- **`frame`** (20×20, shown at 20 px), **`folder-thumbnail`** (32×24) and **`vertical-knob-line`** are drawn for their own sizes.
- **`line-join-*`** use a 15×15 grid because they are shown at 14 px.

View File

@ -1,3 +0,0 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.59091 5.75C7.02192 5.75 5.75 7.02192 5.75 8.59091C5.75 10.1599 7.02192 11.4318 8.59091 11.4318C10.1599 11.4318 11.4318 10.1599 11.4318 8.59091C11.4318 7.02192 10.1599 5.75 8.59091 5.75ZM6.88636 8.59091C6.88636 7.64951 7.64951 6.88636 8.59091 6.88636C9.53231 6.88636 10.2955 7.64951 10.2955 8.59091C10.2955 9.53231 9.53231 10.2955 8.59091 10.2955C7.64951 10.2955 6.88636 9.53231 6.88636 8.59091ZM15.4091 5.75C13.8401 5.75 12.5682 7.02192 12.5682 8.59091C12.5682 10.1599 13.8401 11.4318 15.4091 11.4318C16.9781 11.4318 18.25 10.1599 18.25 8.59091C18.25 7.02192 16.9781 5.75 15.4091 5.75ZM13.7045 8.59091C13.7045 7.64951 14.4677 6.88636 15.4091 6.88636C16.3505 6.88636 17.1136 7.64951 17.1136 8.59091C17.1136 9.53231 16.3505 10.2955 15.4091 10.2955C14.4677 10.2955 13.7045 9.53231 13.7045 8.59091ZM5.75 15.4091C5.75 13.8401 7.02192 12.5682 8.59091 12.5682C10.1599 12.5682 11.4318 13.8401 11.4318 15.4091C11.4318 16.9781 10.1599 18.25 8.59091 18.25C7.02192 18.25 5.75 16.9781 5.75 15.4091ZM8.59091 13.7045C7.64951 13.7045 6.88636 14.4677 6.88636 15.4091C6.88636 16.3505 7.64951 17.1136 8.59091 17.1136C9.53231 17.1136 10.2955 16.3505 10.2955 15.4091C10.2955 14.4677 9.53231 13.7045 8.59091 13.7045ZM15.4091 12.5682C13.8401 12.5682 12.5682 13.8401 12.5682 15.4091C12.5682 16.9781 13.8401 18.25 15.4091 18.25C16.9781 18.25 18.25 16.9781 18.25 15.4091C18.25 13.8401 16.9781 12.5682 15.4091 12.5682ZM13.7045 15.4091C13.7045 14.4677 14.4677 13.7045 15.4091 13.7045C16.3505 13.7045 17.1136 14.4677 17.1136 15.4091C17.1136 16.3505 16.3505 17.1136 15.4091 17.1136C14.4677 17.1136 13.7045 16.3505 13.7045 15.4091Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,3 +0,0 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.3069 5.57328C17.3069 5.3671 17.1397 5.19995 16.9335 5.19995C16.7274 5.19995 16.5602 5.3671 16.5602 5.57328V6.13329H16.0002C15.794 6.13329 15.6269 6.30043 15.6269 6.50662C15.6269 6.7128 15.794 6.87996 16.0002 6.87996H16.5602V7.43996C16.5602 7.64614 16.7274 7.81329 16.9335 7.81329C17.1397 7.81329 17.3069 7.64614 17.3069 7.43996V6.87996H17.8669C18.073 6.87996 18.2402 6.7128 18.2402 6.50662C18.2402 6.30043 18.073 6.13329 17.8669 6.13329H17.3069V5.57328ZM15.3969 8.0433C15.5791 8.22554 15.5791 8.52102 15.3969 8.70327L14.4636 9.6366C14.2813 9.81884 13.9858 9.81884 13.8036 9.6366C13.6213 9.45436 13.6213 9.15888 13.8036 8.97663L14.7368 8.04331C14.9191 7.86106 15.2146 7.86106 15.3969 8.0433ZM13.5302 9.90997C13.7124 10.0922 13.7124 10.3877 13.5302 10.5699L6.99684 17.1032C6.8146 17.2855 6.51913 17.2855 6.33688 17.1032C6.15463 16.9211 6.15463 16.6256 6.33688 16.4433L12.8702 9.90997C13.0525 9.72772 13.348 9.72772 13.5302 9.90997ZM16.9335 9.86662C17.1397 9.86662 17.3069 10.0338 17.3069 10.24V10.8H17.8669C18.073 10.8 18.2402 10.9671 18.2402 11.1733C18.2402 11.3795 18.073 11.5466 17.8669 11.5466H17.3069V12.1066C17.3069 12.3128 17.1397 12.48 16.9335 12.48C16.7274 12.48 16.5602 12.3128 16.5602 12.1066V11.5466H16.0002C15.794 11.5466 15.6269 11.3795 15.6269 11.1733C15.6269 10.9671 15.794 10.8 16.0002 10.8H16.5602V10.24C16.5602 10.0338 16.7274 9.86662 16.9335 9.86662ZM12.6402 5.57328C12.6402 5.3671 12.4731 5.19995 12.2669 5.19995C12.0607 5.19995 11.8935 5.3671 11.8935 5.57328V6.13329H11.3335C11.1274 6.13329 10.9602 6.30043 10.9602 6.50662C10.9602 6.7128 11.1274 6.87996 11.3335 6.87996H11.8935V7.43996C11.8935 7.64614 12.0607 7.81329 12.2669 7.81329C12.4731 7.81329 12.6402 7.64614 12.6402 7.43996V6.87996H13.2002C13.4064 6.87996 13.5735 6.7128 13.5735 6.50662C13.5735 6.30043 13.4064 6.13329 13.2002 6.13329H12.6402V5.57328Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,3 +0,0 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.0444 11.6108V8.70752C16.0444 8.21512 15.6452 7.81592 15.1528 7.81592H8.84521C8.35284 7.81598 7.95368 8.21515 7.95361 8.70752V11.6167C7.95361 11.8254 8.02666 12.0281 8.15967 12.188L11.314 15.978C11.6709 16.4068 12.3289 16.4066 12.6851 15.978L15.8384 12.1812C15.9715 12.0209 16.0444 11.8187 16.0444 11.6108ZM16.9653 11.6108C16.9653 12.0339 16.8165 12.4439 16.5464 12.769L13.3921 16.5659C12.6677 17.4376 11.3304 17.4367 10.606 16.5659L7.45264 12.7759C7.18173 12.4502 7.03369 12.0396 7.03369 11.6167V8.70752C7.03375 7.70705 7.84474 6.89606 8.84521 6.896H15.1528C16.1533 6.896 16.9653 7.707 16.9653 8.70752V11.6108Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 727 B

View File

@ -1,18 +1,18 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0_6512_20130" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="7" y="7" width="10" height="10">
<rect x="7" y="7" width="10" height="10" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0_6512_20130" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="7.5" y="7.5" width="10" height="10">
<rect x="7.5" y="7.5" width="10" height="10" fill="currentColor"/>
</mask>
<g mask="url(#mask0_6512_20130)">
<path opacity="0.2" fill-rule="evenodd" clip-rule="evenodd" d="M18.3021 7.51951C13.3663 8.86561 8.86513 13.3668 7.51902 18.3026L6.89307 18.1318C8.29963 12.9745 12.974 8.30012 18.1313 6.89355L18.3021 7.51951Z" fill="currentColor"/>
<path opacity="0.25" fill-rule="evenodd" clip-rule="evenodd" d="M17.9373 6.96847C12.9463 8.36776 8.36727 12.9468 6.96799 17.9378L6.34326 17.7627C7.80369 12.5536 12.5531 7.80418 17.7623 6.34375L17.9373 6.96847Z" fill="currentColor"/>
<path opacity="0.3" fill-rule="evenodd" clip-rule="evenodd" d="M17.4694 6.44718C12.5006 7.92183 7.92892 12.4911 6.44997 17.4593L5.82812 17.2743C7.3696 12.0959 12.1057 7.36226 17.2847 5.8252L17.4694 6.44718Z" fill="currentColor"/>
<path opacity="0.35" fill-rule="evenodd" clip-rule="evenodd" d="M16.8548 5.97539C12.0074 7.55193 7.55399 12.0044 5.97583 16.8516L5.35889 16.6508C7.00128 11.6063 11.6094 6.99912 16.6541 5.3584L16.8548 5.97539Z" fill="currentColor"/>
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M16.1712 5.53649C11.5009 7.21148 7.22263 11.4862 5.54162 16.1557L4.93115 15.936C6.67772 11.0844 11.0994 6.66618 15.9522 4.92578L16.1712 5.53649Z" fill="currentColor"/>
<path opacity="0.45" fill-rule="evenodd" clip-rule="evenodd" d="M15.3697 5.15694C10.9549 6.92615 6.93187 10.9475 5.15972 15.3618L4.55762 15.1201C6.39573 10.5415 10.5491 6.38982 15.1283 4.55469L15.3697 5.15694Z" fill="currentColor"/>
<path opacity="0.5" fill-rule="evenodd" clip-rule="evenodd" d="M14.4678 4.8427C10.3857 6.67852 6.68702 10.3748 4.84737 14.4563L4.25586 14.1897C6.16062 9.96381 9.97495 6.15183 14.2017 4.25098L14.4678 4.8427Z" fill="currentColor"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M13.4295 4.62427C9.77812 6.48028 6.48829 9.76834 4.62945 13.419L4.05127 13.1246C5.97238 9.35165 9.3617 5.96413 13.1355 4.0459L13.4295 4.62427Z" fill="currentColor"/>
<path opacity="0.7" fill-rule="evenodd" clip-rule="evenodd" d="M12.2033 4.55519C9.12119 6.34523 6.35302 9.11197 4.56084 12.1934L4 11.8672C5.84878 8.68844 8.69792 5.84075 11.8774 3.99414L12.2033 4.55519Z" fill="currentColor"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M10.7007 4.73387C8.3852 6.29848 6.29628 8.38762 4.73196 10.7032L4.19434 10.3401C5.80509 7.95567 7.95321 5.80735 10.3374 4.19629L10.7007 4.73387Z" fill="currentColor"/>
<path opacity="0.2" fill-rule="evenodd" clip-rule="evenodd" d="M18.8021 8.0195C13.8663 9.3656 9.3651 13.8668 8.019 18.8026L7.3931 18.6318C8.7996 13.4745 13.474 8.8001 18.6313 7.3936L18.8021 8.0195Z" fill="currentColor"/>
<path opacity="0.25" fill-rule="evenodd" clip-rule="evenodd" d="M18.4373 7.4685C13.4463 8.8678 8.8673 13.4468 7.468 18.4378L6.8433 18.2627C8.3037 13.0536 13.0531 8.3042 18.2623 6.8438L18.4373 7.4685Z" fill="currentColor"/>
<path opacity="0.3" fill-rule="evenodd" clip-rule="evenodd" d="M17.9694 6.9472C13.0006 8.4218 8.4289 12.9911 6.95 17.9593L6.3281 17.7743C7.8696 12.5959 12.6057 7.8623 17.7847 6.3252L17.9694 6.9472Z" fill="currentColor"/>
<path opacity="0.35" fill-rule="evenodd" clip-rule="evenodd" d="M17.3548 6.4754C12.5074 8.0519 8.054 12.5044 6.4758 17.3516L5.8589 17.1508C7.5013 12.1063 12.1094 7.4991 17.1541 5.8584L17.3548 6.4754Z" fill="currentColor"/>
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M16.6712 6.0365C12.0009 7.7115 7.7226 11.9862 6.0416 16.6557L5.4311 16.436C7.1777 11.5844 11.5994 7.1662 16.4522 5.4258L16.6712 6.0365Z" fill="currentColor"/>
<path opacity="0.45" fill-rule="evenodd" clip-rule="evenodd" d="M15.8697 5.6569C11.4549 7.4261 7.4319 11.4475 5.6597 15.8618L5.0576 15.6201C6.8957 11.0415 11.0491 6.8898 15.6283 5.0547L15.8697 5.6569Z" fill="currentColor"/>
<path opacity="0.5" fill-rule="evenodd" clip-rule="evenodd" d="M14.9678 5.3427C10.8857 7.1785 7.187 10.8748 5.3474 14.9563L4.7559 14.6897C6.6606 10.4638 10.4749 6.6518 14.7017 4.751L14.9678 5.3427Z" fill="currentColor"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M13.9295 5.1243C10.2781 6.9803 6.9883 10.2683 5.1295 13.919L4.5513 13.6246C6.4724 9.8516 9.8617 6.4641 13.6355 4.5459L13.9295 5.1243Z" fill="currentColor"/>
<path opacity="0.7" fill-rule="evenodd" clip-rule="evenodd" d="M12.7033 5.0552C9.6212 6.8452 6.853 9.612 5.0608 12.6934L4.5 12.3672C6.3488 9.1884 9.1979 6.3407 12.3774 4.4941L12.7033 5.0552Z" fill="currentColor"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M11.2007 5.2339C8.8852 6.7985 6.7963 8.8876 5.232 11.2032L4.6943 10.8401C6.3051 8.4557 8.4532 6.3073 10.8374 4.6963L11.2007 5.2339Z" fill="currentColor"/>
</g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.5 6.50049C17.0523 6.50049 17.5 6.9482 17.5 7.50049V16.5005C17.4997 17.0525 17.0521 17.5005 16.5 17.5005H7.5C6.94788 17.5005 6.50026 17.0525 6.5 16.5005L6.5 7.50049C6.5 6.9482 6.94772 6.50049 7.5 6.50049L16.5 6.50049ZM7.5 16.5005H16.5V7.50049L7.5 7.50049L7.5 16.5005Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 7.0005C17.5523 7.0005 18 7.4482 18 8.0005V17.0005C17.9997 17.5525 17.5521 18.0005 17 18.0005H8C7.4479 18.0005 7.0003 17.5525 7 17.0005L7 8.0005C7 7.4482 7.4477 7.0005 8 7.0005L17 7.0005ZM8 17.0005H17V8.0005L8 8.0005L8 17.0005Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.4363 11.1433H19.25V12.8567H17.4375V14.5294H16.5391V16.1429H15.625V14.5294H14.7266V16.1429H13.8125V14.5294H10.1875V16.1429H9.274V14.5294H8.375V16.1429H7.4609V14.5294H6.5625V12.8562H4.75V11.1438H6.5625V7.85714H17.4363V11.1433ZM8.375 11.1433H9.274V9.57063H8.375V11.1433ZM14.7248 11.1433H15.625V9.57063H14.7248V11.1433Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 8H18V12H20V14H18V15H17V17H16V15H15V17H14V15H11V17H10V15H9V17H8V15H7V14H5V12H7V8ZM9 10V12H10V10H9ZM15 10V12H16V10H15Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 292 B

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.79816 5.50775C10.34 5.28508 10.9298 5.20472 11.5115 5.27433C12.2613 5.36038 12.9296 5.6793 13.5162 6.23052C13.5241 6.23801 13.5338 6.24341 13.5443 6.24626C13.5548 6.24911 13.5658 6.2493 13.5764 6.24683C14.3684 6.05222 15.13 6.12084 15.8607 6.4527L15.8962 6.46957L15.9828 6.51232C16.7461 6.90773 17.2934 7.50789 17.6241 8.31109C17.7805 8.69301 17.8593 9.0918 17.8609 9.5069C17.872 9.81599 17.8379 10.125 17.7597 10.4243C17.7558 10.4395 17.7559 10.4555 17.7598 10.4707C17.7638 10.486 17.7714 10.5 17.7822 10.5115C18.2244 10.9598 18.5319 11.5232 18.6698 12.1376C18.8864 13.2068 18.6642 14.1709 18.0044 15.0287L17.902 15.1524C17.465 15.6528 16.8914 16.0146 16.2517 16.1935C16.2377 16.1975 16.2249 16.2049 16.2143 16.2148C16.2037 16.2248 16.1957 16.2372 16.1909 16.2509C16.0475 16.6649 15.9035 17.0181 15.6357 17.3713C14.9613 18.2612 13.9696 18.7561 12.8525 18.7499C11.9621 18.7454 11.1729 18.4198 10.4844 17.7735C10.474 17.7639 10.4612 17.7572 10.4474 17.7541C10.4336 17.7509 10.4192 17.7514 10.4057 17.7555C10.1143 17.8494 9.82066 17.8629 9.50342 17.8596C8.99658 17.8555 8.49736 17.7358 8.04375 17.5097C7.56894 17.2742 7.15562 16.9312 6.83663 16.5079C6.72245 16.3566 6.60939 16.2143 6.5267 16.0462C6.41266 15.8143 6.31948 15.5728 6.24827 15.3245C6.09874 14.7602 6.09545 14.1671 6.2387 13.6011C6.24333 13.5878 6.24487 13.5735 6.2432 13.5595C6.24042 13.5455 6.2331 13.5329 6.22239 13.5235C5.87566 13.1728 5.61061 12.7499 5.44615 12.2849C5.33727 11.9987 5.27406 11.6971 5.25884 11.3912C5.23164 10.9884 5.26731 10.5838 5.36459 10.192C5.61771 9.35728 6.10089 8.70257 6.81413 8.22729C6.97276 8.12154 7.12351 8.03942 7.26525 7.98092C7.42613 7.91343 7.58756 7.85718 7.74956 7.80993C7.76115 7.8065 7.77169 7.80022 7.78024 7.79168C7.78879 7.78313 7.79506 7.77259 7.7985 7.761C7.92134 7.31945 8.13261 6.90745 8.41949 6.55C8.80199 6.07416 9.26154 5.72655 9.79816 5.50775ZM9.34592 9.92313C9.28311 9.81326 9.17923 9.73284 9.05713 9.69956C8.93503 9.66628 8.8047 9.68287 8.69483 9.74567C8.58496 9.80847 8.50454 9.91235 8.47125 10.0344C8.43797 10.1565 8.45456 10.2869 8.51736 10.3967L9.47023 12.0644L8.52074 13.6664C8.46253 13.7749 8.44851 13.9017 8.48161 14.0204C8.51471 14.139 8.59238 14.2403 8.69838 14.303C8.80439 14.3657 8.93053 14.3851 9.05047 14.357C9.1704 14.3289 9.27484 14.2556 9.34198 14.1523L10.4332 12.3119C10.4763 12.2394 10.4993 12.1567 10.5 12.0723C10.5007 11.9879 10.479 11.9049 10.4372 11.8316L9.34592 9.92313ZM12.4093 13.4329C12.2877 13.4402 12.1736 13.4935 12.0901 13.5821C12.0066 13.6707 11.9601 13.7879 11.9601 13.9096C11.9601 14.0314 12.0066 14.1485 12.0901 14.2371C12.1736 14.3257 12.2877 14.3791 12.4093 14.3863H15.1362C15.2587 14.3804 15.3742 14.3275 15.4588 14.2387C15.5434 14.1499 15.5906 14.032 15.5906 13.9093C15.5906 13.7867 15.5434 13.6688 15.4588 13.58C15.3742 13.4912 15.2587 13.4383 15.1362 13.4324H12.4093V13.4329Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.2982 6.0077C10.84 5.7851 11.4298 5.7047 12.0115 5.7743C12.7613 5.8604 13.4296 6.1793 14.0162 6.7305C14.0241 6.738 14.0338 6.7434 14.0443 6.7463C14.0548 6.7491 14.0658 6.7493 14.0764 6.7468C14.8684 6.5522 15.63 6.6208 16.3607 6.9527L16.3962 6.9696L16.4828 7.0123C17.2461 7.4077 17.7934 8.0079 18.1241 8.8111C18.2805 9.193 18.3593 9.5918 18.3609 10.0069C18.372 10.316 18.3379 10.625 18.2597 10.9243C18.2558 10.9395 18.2559 10.9555 18.2598 10.9707C18.2638 10.986 18.2714 11 18.2822 11.0115C18.7244 11.4598 19.0319 12.0232 19.1698 12.6376C19.3864 13.7068 19.1642 14.6709 18.5044 15.5287L18.402 15.6524C17.965 16.1528 17.3914 16.5146 16.7517 16.6935C16.7377 16.6975 16.7249 16.7049 16.7143 16.7148C16.7037 16.7248 16.6957 16.7372 16.6909 16.7509C16.5475 17.1649 16.4035 17.5181 16.1357 17.8713C15.4613 18.7612 14.4696 19.2561 13.3525 19.2499C12.4621 19.2454 11.6729 18.9198 10.9844 18.2735C10.974 18.2639 10.9612 18.2572 10.9474 18.2541C10.9336 18.2509 10.9192 18.2514 10.9057 18.2555C10.6143 18.3494 10.3207 18.3629 10.0034 18.3596C9.4966 18.3555 8.9974 18.2358 8.5437 18.0097C8.0689 17.7742 7.6556 17.4312 7.3366 17.0079C7.2225 16.8566 7.1094 16.7143 7.0267 16.5462C6.9127 16.3143 6.8195 16.0728 6.7483 15.8245C6.5987 15.2602 6.5954 14.6671 6.7387 14.1011C6.7433 14.0878 6.7449 14.0735 6.7432 14.0595C6.7404 14.0455 6.7331 14.0329 6.7224 14.0235C6.3757 13.6728 6.1106 13.2499 5.9462 12.7849C5.8373 12.4987 5.7741 12.1971 5.7588 11.8912C5.7316 11.4884 5.7673 11.0838 5.8646 10.692C6.1177 9.8573 6.6009 9.2026 7.3141 8.7273C7.4728 8.6215 7.6235 8.5394 7.7652 8.4809C7.9261 8.4134 8.0876 8.3572 8.2496 8.3099C8.2612 8.3065 8.2717 8.3002 8.2802 8.2917C8.2888 8.2831 8.2951 8.2726 8.2985 8.261C8.4213 7.8194 8.6326 7.4074 8.9195 7.05C9.302 6.5742 9.7615 6.2265 10.2982 6.0077ZM9.8459 10.4231C9.7831 10.3133 9.6792 10.2328 9.5571 10.1996C9.435 10.1663 9.3047 10.1829 9.1948 10.2457C9.085 10.3085 9.0045 10.4123 8.9712 10.5344C8.938 10.6565 8.9546 10.7869 9.0174 10.8967L9.9702 12.5644L9.0207 14.1664C8.9625 14.2749 8.9485 14.4017 8.9816 14.5204C9.0147 14.639 9.0924 14.7403 9.1984 14.803C9.3044 14.8657 9.4305 14.8851 9.5505 14.857C9.6704 14.8289 9.7748 14.7556 9.842 14.6523L10.9332 12.8119C10.9763 12.7394 10.9993 12.6567 11 12.5723C11.0007 12.4879 10.979 12.4049 10.9372 12.3316L9.8459 10.4231ZM12.9093 13.9329C12.7877 13.9402 12.6736 13.9935 12.5901 14.0821C12.5066 14.1707 12.4601 14.2879 12.4601 14.4096C12.4601 14.5314 12.5066 14.6485 12.5901 14.7371C12.6736 14.8257 12.7877 14.8791 12.9093 14.8863H15.6362C15.7587 14.8804 15.8742 14.8275 15.9588 14.7387C16.0434 14.6499 16.0906 14.532 16.0906 14.4093C16.0906 14.2867 16.0434 14.1688 15.9588 14.08C15.8742 13.9912 15.7587 13.9383 15.6362 13.9324H12.9093V13.9329Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.2943 8.19548L12.4894 4.84384C12.3978 4.791 12.2938 4.76318 12.188 4.76318C12.0822 4.76318 11.9783 4.791 11.8866 4.84384L6.08244 8.19548C6.00538 8.23997 5.94136 8.30395 5.89683 8.38098C5.85229 8.45802 5.82879 8.54542 5.82869 8.63441V15.3919C5.82879 15.4808 5.85229 15.5682 5.89683 15.6453C5.94136 15.7223 6.00538 15.7863 6.08244 15.8308L11.8873 19.1824C11.9789 19.2353 12.0829 19.2632 12.1887 19.2632C12.2945 19.2632 12.3985 19.2353 12.4901 19.1824L18.295 15.8315C18.372 15.787 18.436 15.723 18.4806 15.646C18.5251 15.5689 18.5486 15.4815 18.5487 15.3925V8.63372C18.5486 8.54473 18.5251 8.45734 18.4806 8.3803C18.436 8.30326 18.372 8.23929 18.295 8.19479L18.2943 8.19548ZM17.9301 8.90531L12.3262 18.6111C12.2885 18.6763 12.1884 18.6495 12.1884 18.5734V12.2185C12.1883 12.156 12.1718 12.0945 12.1405 12.0404C12.1092 11.9862 12.0642 11.9412 12.01 11.9099L6.50697 8.73385C6.44113 8.69544 6.46788 8.59531 6.544 8.59531H17.7504C17.9102 8.59531 18.0097 8.76746 17.9301 8.90531Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.7943 8.6955L12.9894 5.3438C12.8978 5.291 12.7938 5.2632 12.688 5.2632C12.5822 5.2632 12.4783 5.291 12.3866 5.3438L6.5824 8.6955C6.5054 8.74 6.4414 8.804 6.3968 8.881C6.3523 8.958 6.3288 9.0454 6.3287 9.1344V15.8919C6.3288 15.9808 6.3523 16.0682 6.3968 16.1453C6.4414 16.2223 6.5054 16.2863 6.5824 16.3308L12.3873 19.6824C12.4789 19.7353 12.5829 19.7632 12.6887 19.7632C12.7945 19.7632 12.8985 19.7353 12.9901 19.6824L18.795 16.3315C18.872 16.287 18.936 16.223 18.9806 16.146C19.0251 16.0689 19.0486 15.9815 19.0487 15.8925V9.1337C19.0486 9.0447 19.0251 8.9573 18.9806 8.8803C18.936 8.8033 18.872 8.7393 18.795 8.6948L18.7943 8.6955ZM18.4301 9.4053L12.8262 19.1111C12.7885 19.1763 12.6884 19.1495 12.6884 19.0734V12.7185C12.6883 12.656 12.6718 12.5945 12.6405 12.5404C12.6092 12.4862 12.5642 12.4412 12.51 12.4099L7.007 9.2339C6.9411 9.1954 6.9679 9.0953 7.044 9.0953H18.2504C18.4102 9.0953 18.5097 9.2675 18.4301 9.4053Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.4849 17.9678C18.2386 18.5331 19.3693 18.1562 18.3331 17.1195C15.2231 14.1051 15.8834 5.81376 12.0207 5.81376C8.15802 5.81376 8.81727 14.1051 5.70832 17.1201C4.57769 18.2501 5.80226 18.5325 6.55601 17.9672C9.47653 15.9889 9.28809 12.503 12.0207 12.503C14.7528 12.503 14.5644 15.9889 17.4849 17.9678Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.9849 18.4678C18.7386 19.0331 19.8693 18.6562 18.8331 17.6195C15.7231 14.6051 16.3834 6.3138 12.5207 6.3138C8.658 6.3138 9.3173 14.6051 6.2083 17.6201C5.0777 18.7501 6.3023 19.0325 7.056 18.4672C9.9765 16.4889 9.7881 13.003 12.5207 13.003C15.2528 13.003 15.0644 16.4889 17.9849 18.4678Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 462 B

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.2793 5.25C16.9345 5.25 17.5631 5.51032 18.0264 5.97363C18.4897 6.43694 18.75 7.06549 18.75 7.7207V16.2793C18.75 16.9345 18.4897 17.5631 18.0264 18.0264C17.5631 18.4897 16.9345 18.75 16.2793 18.75H7.7207C7.06549 18.75 6.43694 18.4897 5.97363 18.0264C5.51032 17.5631 5.25 16.9345 5.25 16.2793V7.7207C5.25 7.06549 5.51032 6.43694 5.97363 5.97363C6.43694 5.51032 7.06549 5.25 7.7207 5.25H16.2793ZM7.64648 6.0625C7.22638 6.0625 6.82342 6.22931 6.52637 6.52637C6.22931 6.82342 6.0625 7.22638 6.0625 7.64648V16.3535C6.0625 16.7736 6.22931 17.1766 6.52637 17.4736C6.82342 17.7707 7.22638 17.9375 7.64648 17.9375H16.3535C16.7736 17.9375 17.1766 17.7707 17.4736 17.4736C17.7707 17.1766 17.9375 16.7736 17.9375 16.3535V7.64648C17.9375 7.22638 17.7707 6.82342 17.4736 6.52637C17.1766 6.22931 16.7736 6.0625 16.3535 6.0625H7.64648ZM14.6963 11.0762V13.251L9.32031 15.8359V14.2607L13.6807 12.1641L9.32129 10.0674V8.49121L14.6963 11.0762Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.7793 5.75C17.4345 5.75 18.0631 6.0103 18.5264 6.4736C18.9897 6.9369 19.25 7.5655 19.25 8.2207V16.7793C19.25 17.4345 18.9897 18.0631 18.5264 18.5264C18.0631 18.9897 17.4345 19.25 16.7793 19.25H8.2207C7.5655 19.25 6.9369 18.9897 6.4736 18.5264C6.0103 18.0631 5.75 17.4345 5.75 16.7793V8.2207C5.75 7.5655 6.0103 6.9369 6.4736 6.4736C6.9369 6.0103 7.5655 5.75 8.2207 5.75H16.7793ZM8.1465 6.5625C7.7264 6.5625 7.3234 6.7293 7.0264 7.0264C6.7293 7.3234 6.5625 7.7264 6.5625 8.1465V16.8535C6.5625 17.2736 6.7293 17.6766 7.0264 17.9736C7.3234 18.2707 7.7264 18.4375 8.1465 18.4375H16.8535C17.2736 18.4375 17.6766 18.2707 17.9736 17.9736C18.2707 17.6766 18.4375 17.2736 18.4375 16.8535V8.1465C18.4375 7.7264 18.2707 7.3234 17.9736 7.0264C17.6766 6.7293 17.2736 6.5625 16.8535 6.5625H8.1465ZM15.1963 11.5762V13.751L9.8203 16.3359V14.7607L14.1807 12.6641L9.8213 10.5674V8.9912L15.1963 11.5762Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1019 B

View File

@ -1,5 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(4 4)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.666 3.9987H5.33268V11.9987H10.666V3.9987ZM13.3327 14.6654H2.66602V1.33203H13.3327V14.6654Z" fill="currentColor"/>
</g>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 9H10V16H15V9ZM18 19H7V6H18V19Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 187 B

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.126 6.37019C12.744 5.70777 13.7011 5.55541 14.7939 5.67683C15.9085 5.80098 16.738 6.15524 17.2627 6.81941C17.7756 7.46738 17.8906 8.28293 17.8906 9.07136C17.8906 9.58953 17.8422 10.1112 17.6602 10.5714C17.7199 10.7779 17.749 10.9603 17.7744 11.1261C17.7853 11.1949 17.7968 11.2609 17.8086 11.3243C18.6457 11.6734 19.1875 12.6574 19.25 13.2227V14.919C19.2497 15.6134 16.2128 18.3585 11.998 18.3585C7.86451 18.3584 4.86425 15.7182 4.75 14.961V13.1954C4.82703 12.6263 5.36386 11.6678 6.18945 11.3243C6.20123 11.2609 6.2108 11.194 6.22168 11.1261C6.24795 10.9603 6.27615 10.7779 6.33594 10.5714C6.15392 10.1112 6.1055 9.58949 6.10547 9.07136C6.10547 8.28293 6.22137 7.46738 6.7334 6.81941C7.25808 6.1552 8.0876 5.80101 9.20215 5.67683C10.295 5.55541 11.252 5.70788 11.8701 6.37019C11.9154 6.41814 11.9572 6.46804 11.9961 6.51961C12.036 6.46795 12.0816 6.41822 12.126 6.37019ZM12 10.4444C11.8686 10.6912 11.7024 10.9184 11.5068 11.1182C10.9178 11.7199 10.0902 12.0167 9.05078 12.0167C8.46008 12.0167 7.9312 11.9423 7.48633 11.752L7.46484 11.8575V15.7139C7.84455 16.0067 9.93184 17.0127 11.998 17.0128C14.0641 17.0128 16.1521 16.0068 16.5312 15.7139V11.8575L16.5107 11.752C16.0667 11.9423 15.5362 12.0167 14.9453 12.0167C13.9068 12.0167 13.0792 11.72 12.4893 11.1182C12.2948 10.9183 12.1301 10.6911 12 10.4444ZM10.3594 12.9542C10.5458 12.9542 10.7246 13.0284 10.8564 13.1602C10.9883 13.292 11.0624 13.4709 11.0625 13.6573V15.0645C11.0625 15.251 10.9882 15.4297 10.8564 15.5616C10.7246 15.6935 10.5459 15.7677 10.3594 15.7677C10.1729 15.7677 9.99417 15.6935 9.8623 15.5616C9.73051 15.4297 9.65625 15.251 9.65625 15.0645V13.6573C9.65631 13.4709 9.7305 13.292 9.8623 13.1602C9.99415 13.0284 10.173 12.9542 10.3594 12.9542ZM13.6406 12.9542C13.827 12.9542 14.0058 13.0284 14.1377 13.1602C14.2695 13.292 14.3437 13.4709 14.3438 13.6573V15.0645C14.3438 15.251 14.2695 15.4297 14.1377 15.5616C14.0058 15.6935 13.8271 15.7677 13.6406 15.7677C13.4541 15.7677 13.2754 15.6935 13.1436 15.5616C13.0118 15.4297 12.9375 15.251 12.9375 15.0645V13.6573C12.9376 13.4709 13.0117 13.292 13.1436 13.1602C13.2754 13.0284 13.4542 12.9542 13.6406 12.9542ZM10.8779 7.29695C10.7029 7.11036 10.3001 6.92332 9.35352 7.0284C8.43074 7.13076 8.01391 7.39411 7.80176 7.66218C7.57791 7.94493 7.4668 8.37808 7.4668 9.07136C7.46685 9.7897 7.58391 10.1323 7.74609 10.3136C7.89295 10.4775 8.21657 10.6573 9.05273 10.6573C9.82577 10.6573 10.2661 10.4435 10.5371 10.1671C10.8225 9.87525 11.0151 9.4177 11.0967 8.75984C11.2027 7.91266 11.0628 7.4954 10.8779 7.29695ZM14.6436 7.0284C13.6978 6.92331 13.2951 7.11033 13.1201 7.29695C12.9353 7.4954 12.7944 7.91267 12.9004 8.75984C12.9828 9.41765 13.1756 9.87525 13.4609 10.1671C13.7319 10.4435 14.1714 10.6573 14.9453 10.6573C15.7806 10.6573 16.1051 10.4775 16.252 10.3136C16.4141 10.1323 16.5312 9.7897 16.5312 9.07136C16.5312 8.37808 16.4201 7.94493 16.1963 7.66218C15.9851 7.39397 15.5678 7.1308 14.6436 7.0284Z" fill="currentColor" fill-opacity="0.64"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.626 6.8702C13.244 6.2078 14.2011 6.0554 15.2939 6.1768C16.4085 6.301 17.238 6.6552 17.7627 7.3194C18.2756 7.9674 18.3906 8.7829 18.3906 9.5714C18.3906 10.0895 18.3422 10.6112 18.1602 11.0714C18.2199 11.2779 18.249 11.4603 18.2744 11.6261C18.2853 11.6949 18.2968 11.7609 18.3086 11.8243C19.1457 12.1734 19.6875 13.1574 19.75 13.7227V15.419C19.7497 16.1134 16.7128 18.8585 12.498 18.8585C8.3645 18.8584 5.3643 16.2182 5.25 15.461V13.6954C5.327 13.1263 5.8639 12.1678 6.6894 11.8243C6.7012 11.7609 6.7108 11.694 6.7217 11.6261C6.748 11.4603 6.7762 11.2779 6.8359 11.0714C6.6539 10.6112 6.6055 10.0895 6.6055 9.5714C6.6055 8.7829 6.7214 7.9674 7.2334 7.3194C7.7581 6.6552 8.5876 6.301 9.7021 6.1768C10.795 6.0554 11.752 6.2079 12.3701 6.8702C12.4154 6.9181 12.4572 6.968 12.4961 7.0196C12.536 6.968 12.5816 6.9182 12.626 6.8702ZM12.5 10.9444C12.3686 11.1912 12.2024 11.4184 12.0068 11.6182C11.4178 12.2199 10.5902 12.5167 9.5508 12.5167C8.9601 12.5167 8.4312 12.4423 7.9863 12.252L7.9648 12.3575V16.2139C8.3445 16.5067 10.4318 17.5127 12.498 17.5128C14.5641 17.5128 16.6521 16.5068 17.0312 16.2139V12.3575L17.0107 12.252C16.5667 12.4423 16.0362 12.5167 15.4453 12.5167C14.4068 12.5167 13.5792 12.22 12.9893 11.6182C12.7948 11.4183 12.6301 11.1911 12.5 10.9444ZM10.8594 13.4542C11.0458 13.4542 11.2246 13.5284 11.3564 13.6602C11.4883 13.792 11.5624 13.9709 11.5625 14.1573V15.5645C11.5625 15.751 11.4882 15.9297 11.3564 16.0616C11.2246 16.1935 11.0459 16.2677 10.8594 16.2677C10.6729 16.2677 10.4942 16.1935 10.3623 16.0616C10.2305 15.9297 10.1562 15.751 10.1562 15.5645V14.1573C10.1563 13.9709 10.2305 13.792 10.3623 13.6602C10.4941 13.5284 10.673 13.4542 10.8594 13.4542ZM14.1406 13.4542C14.327 13.4542 14.5058 13.5284 14.6377 13.6602C14.7695 13.792 14.8437 13.9709 14.8438 14.1573V15.5645C14.8438 15.751 14.7695 15.9297 14.6377 16.0616C14.5058 16.1935 14.3271 16.2677 14.1406 16.2677C13.9541 16.2677 13.7754 16.1935 13.6436 16.0616C13.5118 15.9297 13.4375 15.751 13.4375 15.5645V14.1573C13.4376 13.9709 13.5117 13.792 13.6436 13.6602C13.7754 13.5284 13.9542 13.4542 14.1406 13.4542ZM11.3779 7.7969C11.2029 7.6104 10.8001 7.4233 9.8535 7.5284C8.9307 7.6308 8.5139 7.8941 8.3018 8.1622C8.0779 8.4449 7.9668 8.8781 7.9668 9.5714C7.9668 10.2897 8.0839 10.6323 8.2461 10.8136C8.3929 10.9775 8.7166 11.1573 9.5527 11.1573C10.3258 11.1573 10.7661 10.9435 11.0371 10.6671C11.3225 10.3752 11.5151 9.9177 11.5967 9.2598C11.7027 8.4127 11.5628 7.9954 11.3779 7.7969ZM15.1436 7.5284C14.1978 7.4233 13.7951 7.6103 13.6201 7.7969C13.4353 7.9954 13.2944 8.4127 13.4004 9.2598C13.4828 9.9177 13.6756 10.3752 13.9609 10.6671C14.2319 10.9435 14.6714 11.1573 15.4453 11.1573C16.2806 11.1573 16.6051 10.9775 16.752 10.8136C16.9141 10.6323 17.0312 10.2897 17.0312 9.5714C17.0312 8.8781 16.9201 8.4449 16.6963 8.1622C16.4851 7.894 16.0678 7.6308 15.1436 7.5284Z" fill="currentColor" fill-opacity="0.64"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.5005 7C15.5379 7.0002 18.0005 9.4625 18.0005 12.5C18.0005 15.5375 15.5379 17.9998 12.5005 18C9.4629 18 7.0005 15.5376 7.0005 12.5C7.0005 9.4624 9.4629 7 12.5005 7ZM12.5005 8C10.0152 8 8.0005 10.0147 8.0005 12.5C8.0005 14.9853 10.0152 17 12.5005 17C14.9856 16.9998 17.0005 14.9852 17.0005 12.5C17.0005 10.0148 14.9856 8.0002 12.5005 8ZM12.1118 10.0518C12.2131 9.6483 12.7869 9.6483 12.8882 10.0518L13.0093 10.5361C13.1885 11.2525 13.7479 11.8121 14.4644 11.9912L14.9478 12.1123C15.3516 12.2133 15.3516 12.7867 14.9478 12.8877L14.4644 13.0088C13.7479 13.1879 13.1885 13.7475 13.0093 14.4639L12.8882 14.9482C12.7869 15.3517 12.2131 15.3517 12.1118 14.9482L11.9907 14.4639C11.8115 13.7475 11.2521 13.1879 10.5356 13.0088L10.0523 12.8877C9.6484 12.7867 9.6484 12.2133 10.0523 12.1123L10.5356 11.9912C11.2521 11.8121 11.8115 11.2525 11.9907 10.5361L12.1118 10.0518Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 976 B

View File

@ -0,0 +1,4 @@
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12.5" cy="12.5" r="6" stroke="currentColor"/>
<path d="M12.5 9Q13.7 11.3 16 12.5Q13.7 13.7 12.5 16Q11.3 13.7 9 12.5Q11.3 11.3 12.5 9Z" stroke="currentColor" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 275 B

View File

@ -1,3 +1,5 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.2998 15.1279C8.1673 15.1279 8.87081 15.8318 8.87109 16.6992C8.87109 17.5669 8.16747 18.2705 7.2998 18.2705C6.43219 18.2704 5.72852 17.5668 5.72852 16.6992C5.7288 15.8318 6.43237 15.128 7.2998 15.1279ZM12 6.02832C12.2383 6.02832 12.469 6.11239 12.6523 6.26465C12.8353 6.41668 12.96 6.62752 13.0039 6.86133L13.5811 9.91797H13.582C13.6055 10.042 13.6656 10.1559 13.7549 10.2451C13.8441 10.3344 13.958 10.3945 14.082 10.418V10.4189L17.1387 10.9961H17.1377C17.3719 11.0398 17.5831 11.1644 17.7354 11.3477C17.8876 11.531 17.9717 11.7617 17.9717 12C17.9717 12.2383 17.8876 12.469 17.7354 12.6523C17.5832 12.8355 17.3718 12.9591 17.1377 13.0029L14.082 13.5811V13.582C13.958 13.6055 13.8441 13.6656 13.7549 13.7549C13.6656 13.8441 13.6055 13.958 13.582 14.082H13.5811L13.0039 17.1387C12.96 17.3725 12.8353 17.5833 12.6523 17.7354C12.469 17.8876 12.2383 17.9717 12 17.9717C11.7617 17.9717 11.531 17.8876 11.3477 17.7354C11.1647 17.5833 11.04 17.3725 10.9961 17.1387L10.4189 14.082H10.418C10.3945 13.958 10.3344 13.8441 10.2451 13.7549C10.1559 13.6656 10.042 13.6055 9.91797 13.582V13.5811L6.86133 13.0039V13.0029C6.62759 12.959 6.41664 12.8353 6.26465 12.6523C6.11239 12.469 6.02832 12.2383 6.02832 12C6.02832 11.7617 6.11239 11.531 6.26465 11.3477C6.41668 11.1647 6.62752 11.04 6.86133 10.9961L9.91797 10.4189V10.418C10.042 10.3945 10.1559 10.3344 10.2451 10.2451C10.3344 10.1559 10.3945 10.042 10.418 9.91797H10.4189L10.9961 6.86133C11.04 6.62752 11.1647 6.41668 11.3477 6.26465C11.531 6.11239 11.7617 6.02832 12 6.02832ZM7.2998 16.0713C6.95297 16.0714 6.67215 16.3524 6.67188 16.6992C6.67188 17.0462 6.9528 17.3281 7.2998 17.3281C7.64687 17.3281 7.92871 17.0463 7.92871 16.6992C7.92843 16.3524 7.6467 16.0713 7.2998 16.0713ZM12 6.97168C11.9818 6.97168 11.9642 6.97771 11.9502 6.98926C11.9362 7.00091 11.9263 7.01725 11.9229 7.03516V7.03613L11.3447 10.0928C11.2861 10.4031 11.1354 10.6888 10.9121 10.9121C10.6888 11.1354 10.4031 11.2861 10.0928 11.3447L7.03613 11.9229H7.03516C7.01725 11.9263 7.00091 11.9362 6.98926 11.9502C6.97771 11.9642 6.97168 11.9818 6.97168 12C6.97168 12.0182 6.97771 12.0358 6.98926 12.0498C7.00091 12.0638 7.01725 12.0737 7.03516 12.0771H7.03613L10.0928 12.6553C10.4031 12.7139 10.6888 12.8646 10.9121 13.0879C11.1354 13.3112 11.2861 13.5969 11.3447 13.9072L11.9229 16.9639V16.9648C11.9263 16.9827 11.9362 16.9991 11.9502 17.0107C11.9642 17.0223 11.9818 17.0283 12 17.0283C12.0182 17.0283 12.0358 17.0223 12.0498 17.0107C12.0638 16.9991 12.0737 16.9827 12.0771 16.9648V16.9639L12.6553 13.9072C12.7139 13.5969 12.8646 13.3112 13.0879 13.0879C13.3112 12.8646 13.5969 12.7139 13.9072 12.6553L16.9639 12.0771H16.9648C16.9827 12.0737 16.9991 12.0638 17.0107 12.0498C17.0223 12.0358 17.0283 12.0182 17.0283 12C17.0283 11.9818 17.0223 11.9642 17.0107 11.9502C16.9991 11.9362 16.9827 11.9263 16.9648 11.9229H16.9639L13.9072 11.3447C13.5969 11.2861 13.3112 11.1354 13.0879 10.9121C12.8646 10.6888 12.7139 10.4031 12.6553 10.0928L12.0771 7.03613V7.03516C12.0737 7.01725 12.0638 7.00091 12.0498 6.98926C12.0358 6.97771 12.0182 6.97168 12 6.97168ZM16.8496 5.73047C17.1099 5.73047 17.3213 5.94282 17.3213 6.20312V6.97852H18.1025C18.3625 6.97878 18.5741 7.19019 18.5742 7.4502C18.574 7.71012 18.3625 7.92161 18.1025 7.92188H17.3213V8.70312C17.3208 8.96299 17.1096 9.1748 16.8496 9.1748C16.5898 9.17459 16.3784 8.96286 16.3779 8.70312V7.92188H15.6025C15.3424 7.92188 15.1301 7.71028 15.1299 7.4502C15.13 7.19003 15.3423 6.97852 15.6025 6.97852H16.3779V6.20312C16.3779 5.94295 16.5895 5.73068 16.8496 5.73047Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.5 7L13.55 10.58Q13.75 11.25 14.42 11.45L18 12.5L14.42 13.55Q13.75 13.75 13.55 14.42L12.5 18L11.45 14.42Q11.25 13.75 10.58 13.55L7 12.5L10.58 11.45Q11.25 11.25 11.45 10.58Z" stroke="currentColor" stroke-linejoin="round"/>
<circle cx="7.5" cy="17.5" r="1" stroke="currentColor"/>
<path d="M17.5 6.5V8.5M16.5 7.5H18.5" stroke="currentColor" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 456 B

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.7459 8.9822C17.7929 10.0294 17.7928 11.7273 16.7459 12.7746L12.5032 17.0173C12.2726 17.2479 12.2727 17.622 12.5032 17.8528L13.2753 18.6248C13.4702 18.82 13.4701 19.1367 13.2753 19.3319C13.0801 19.5271 12.7634 19.527 12.5681 19.3319L11.7961 18.5599C11.1751 17.9386 11.1749 16.9314 11.7961 16.3101L16.0388 12.0675C16.6952 11.4108 16.6952 10.346 16.0388 9.68931C15.3821 9.03268 14.3174 9.03283 13.6606 9.68931L10.1893 13.1606C10.0673 13.2826 9.89726 13.3285 9.73972 13.298C9.67674 13.2858 9.61559 13.2614 9.56018 13.2248C9.53235 13.2065 9.50595 13.1844 9.48146 13.1599C9.37064 13.0488 9.32521 12.8988 9.34059 12.7539C9.34548 12.7081 9.35415 12.6625 9.37166 12.6192C9.38393 12.5889 9.39944 12.5595 9.41793 12.5315C9.43618 12.504 9.45715 12.4771 9.48146 12.4528L12.9528 8.98151C13.6093 8.3247 13.6095 7.26001 12.9528 6.60331C12.296 5.94704 11.2312 5.94696 10.5746 6.60331L5.56061 11.6173C5.36534 11.8125 5.04876 11.8125 4.8535 11.6173C4.65853 11.422 4.65834 11.1053 4.8535 10.9102L9.86747 5.89621C10.9147 4.84933 12.6126 4.84941 13.6599 5.89621C14.2967 6.53303 14.5433 7.41035 14.4057 8.23574C15.2312 8.09786 16.1089 8.34526 16.7459 8.9822ZM15.2032 10.5249C15.3984 10.7201 15.3984 11.0367 15.2032 11.232L11.7319 14.7033C10.6846 15.7505 8.98679 15.7506 7.93949 14.7033C6.89243 13.656 6.89232 11.9581 7.93949 10.9109L11.4108 7.43955C11.606 7.24445 11.9227 7.24443 12.1179 7.43955C12.3131 7.63477 12.313 7.95138 12.1179 8.14666L8.6466 11.618C7.98995 12.2747 7.99006 13.3394 8.6466 13.9962C9.30337 14.6529 10.368 14.6529 11.0248 13.9962L14.4961 10.5249C14.6913 10.3298 15.008 10.33 15.2032 10.5249Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.2459 9.4822C18.2929 10.5294 18.2928 12.2273 17.2459 13.2746L13.0032 17.5173C12.7726 17.7479 12.7727 18.122 13.0032 18.3528L13.7753 19.1248C13.9702 19.32 13.9701 19.6367 13.7753 19.8319C13.5801 20.0271 13.2634 20.027 13.0681 19.8319L12.2961 19.0599C11.6751 18.4386 11.6749 17.4314 12.2961 16.8101L16.5388 12.5675C17.1952 11.9108 17.1952 10.846 16.5388 10.1893C15.8821 9.5327 14.8174 9.5328 14.1606 10.1893L10.6893 13.6606C10.5673 13.7826 10.3973 13.8285 10.2397 13.798C10.1767 13.7858 10.1156 13.7614 10.0602 13.7248C10.0323 13.7065 10.006 13.6844 9.9815 13.6599C9.8706 13.5488 9.8252 13.3988 9.8406 13.2539C9.8455 13.2081 9.8542 13.1625 9.8717 13.1192C9.8839 13.0889 9.8994 13.0595 9.9179 13.0315C9.9362 13.004 9.9572 12.9771 9.9815 12.9528L13.4528 9.4815C14.1093 8.8247 14.1095 7.76 13.4528 7.1033C12.796 6.447 11.7312 6.447 11.0746 7.1033L6.0606 12.1173C5.8653 12.3125 5.5488 12.3125 5.3535 12.1173C5.1585 11.922 5.1583 11.6053 5.3535 11.4102L10.3675 6.3962C11.4147 5.3493 13.1126 5.3494 14.1599 6.3962C14.7967 7.033 15.0433 7.9104 14.9057 8.7357C15.7312 8.5979 16.6089 8.8453 17.2459 9.4822ZM15.7032 11.0249C15.8984 11.2201 15.8984 11.5367 15.7032 11.732L12.2319 15.2033C11.1846 16.2505 9.4868 16.2506 8.4395 15.2033C7.3924 14.156 7.3923 12.4581 8.4395 11.4109L11.9108 7.9395C12.106 7.7444 12.4227 7.7444 12.6179 7.9395C12.8131 8.1348 12.813 8.4514 12.6179 8.6467L9.1466 12.118C8.49 12.7747 8.4901 13.8394 9.1466 14.4962C9.8034 15.1529 10.868 15.1529 11.5248 14.4962L14.9961 11.0249C15.1913 10.8298 15.508 10.83 15.7032 11.0249Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,4 @@
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15.5 7.5L7.5 15.5V17.5H9.5L17.5 9.5A1.4142 1.4142 0 0 0 15.5 7.5ZM14.5 8.5L16.5 10.5M13.5 17.5H18.5M15.5 14.5H18.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8.01 5.44C8.14 4.94 8.86 4.94 8.99 5.44L9.3 6.7L10.56 7.01C11.06 7.14 11.06 7.86 10.56 7.99L9.3 8.3L8.99 9.56C8.86 10.06 8.14 10.06 8.01 9.56L7.7 8.3L6.44 7.99C5.94 7.86 5.94 7.14 6.44 7.01L7.7 6.7Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 509 B

View File

@ -0,0 +1,5 @@
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.5 9.5V8.5A1 1 0 0 1 8.5 7.5H9.5M11.5 7.5H13.5M17.5 11.5V12.5M7.5 16V16.5A1 1 0 0 0 8.5 17.5H9.5M11.5 17.5H13.5M7.5 11.5V14.5L9.5 12.5L13 16M12.5 15.5L15.5 12.5L17.5 14.5V16.5A1 1 0 0 1 16.5 17.5H15.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="12.5" cy="10.5" r="1" stroke="currentColor"/>
<path d="M17.01 5.44C17.14 4.94 17.86 4.94 17.99 5.44L18.3 6.7L19.56 7.01C20.06 7.14 20.06 7.86 19.56 7.99L18.3 8.3L17.99 9.56C17.86 10.06 17.14 10.06 17.01 9.56L16.7 8.3L15.44 7.99C14.94 7.86 14.94 7.14 15.44 7.01L16.7 6.7Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 670 B

View File

@ -0,0 +1,4 @@
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.5 6.5V18.5M10.5 7.5H9A1.5 1.5 0 0 0 7.5 9V16A1.5 1.5 0 0 0 9 17.5H10.5M17.5 10.5V16A1.5 1.5 0 0 1 16 17.5H14.5M9.5 11.5V13.5M15.5 11.5V13.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16.01 4.44C16.14 3.94 16.86 3.94 16.99 4.44L17.3 5.7L18.56 6.01C19.06 6.14 19.06 6.86 18.56 6.99L17.3 7.3L16.99 8.56C16.86 9.06 16.14 9.06 16.01 8.56L15.7 7.3L14.44 6.99C13.94 6.86 13.94 6.14 14.44 6.01L15.7 5.7Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 551 B

View File

@ -1,3 +1,5 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.0007 17.9998C8.68737 17.9998 6.00098 15.3134 6.00098 11.9995C6.00098 8.68615 8.68738 5.99976 12.0007 5.99976C15.3146 5.99976 18.001 8.68615 18.001 11.9995C18.001 15.3134 15.3146 17.9998 12.0007 17.9998ZM12.0007 17.0999C12.6751 17.1072 13.3443 16.9807 13.9695 16.7277C14.5946 16.4746 15.1634 16.1001 15.6429 15.6258C16.1224 15.1515 16.5031 14.5868 16.7629 13.9644C17.0227 13.342 17.1564 12.6742 17.1564 11.9998C17.1564 11.3253 17.0227 10.6575 16.7629 10.0351C16.5031 9.41272 16.1224 8.84802 15.6429 8.3737C15.1634 7.89938 14.5946 7.52487 13.9695 7.27185C13.3443 7.01882 12.6751 6.89231 12.0007 6.89962C10.6576 6.91419 9.37451 7.45793 8.42994 8.41281C7.48536 9.36769 6.95556 10.6566 6.95556 11.9998C6.95556 13.3429 7.48536 14.6318 8.42994 15.5867C9.37451 16.5416 10.6576 17.0853 12.0007 17.0999ZM12.0019 12.8999C11.8825 12.8999 11.7681 12.8525 11.6837 12.7681C11.5993 12.6838 11.5519 12.5693 11.5519 12.45L11.5519 9.45044C11.5519 9.33111 11.5993 9.21667 11.6837 9.13229C11.7681 9.04791 11.8825 9.0005 12.0019 9.0005C12.1212 9.0005 12.2356 9.04791 12.32 9.13229C12.4044 9.21667 12.4518 9.33111 12.4518 9.45044L12.4518 12.45C12.4518 12.5693 12.4044 12.6838 12.32 12.7681C12.2356 12.8525 12.1212 12.8999 12.0019 12.8999ZM12.0019 13.7998C11.8428 13.7998 11.6902 13.863 11.5777 13.9755C11.4652 14.088 11.402 14.2406 11.402 14.3997C11.402 14.5588 11.4652 14.7114 11.5777 14.8239C11.6902 14.9364 11.8428 14.9996 12.0019 14.9996C12.161 14.9996 12.3136 14.9364 12.4261 14.8239C12.5386 14.7114 12.6018 14.5588 12.6018 14.3997C12.6018 14.2406 12.5386 14.088 12.4261 13.9755C12.3136 13.863 12.161 13.7998 12.0019 13.7998Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12.5" cy="12.5" r="6" stroke="currentColor"/>
<path d="M12.5 9.5V12.5" stroke="currentColor" stroke-linecap="round"/>
<circle cx="12.5" cy="14.5" r="0.6" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 268 B

View File

@ -1,3 +1,3 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.333 6.83468C12.333 6.75441 12.3136 6.67532 12.2766 6.60411C12.2395 6.5329 12.1859 6.47166 12.1201 6.42556C12.0544 6.37946 11.9786 6.34986 11.899 6.33927C11.8194 6.32867 11.7385 6.33738 11.663 6.36468L7.10301 8.01468C6.87753 8.0962 6.68264 8.24521 6.54486 8.44144C6.40708 8.63767 6.33311 8.87158 6.33301 9.11134V13.166C6.33304 13.2463 6.3524 13.3254 6.38945 13.3966C6.4265 13.4678 6.48015 13.529 6.54587 13.5751C6.61158 13.6212 6.68743 13.6508 6.767 13.6614C6.84657 13.672 6.92752 13.6633 7.00301 13.636L7.33301 13.5167V14.58C7.10683 14.66 6.86477 14.6845 6.62715 14.6516C6.38952 14.6187 6.16326 14.5292 5.96734 14.3908C5.77143 14.2523 5.61157 14.0689 5.5012 13.8559C5.39083 13.6429 5.33315 13.4066 5.33301 13.1667V9.11068C5.33301 8.66536 5.47023 8.23087 5.72598 7.86632C5.98174 7.50177 6.34361 7.22489 6.76234 7.07334L11.3223 5.42334C11.549 5.34129 11.792 5.31506 12.0309 5.34685C12.2698 5.37865 12.4975 5.46754 12.6948 5.606C12.892 5.74447 13.053 5.92842 13.1641 6.1423C13.2752 6.35617 13.3332 6.59367 13.333 6.83468V6.95268L12.333 7.31468V6.83468ZM14.9997 8.83468C14.9996 8.75441 14.9803 8.67532 14.9432 8.60411C14.9062 8.5329 14.8525 8.47166 14.7868 8.42556C14.7211 8.37946 14.6453 8.34986 14.5657 8.33927C14.4861 8.32867 14.4052 8.33738 14.3297 8.36468L9.54967 10.0933C9.38851 10.1516 9.24923 10.2582 9.15081 10.3984C9.05238 10.5387 8.99961 10.706 8.99967 10.8773V15.1653C8.99971 15.2456 9.01907 15.3247 9.05612 15.3959C9.09317 15.4671 9.14682 15.5284 9.21253 15.5745C9.27825 15.6206 9.3541 15.6502 9.43367 15.6608C9.51323 15.6714 9.59419 15.6626 9.66967 15.6353L9.99967 15.5167V16.5807C9.77339 16.6607 9.53122 16.6852 9.29348 16.6522C9.05575 16.6192 8.82941 16.5297 8.63346 16.3911C8.43752 16.2525 8.27769 16.0689 8.16741 15.8557C8.05712 15.6425 7.9996 15.406 7.99967 15.166V10.878C7.99951 10.5011 8.11553 10.1333 8.33193 9.82466C8.54833 9.51605 8.85459 9.28163 9.20901 9.15334L13.989 7.42334C14.2156 7.34129 14.4587 7.31506 14.6976 7.34685C14.9365 7.37865 15.1642 7.46754 15.3615 7.606C15.5587 7.74447 15.7197 7.92842 15.8308 8.1423C15.9419 8.35617 15.9998 8.59367 15.9997 8.83468V8.95268L14.9997 9.31468V8.83468ZM16.9963 10.3647C17.0718 10.3374 17.1528 10.3287 17.2324 10.3393C17.3119 10.3499 17.3878 10.3795 17.4535 10.4256C17.5192 10.4717 17.5728 10.5329 17.6099 10.6041C17.6469 10.6753 17.6663 10.7544 17.6663 10.8347V15.3567C17.6663 15.4594 17.6346 15.5597 17.5755 15.6438C17.5165 15.7279 17.433 15.7917 17.3363 15.8267L12.3363 17.636C12.2609 17.6633 12.1799 17.672 12.1003 17.6614C12.0208 17.6508 11.9449 17.6212 11.8792 17.5751C11.8135 17.529 11.7598 17.4678 11.7228 17.3966C11.6857 17.3254 11.6664 17.2463 11.6663 17.166V12.644C11.6664 12.5413 11.6981 12.441 11.7571 12.3569C11.8162 12.2728 11.8997 12.2089 11.9963 12.174L16.9963 10.3647ZM18.6663 10.8347C18.6664 10.5937 18.6084 10.3563 18.4972 10.1425C18.3861 9.92873 18.2251 9.74487 18.0278 9.60648C17.8306 9.46809 17.6029 9.37926 17.3641 9.3475C17.1252 9.31573 16.8822 9.34198 16.6557 9.42401L11.6557 11.2333C11.3658 11.3383 11.1153 11.53 10.9383 11.7825C10.7612 12.0349 10.6663 12.3357 10.6663 12.644V17.166C10.6663 17.407 10.7243 17.6444 10.8354 17.8582C10.9466 18.072 11.1076 18.2558 11.3048 18.3942C11.5021 18.5326 11.7298 18.6214 11.9686 18.6532C12.2075 18.685 12.4504 18.6587 12.677 18.5767L17.677 16.7673C17.9669 16.6624 18.2174 16.4706 18.3944 16.2182C18.5715 15.9658 18.6664 15.665 18.6663 15.3567V10.8347Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.4 14.3214L6.2063 14.7477Q5.5 15 5.5 14.25V9.25Q5.5 8.5 6.2063 8.2477L11.7937 6.2523Q12.5 6 12.5 6.75V7.9405M10.4 16.3214L9.2063 16.7477Q8.5 17 8.5 16.25V11.25Q8.5 10.5 9.2063 10.2477L14.7937 8.2523Q15.5 8 15.5 8.75V9.9405M11.5 13.25Q11.5 12.5 12.2063 12.2477L17.7937 10.2523Q18.5 10 18.5 10.75V15.75Q18.5 16.5 17.7937 16.7523L12.2063 18.7477Q11.5 19 11.5 18.25Z" stroke="currentColor" stroke-linejoin="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 503 B

View File

@ -1,3 +1,4 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.83 7.88C14.476 7.88015 14.9999 8.40392 14.9999 9.05V11.1199L18.6249 11.1199C19.108 11.1199 19.4996 11.5119 19.4999 11.9949C19.4997 12.478 19.108 12.8699 18.6249 12.8699L14.9999 12.8699V14.95C14.9999 15.5961 14.476 16.1199 13.83 16.12H10.1708C9.52461 16.12 8.99989 15.5962 8.99988 14.95V12.8699H5.37488C4.89187 12.8698 4.50007 12.4779 4.49988 11.9949C4.50014 11.512 4.89191 11.1201 5.37488 11.1199H8.99988V9.05C8.99988 8.40383 9.5246 7.88 10.1708 7.88H13.83Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 12.5H19.5" stroke="currentColor" stroke-linecap="round"/>
<rect x="10" y="8" width="5" height="9" rx="1" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 221 B

View File

@ -1,3 +1,4 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 3.125C12.4832 3.125 12.875 3.51675 12.875 4V8.49023H14.3398C14.986 8.49023 15.5098 9.01398 15.5098 9.66016V11.125H20C20.4832 11.125 20.875 11.5168 20.875 12C20.875 12.4832 20.4832 12.875 20 12.875H15.5098V14.3398C15.5098 14.986 14.986 15.5098 14.3398 15.5098H9.66016C9.01398 15.5098 8.49023 14.986 8.49023 14.3398V9.66016C8.49023 9.01398 9.01398 8.49023 9.66016 8.49023H11.125V4C11.125 3.51675 11.5168 3.125 12 3.125Z" fill="currentColor"/>
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.5 9V4.5M16 12.5H20.5" stroke="currentColor" stroke-linecap="round"/>
<rect x="9" y="9" width="7" height="7" rx="1" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 534 B

After

Width:  |  Height:  |  Size: 230 B

Some files were not shown because too many files have changed in this diff Show More