Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ef7459d
WIP: Decouple Electron from `electron-client` entrypoint
somebody1234 Oct 20, 2025
8d362a1
Decouple Electron from `electron-client` entrypoint
somebody1234 Oct 21, 2025
3be6b66
Move `LocalBackend` and `RemoteBackend` to `common`
somebody1234 Oct 22, 2025
3cebacc
WIP: Headless hybrid execution
somebody1234 Oct 23, 2025
da0b2ac
WIP: Headless hybrid execution
somebody1234 Oct 24, 2025
5a67113
Fix type errors in `hybrid.ts`
somebody1234 Oct 27, 2025
e4f7e2a
Replace `App` class with free-standing functions
somebody1234 Oct 27, 2025
a6402b9
Remove global `electron` variable
somebody1234 Oct 27, 2025
46a246b
Move Electron-only functions to `electron` module
somebody1234 Oct 27, 2025
db294e8
Replace `*` imports with named imports
somebody1234 Oct 27, 2025
ec40192
More refactors
somebody1234 Oct 27, 2025
8afeafa
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 27, 2025
79a0ba3
Fixes
somebody1234 Oct 27, 2025
23c401a
Fix imports to `result` and `opt`
somebody1234 Oct 27, 2025
8378775
Fix constructing `RemoteBackend`
somebody1234 Oct 27, 2025
4e691e6
Update Nix flake
somebody1234 Oct 27, 2025
5a70186
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 28, 2025
c6b394b
Fix errors
somebody1234 Oct 28, 2025
9210c7e
Prettier
somebody1234 Oct 28, 2025
b3f51f1
Fix import errors
somebody1234 Oct 28, 2025
84b1055
Fix type error
somebody1234 Oct 28, 2025
bcf55e2
Fix lint error
somebody1234 Oct 28, 2025
a0f0111
Revert changes to `electron-client`
somebody1234 Oct 29, 2025
8e579c5
Address CR
somebody1234 Oct 29, 2025
413d4af
Fix unit tests
somebody1234 Oct 29, 2025
26fd722
Fix more unit tests
somebody1234 Oct 29, 2025
051d545
Move `download.ts` in `common`
somebody1234 Oct 31, 2025
bf8ed25
Remove `.js` extension from files in `common`
somebody1234 Oct 31, 2025
50a2992
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 31, 2025
9a1fcc2
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Nov 6, 2025
58c46e9
Fix import errors
somebody1234 Nov 6, 2025
5e5a363
Fix import errors
somebody1234 Nov 6, 2025
7015499
Fix import errors
somebody1234 Nov 6, 2025
e081372
I guess we do need `.js` suffix now...
somebody1234 Nov 6, 2025
ddc0da0
Fix type errors
somebody1234 Nov 6, 2025
2cf4ad4
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Nov 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@internationalized/date": "3.7.0",
"@types/node": "catalog:",
"is-network-error": "^1.1.0",
"vue": "^3.5.13",
"vue": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions app/common/src/download.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Path } from './utilities/file.js'

export interface DownloadUrlOptions {
readonly url: string
readonly path?: Path | null | undefined
readonly name?: string | null | undefined
readonly shouldUnpackProject?: boolean
readonly showFileDialog?: boolean
}
Comment on lines +3 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be placed elsewhere. "Utilities" is too general, I don't see where I should use this structure (it mentions both FileDialog and project unpacking)


/** Options for `download` function. */
export interface DownloadOptions {
readonly url: string
readonly name?: string | null | undefined
readonly electronOptions?: Omit<DownloadUrlOptions, 'name' | 'url'>
}
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are options for "download" function, it should be defined next to that function IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, but unfortunately right now the download function is browser-only :/ any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, one is used in electron IPC, another in special download callback in Backends...

I think I would put this file just in src, like options.ts or text.ts

1 change: 0 additions & 1 deletion app/common/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @file Shared application options schema and helpers. */

import { z } from 'zod'

const DEFAULT_PROFILING_TIME = 120
Expand Down
21 changes: 15 additions & 6 deletions app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @file Type definitions common between all backends. */
import { z } from 'zod'
import type { DownloadOptions } from '../download.js'
import { getText, resolveDictionary, type Replacements, type TextId } from '../text.js'
import * as dateTime from '../utilities/data/dateTime.js'
import * as newtype from '../utilities/data/newtype.js'
Expand Down Expand Up @@ -95,7 +96,7 @@ export interface Logger {
readonly error: (message: unknown, ...optionalParams: unknown[]) => void
}

type GetText = <K extends TextId>(key: K, ...replacements: Replacements[K]) => string
export type GetText = <K extends TextId>(key: K, ...replacements: Replacements[K]) => string

/** The {@link Backend} variant. If a new variant is created, it should be added to this enum. */
export enum BackendType {
Expand Down Expand Up @@ -1635,15 +1636,23 @@ export class NetworkError extends Error {
export class NotAuthorizedError extends NetworkError {}

/** Interface for sending requests to a backend that manages assets and runs projects. */
export default abstract class Backend {
export abstract class Backend {
abstract readonly type: BackendType
abstract readonly baseUrl: URL
protected getText: GetText
private readonly client: HttpClient
protected readonly downloader: (options: DownloadOptions) => void | Promise<void>

/** Create a {@link LocalBackend}. */
/** Create a {@link Backend}. */
constructor(
protected getText: GetText,
private readonly client: HttpClient,
) {}
getText: GetText,
client: HttpClient,
downloader: (options: DownloadOptions) => void | Promise<void>,
) {
this.getText = getText
this.client = client
this.downloader = downloader
}

/**
* Set `this.getText`. This function is exposed rather than the property itself to make it clear
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @file The categories available in the category switcher. */
import type { SvgUseIcon } from '#/components/types'
import type { UserId } from '#/services/Backend'
import * as z from 'zod'
import {
BackendType,
FilterBy,
Expand All @@ -9,11 +8,8 @@ import {
type User,
type UserGroup,
type UserGroupId,
} from '#/services/Backend'
import { isUrlString } from '@/util/data/urlString'
import { isIconName } from '@/util/iconMetadata/iconName'
import type { DropOperation } from '@react-types/shared'
import * as z from 'zod'
type UserId,
} from '../Backend.js'

// oxlint-disable-next-line no-unused-vars
const PATH_SCHEMA = z.string().refine((s): s is Path => true)
Expand All @@ -22,9 +18,7 @@ const DIRECTORY_ID_SCHEMA = z.string().refine((s): s is DirectoryId => true)

const EACH_CATEGORY_SCHEMA = z.object({
label: z.string(),
icon: z.custom<SvgUseIcon | (string & {})>(
(icon) => typeof icon === 'string' && (isIconName(icon) || isUrlString(icon)),
),
icon: z.string(),
canUploadHere: z.boolean(),
/**
* Internal type discriminator.
Expand Down Expand Up @@ -170,7 +164,6 @@ export const CATEGORY_TO_FILTER_BY: Readonly<Record<Category['type'], FilterBy |
trash: FilterBy.trashed,
user: FilterBy.active,
team: FilterBy.active,
// eslint-disable-next-line @typescript-eslint/naming-convention
'local-directory': FilterBy.active,
}

Expand Down Expand Up @@ -210,7 +203,7 @@ export function dropOperationBetweenCategories(
from: Category,
to: Category,
parentId: DirectoryId | null = null,
): DropOperation {
): 'cancel' | 'copy' | 'move' | undefined {
// Moving into the same category without a parentId is not allowed.
if (from.type === to.type && parentId == null) {
return 'cancel'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/**
* @file Module containing utility functions related to any backend.
*/
import type { AnyCategory } from '../layouts/Drive/Categories/Category'
import type { DirectoryId } from './Backend'
/** @file Backend agnostic utility functions. */
import type { DirectoryId } from '../Backend.js'
import type { AnyCategory } from './Category.js'

/**
* Options for the parseDirectoriesPath function.
*/
/** Options for {@link parseDirectoriesPath}. */
export interface ParsedDirectoriesPathOptions {
readonly rootDirectoryId: DirectoryId
readonly getCategoryByDirectoryId: (id: DirectoryId) => AnyCategory | null
Expand All @@ -22,14 +18,12 @@ export interface PathItem {
readonly icon: AnyCategory['icon']
}

/**
* Parse the parents path and virtual parents path into a list of {@link PathItem}.
*/
/** Parse the parents path and virtual parents path into a list of {@link PathItem}. */
export function parseDirectoriesPath(options: ParsedDirectoriesPathOptions) {
const { getCategoryByDirectoryId, parentsPath, rootDirectoryId, virtualParentsPath } = options

// e.g: parentsPath = 'directory-id1adsf/directory-id2adsf/directory-id3adsf'
// eslint-disable-next-line no-restricted-syntax

const splitPath = parentsPath.split('/') as DirectoryId[]
const rootDirectoryInPath = splitPath[0] || rootDirectoryId

Expand Down
Loading
Loading