Skip to content

Commit

Permalink
Merge branch 'develop' into 11389-debug-restart
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertp committed Nov 12, 2024
2 parents 8df1614 + a83297b commit fbafbea
Show file tree
Hide file tree
Showing 125 changed files with 5,869 additions and 12,105 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
22.11.0
2 changes: 1 addition & 1 deletion app/common/src/text/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file Functions related to displaying text. */

import ENGLISH from './english.json' assert { type: 'json' }
import ENGLISH from './english.json' with { type: 'json' }

// =============
// === Types ===
Expand Down
2 changes: 1 addition & 1 deletion app/gui/e2e/project-view/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server } from '@open-rpc/server-js'
import * as random from 'lib0/random'
import pmSpec from './pm-openrpc.json' assert { type: 'json' }
import pmSpec from './pm-openrpc.json' with { type: 'json' }
import {
methods as pmMethods,
projects,
Expand Down
3 changes: 1 addition & 2 deletions app/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,13 @@
"@playwright/test": "^1.40.0",
"@react-types/shared": "^3.22.1",
"@tanstack/react-query-devtools": "5.45.1",
"@types/node": "^20.11.21",
"@types/node": "^22.9.0",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/validator": "^13.11.7",
"@vitejs/plugin-react": "^4.3.3",
"chalk": "^5.3.0",
"cross-env": "^7.0.3",
"enso-chat": "git://github.com/enso-org/enso-bot",
"fast-check": "^3.15.0",
"playwright": "^1.39.0",
"postcss": "^8.4.29",
Expand Down
2 changes: 1 addition & 1 deletion app/gui/project-manager-shim-middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as tar from 'tar'
import * as yaml from 'yaml'

import * as common from 'enso-common'
import GLOBAL_CONFIG from 'enso-common/src/config.json' assert { type: 'json' }
import GLOBAL_CONFIG from 'enso-common/src/config.json' with { type: 'json' }

import * as projectManagement from './projectManagement'

Expand Down
3 changes: 2 additions & 1 deletion app/gui/src/dashboard/layouts/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react'

import * as reactDom from 'react-dom'

import * as chat from 'enso-chat/chat'
import * as chat from '#/services/Chat'

import CloseLargeIcon from '#/assets/close_large.svg'
import DefaultUserIcon from '#/assets/default_user.svg'
Expand Down Expand Up @@ -480,6 +480,7 @@ export default function Chat(props: ChatProps) {
element.scrollTop = element.scrollHeight - element.clientHeight
}
// Auto-scroll MUST only happen when the message list changes.
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [messages])

Expand Down
260 changes: 260 additions & 0 deletions app/gui/src/dashboard/services/Chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
/**
* @file An API definition for the chat WebSocket server.
* Types copied from the enso-bot server implementation:
* https://github.com/enso-org/enso-bot/blob/aa903b6e639a31930ee4fff55c5639e4471fa48d/chat.ts
*/

import type * as newtype from '#/utilities/newtype'

// =====================
// === Message Types ===
// =====================

/** Identifier for a chat Thread. */
export type ThreadId = newtype.Newtype<string, 'ThreadId'>
/** Identifier for a chat message. */
export type MessageId = newtype.Newtype<string, 'MessageId'>
/** Identifier for a chat user. */
export type UserId = newtype.Newtype<string, 'UserId'>
/** Chat user's email addresss. */
export type EmailAddress = newtype.Newtype<string, 'EmailAddress'>

/** Enumeration of all message types exchanged with the chat server. */
export enum ChatMessageDataType {
// Messages internal to the server.
/** Like the `authenticate` message, but with user details. */
internalAuthenticate = 'internal-authenticate',
/** Like the `authenticateAnonymously` message, but with user details. */
internalAuthenticateAnonymously = 'internal-authenticate-anonymously',
// Messages from the server to the client.
/** Metadata for all threads associated with a user. */
serverThreads = 'server-threads',
/** Metadata for the currently open thread. */
serverThread = 'server-thread',
/** A message from the server to the client. */
serverMessage = 'server-message',
/** An edited message from the server to the client. */
serverEditedMessage = 'server-edited-message',
/**
* A message from the client to the server, sent from the server to the client as part of
* the message history.
*/
serverReplayedMessage = 'server-replayed-message',
// Messages from the client to the server.
/** The authentication token. */
authenticate = 'authenticate',
/** Sent by a user that is not logged in. This is currently only used on the website. */
authenticateAnonymously = 'authenticate-anonymously',
/** Sent when the user is requesting scrollback history. */
historyBefore = 'history-before',
/** Create a new thread with an initial message. */
newThread = 'new-thread',
/** Rename an existing thread. */
renameThread = 'rename-thread',
/** Change the currently active thread. */
switchThread = 'switch-thread',
/** A message from the client to the server. */
message = 'message',
/** A reaction from the client. */
reaction = 'reaction',
/** Removal of a reaction from the client. */
removeReaction = 'remove-reaction',
/**
* Mark a message as read. Used to determine whether to show the notification dot
* next to a thread.
*/
markAsRead = 'mark-as-read',
}

/** Properties common to all WebSocket messages. */
interface ChatBaseMessageData<Type extends ChatMessageDataType> {
readonly type: Type
}

// =========================
// === Internal messages ===
// =========================

/** Sent to the main file with user information. */
export interface ChatInternalAuthenticateMessageData
extends ChatBaseMessageData<ChatMessageDataType.internalAuthenticate> {
readonly userId: UserId
readonly userName: string
}

/** Sent to the main file with user IP. */
export interface ChatInternalAuthenticateAnonymouslyMessageData
extends ChatBaseMessageData<ChatMessageDataType.internalAuthenticateAnonymously> {
readonly userId: UserId
readonly email: EmailAddress
}

// ======================================
// === Messages from server to client ===
// ======================================

/** All possible emojis that can be used as a reaction on a chat message. */
export type ReactionSymbol = '❤️' | '🎉' | '👀' | '👍' | '👎' | '😀' | '🙁'

/** Basic metadata for a single thread. */
export interface ThreadData {
readonly title: string
readonly id: ThreadId
readonly hasUnreadMessages: boolean
}

/** Basic metadata for a all of a user's threads. */
export interface ChatServerThreadsMessageData
extends ChatBaseMessageData<ChatMessageDataType.serverThreads> {
readonly threads: ThreadData[]
}

/** All possible message types that may trigger a {@link ChatServerThreadMessageData} response. */
export type ChatServerThreadRequestType =
| ChatMessageDataType.authenticate
| ChatMessageDataType.historyBefore
| ChatMessageDataType.newThread
| ChatMessageDataType.switchThread

/**
* Thread details and recent messages.
* This message is sent every time the user switches threads.
*/
export interface ChatServerThreadMessageData
extends ChatBaseMessageData<ChatMessageDataType.serverThread> {
/** The type of the message that triggered this response. */
readonly requestType: ChatServerThreadRequestType
readonly title: string
readonly id: ThreadId
/** `true` if there is no more message history before these messages. */
readonly isAtBeginning: boolean
readonly messages: (ChatServerMessageMessageData | ChatServerReplayedMessageMessageData)[]
}

/** A regular chat message from the server to the client. */
export interface ChatServerMessageMessageData
extends ChatBaseMessageData<ChatMessageDataType.serverMessage> {
readonly id: MessageId
// This should not be `null` for staff, as registration is required.
// However, it will be `null` for users that have not yet set an avatar.
readonly authorAvatar: string | null
readonly authorName: string
readonly content: string
readonly reactions: ReactionSymbol[]
/** Milliseconds since the Unix epoch. */
readonly timestamp: number
/**
* Milliseconds since the Unix epoch.
* Should only be present when receiving message history, because new messages cannot have been
* edited.
*/
readonly editedTimestamp: number | null
}

/** A regular edited chat message from the server to the client. */
export interface ChatServerEditedMessageMessageData
extends ChatBaseMessageData<ChatMessageDataType.serverEditedMessage> {
readonly id: MessageId
readonly content: string
/** Milliseconds since the Unix epoch. */
readonly timestamp: number
}

/** A replayed message from the client to the server. Includes the timestamp of the message. */
export interface ChatServerReplayedMessageMessageData
extends ChatBaseMessageData<ChatMessageDataType.serverReplayedMessage> {
readonly id: MessageId
readonly content: string
/** Milliseconds since the Unix epoch. */
readonly timestamp: number
}

/** A message from the server to the client. */
export type ChatServerMessageData =
| ChatServerEditedMessageMessageData
| ChatServerMessageMessageData
| ChatServerReplayedMessageMessageData
| ChatServerThreadMessageData
| ChatServerThreadsMessageData

// ======================================
// === Messages from client to server ===
// ======================================

/** Sent whenever the user opens the chat sidebar. */
export interface ChatAuthenticateMessageData
extends ChatBaseMessageData<ChatMessageDataType.authenticate> {
readonly accessToken: string
}

/** Sent whenever the user opens the chat sidebar. */
export interface ChatAuthenticateAnonymouslyMessageData
extends ChatBaseMessageData<ChatMessageDataType.authenticateAnonymously> {
readonly email: EmailAddress
}

/** Sent when the user is requesting scrollback history. */
export interface ChatHistoryBeforeMessageData
extends ChatBaseMessageData<ChatMessageDataType.historyBefore> {
readonly messageId: MessageId
}

/** Sent when the user sends a message in a new thread. */
export interface ChatNewThreadMessageData
extends ChatBaseMessageData<ChatMessageDataType.newThread> {
readonly title: string
/** Content of the first message, to reduce the number of round trips. */
readonly content: string
}

/** Sent when the user finishes editing the thread name in the chat title bar. */
export interface ChatRenameThreadMessageData
extends ChatBaseMessageData<ChatMessageDataType.renameThread> {
readonly title: string
readonly threadId: ThreadId
}

/** Sent when the user picks a thread from the dropdown. */
export interface ChatSwitchThreadMessageData
extends ChatBaseMessageData<ChatMessageDataType.switchThread> {
readonly threadId: ThreadId
}

/** A regular message from the client to the server. */
export interface ChatMessageMessageData extends ChatBaseMessageData<ChatMessageDataType.message> {
readonly threadId: ThreadId
readonly content: string
}

/** A reaction to a message sent by staff. */
export interface ChatReactionMessageData extends ChatBaseMessageData<ChatMessageDataType.reaction> {
readonly messageId: MessageId
readonly reaction: ReactionSymbol
}

/** Removal of a reaction from the client. */
export interface ChatRemoveReactionMessageData
extends ChatBaseMessageData<ChatMessageDataType.removeReaction> {
readonly messageId: MessageId
readonly reaction: ReactionSymbol
}

/** Sent when the user scrolls to the bottom of a chat thread. */
export interface ChatMarkAsReadMessageData
extends ChatBaseMessageData<ChatMessageDataType.markAsRead> {
readonly threadId: ThreadId
readonly messageId: MessageId
}

/** A message from the client to the server. */
export type ChatClientMessageData =
| ChatAuthenticateAnonymouslyMessageData
| ChatAuthenticateMessageData
| ChatHistoryBeforeMessageData
| ChatMarkAsReadMessageData
| ChatMessageMessageData
| ChatNewThreadMessageData
| ChatReactionMessageData
| ChatRemoveReactionMessageData
| ChatRenameThreadMessageData
| ChatSwitchThreadMessageData
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import testCases from '@/components/GraphEditor/__tests__/clipboardTestCases.json' assert { type: 'json' }
import testCases from '@/components/GraphEditor/__tests__/clipboardTestCases.json' with { type: 'json' }
import {
isSpreadsheetTsv,
nodesFromClipboardContent,
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/project-view/mock/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { uuidToBits } from 'ydoc-shared/uuid'
import * as Y from 'yjs'
import { mockFsDirectoryHandle, type FileTree } from '../util/convert/fsAccess'
import { mockDataWSHandler as originalMockDataWSHandler } from './dataServer'
import mockDb from './mockSuggestions.json' assert { type: 'json' }
import mockDb from './mockSuggestions.json' with { type: 'json' }

const mockProjectId = random.uuidv4() as Uuid
const standardBase = 'Standard.Base' as QualifiedName
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/project-view/util/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file Configuration options for an application. */
import CONFIG from '@/config.json' assert { type: 'json' }
import CONFIG from '@/config.json' with { type: 'json' }

export type ApplicationConfig = typeof baseConfig
export type ApplicationConfigValue = ConfigValue<typeof baseConfig>
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/client/buildInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @file A re-export of `build.json` to avoid breakage when moving the path of this module. */

import BUILD_INFO from '../../../build.json' assert { type: 'json' }
import BUILD_INFO from '../../../build.json' with { type: 'json' }
export default BUILD_INFO
2 changes: 1 addition & 1 deletion app/ide-desktop/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@babel/plugin-syntax-import-attributes": "^7.24.7",
"@electron/notarize": "2.1.0",
"@types/mime-types": "^2.1.1",
"@types/node": "^20.11.21",
"@types/node": "^22.9.0",
"@types/opener": "^1.4.0",
"@types/semver": "^7.5.8",
"@types/tar": "^6.1.4",
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/client/src/contentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export const VERSION = {
// === Options ===
// ===============

import CONFIG from './config.json' assert { type: 'json' }
import CONFIG from './config.json' with { type: 'json' }

export const OPTIONS = linkedDist.config.options.merge(linkedDist.config.objectToGroup(CONFIG))
2 changes: 1 addition & 1 deletion app/ide-desktop/client/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* These are from variables defined at build time, environment variables,
* monkeypatching on `window` and generated code.
*/
import * as buildJson from './../../build.json' assert { type: 'json' }
import * as buildJson from './../../build.json' with { type: 'json' }

// =============
// === Types ===
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as portfinder from 'portfinder'

import * as common from 'enso-common'
import * as buildUtils from 'enso-common/src/buildUtils'
import GLOBAL_CONFIG from 'enso-common/src/config.json' assert { type: 'json' }
import GLOBAL_CONFIG from 'enso-common/src/config.json' with { type: 'json' }

import * as authentication from '@/authentication'
import * as config from '@/config'
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/client/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type * as vite from 'vite'

import * as projectManagement from '@/projectManagement'
import * as common from 'enso-common'
import GLOBAL_CONFIG from 'enso-common/src/config.json' assert { type: 'json' }
import GLOBAL_CONFIG from 'enso-common/src/config.json' with { type: 'json' }
import * as ydocServer from 'ydoc-server'

import * as contentConfig from '@/contentConfig'
Expand Down
Loading

0 comments on commit fbafbea

Please sign in to comment.