Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Desktop] Startup maintenance screen #2253

Merged
merged 65 commits into from
Jan 21, 2025
Merged

Conversation

webfiltered
Copy link
Contributor

@webfiltered webfiltered commented Jan 15, 2025

Desktop startup validation

Detects problems with the installation when loading, allowing users to easily resolve several issues without needing to load a terminal and type out lengthy commands.

  • Change application install path
  • Install missing python packages
  • Reset virtual environment (clear python packages)
  • Reset uv cache
  • Remove desktop config files and re-run the app installer (reinstall)
  • Download git & Visual C++ Redistributable

Fix typo in base_path, and missing pyyaml

base-path-venv.mp4

Edit: Pending updates.

┆Issue is synchronized with this Notion page by Unito

src/types/vueTypes.ts Outdated Show resolved Hide resolved
src/types/maintenanceTypes.ts Outdated Show resolved Hide resolved
src/locales/en/main.json Show resolved Hide resolved
src/types/maintenanceTypes.ts Outdated Show resolved Hide resolved
src/views/MaintenanceView.vue Outdated Show resolved Hide resolved
src/views/MaintenanceView.vue Outdated Show resolved Hide resolved
src/components/maintenance/TaskCard.vue Outdated Show resolved Hide resolved
src/views/MaintenanceView.vue Outdated Show resolved Hide resolved
Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

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

Can you attach some example screenshots and the UX flow of this feature?

@webfiltered
Copy link
Contributor Author

Can you attach some example screenshots and the UX flow of this feature?

100% - was the first thing I started doing after drafting. 😄

src/utils/refUtil.ts Outdated Show resolved Hide resolved
src/views/MaintenanceView.vue Show resolved Hide resolved
src/types/desktop/maintenanceTypes.ts Outdated Show resolved Hide resolved
src/types/desktop/maintenanceTypes.ts Outdated Show resolved Hide resolved
src/types/desktop/maintenanceTypes.ts Outdated Show resolved Hide resolved
src/views/MaintenanceView.vue Outdated Show resolved Hide resolved
src/extensions/core/electronTasks.ts Outdated Show resolved Hide resolved
src/extensions/core/electronTasks.ts Outdated Show resolved Hide resolved
@webfiltered webfiltered force-pushed the desktop-maintenance-screen branch from 1fc2978 to 230a602 Compare January 20, 2025 23:02
src/stores/maintenanceTaskStore.ts Outdated Show resolved Hide resolved
}

/** State of a maintenance task, managed by the maintenance task store. */
export interface MaintenanceTaskState {
Copy link
Member

Choose a reason for hiding this comment

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

We can simplify states to following structure and make these boolean fields computed getter.

export enum TaskState {
  Idle = 'idle',
  Loading = 'loading',
  Executing = 'executing',
  Error = 'error',
  Warning = 'warning',
  OK = 'OK',
  Skipped = 'skipped',
  Resolved = 'resolved'
}

/** State of a maintenance task, managed by the maintenance task store. */
export interface MaintenanceTaskState {
  /** The current state of the task. */
  taskState: TaskState
  /** `true` if the task has been resolved (was `error`, now `OK`). */
  resolved: boolean
  /** Whether the task state is currently being refreshed. */
  loading: boolean
  /** Whether the task is currently running. */
  executing: boolean
  /** The error message that occurred when the task failed. */
  error?: string
}

export class MaintenanceTaskStateImpl implements MaintenanceTaskState {
  taskState: TaskState = TaskState.Idle
  error?: string

  constructor(public readonly task: MaintenanceTask) {}

  get resolved(): boolean {
    return this.taskState === TaskState.Resolved
  }

  get loading(): boolean {
    return this.taskState === TaskState.Loading
  }

  get executing(): boolean {
    return this.taskState === TaskState.Executing
  }

  get hasError(): boolean {
    return this.taskState === TaskState.Error
  }

  async execute() {
    try {
      this.taskState = TaskState.Executing
      const success = await this.task.execute()
      if (!success) return false

      this.error = undefined
      this.taskState = TaskState.OK
      return true
    } catch (error) {
      this.error = (error as Error)?.message
      this.taskState = TaskState.Error
      throw error
    }
  }
}

  /**
   * Updates the task list with the latest validation state.
   * @param update Update details passed in by electron
   */
  const processUpdate = (update: InstallValidation) => {
    // Update each task state
    for (const task of DESKTOP_MAINTENANCE_TASKS) {
      const state = getState(task)

      if (update[task.id] === undefined) {
        state.taskState = TaskState.Loading
        continue
      }

      if (state.taskState === TaskState.Error && update[task.id] === 'OK') {
        state.taskState = TaskState.Resolved
      } else {
        state.taskState = update[task.id] as TaskState
      }
    }

    // Final update
    if (!update.inProgress) {
      for (const task of DESKTOP_MAINTENANCE_TASKS) {
        const state = getState(task)
        state.taskState = update[task.id] as TaskState ?? TaskState.Skipped
      }
    }
  }

@webfiltered webfiltered marked this pull request as ready for review January 21, 2025 19:45
@huchenlei huchenlei merged commit 0b69d3c into main Jan 21, 2025
10 checks passed
@huchenlei huchenlei deleted the desktop-maintenance-screen branch January 21, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants