Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ipollo/desktop",
"description": "Electron desktop shell for a bundled dsh runtime and external plugins",
"version": "1.0.22",
"version": "1.0.23",
"private": true,
"license": "SEE LICENSE IN LICENSE",
"author": {
Expand Down
95 changes: 95 additions & 0 deletions integrations/desktop/renderer/social-login-loading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'">
<style>
:root {
color-scheme: light dark;
--line: color-mix(in srgb, CanvasText 16%, transparent);
--secondary: color-mix(in srgb, CanvasText 68%, Canvas);
}
[hidden] { display: none !important; }
body {
margin: 0; min-height: 100vh; display: flex; flex-direction: column;
background: Canvas; color: CanvasText; font: 14px/1.5 system-ui, sans-serif;
}
header {
box-sizing: border-box; height: 52px; flex: none; padding: 0 12px;
display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line);
}
.page { flex: 1; min-width: 0; line-height: 1.25; }
.page > * { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h1 { font-size: 14px; font-weight: 500; }
#context { margin-top: 3px; color: var(--secondary); font-size: 12px; }
main { flex: 1; display: grid; place-items: center; }
.feedback { box-sizing: border-box; padding: 24px; max-width: 420px; text-align: center; }
[role="status"] { margin: 0; }
#spinner {
box-sizing: border-box; width: 24px; height: 24px; margin: 0 auto 14px;
border: 2px solid color-mix(in srgb, CanvasText 20%, transparent);
border-top-color: CanvasText; border-radius: 50%; animation: spin 900ms linear infinite;
}
button {
padding: 4px 12px; min-height: 32px; font: inherit; white-space: nowrap;
background: Canvas; color: CanvasText; border: 1px solid var(--line);
border-radius: 8px; cursor: pointer;
}
button:hover { background: color-mix(in srgb, CanvasText 8%, Canvas); }
button:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.actions button { margin-top: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #spinner { animation: none; } }
</style>
</head>
<body>
<header aria-label="登录浏览器">
<button id="leave" type="button">返回运营台</button>
<div class="page">
<h1 id="platform">平台账号登录</h1>
<p id="context" aria-live="polite"></p>
</div>
<button id="back" type="button" hidden>返回登录页</button>
<button id="reload" type="button" hidden>重新加载</button>
<button id="direct-toolbar" type="button" hidden>直连重试</button>
</header>
<main id="feedback">
<div class="feedback">
<div id="spinner" aria-hidden="true"></div>
<p id="message" role="status">正在加载平台登录页…</p>
<div class="actions">
<button id="retry" type="button" hidden>重试</button>
<button id="direct" type="button" hidden>直连重试</button>
</div>
</div>
</main>
<script>
const elements = Object.fromEntries(
['leave', 'platform', 'context', 'back', 'reload', 'feedback', 'spinner', 'message', 'retry', 'direct', 'direct-toolbar']
.map(id => [id, document.getElementById(id)])
)
for (const [id, action] of [['leave', 'leave'], ['back', 'back'], ['reload', 'retry'], ['retry', 'retry'], ['direct', 'direct'], ['direct-toolbar', 'direct']]) {
elements[id].addEventListener('click', () => {
history.replaceState(null, '', location.href.split('#')[0])
location.hash = action
})
}
globalThis.renderSocialLogin = ({ label, hostname, authorization, notice, message, retry, directRetry }) => {
document.title = label
elements.platform.textContent = label
elements.context.textContent = notice || hostname
elements.context.title = notice || hostname
elements.back.hidden = !authorization
elements.reload.hidden = Boolean(message || authorization)
elements['direct-toolbar'].hidden = Boolean(message || authorization || !directRetry)
elements.feedback.hidden = !message
elements.message.textContent = message || ''
elements.spinner.hidden = retry
elements.retry.hidden = !retry
elements.direct.hidden = !retry || !directRetry || authorization
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions integrations/desktop/src/client/WelcomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export function Welcome({ api }: { api: WelcomeApi }) {
'invalid-credentials': m.welcomeInvalidCredentials,
'email-in-use': m.welcomeEmailInUse,
'session-rejected': m.welcomeAuthSessionRejected,
'connection-interrupted': m.welcomeAuthConnectionInterrupted,
'service-unavailable': m.welcomeAuthServiceUnavailable,
timeout: m.welcomeAuthTimeout,
'rate-limited': m.welcomeAuthRateLimited,
Expand Down
5 changes: 3 additions & 2 deletions integrations/desktop/src/enterprise-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class EnterpriseDesktop {
private readonly active = new Map<string, BrowserWindow>()
private readonly tracked = new Map<string, { session: Session; stop: () => void }>()

constructor(private readonly directory: string, private readonly localHost: () => string | undefined) {}
constructor(private readonly directory: string, private readonly localHost: () => string | undefined,
private readonly applicationIconPath: string) {}

handle(message: EnterpriseDesktopMessage): Promise<unknown> {
return this.serialize(async () => {
Expand Down Expand Up @@ -143,7 +144,7 @@ export class EnterpriseDesktop {
})
profile.on('will-download', event => event.preventDefault())
const window = new BrowserWindow({
title: input.label, width: 1060, height: 760, autoHideMenuBar: true,
title: input.label, width: 1060, height: 760, autoHideMenuBar: true, icon: this.applicationIconPath,
webPreferences: {
session: profile, sandbox: true, contextIsolation: true, nodeIntegration: false,
webviewTag: false, devTools: false, navigateOnDragDrop: false,
Expand Down
19 changes: 18 additions & 1 deletion integrations/desktop/src/host-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { PlatformSession } from '@deepseek-ai/dsh-deepseek-account'
import { desktopNodeEnvironment } from './node-environment.ts'
import { enterpriseDesktopMessage, type EnterpriseDesktopMessage } from './enterprise-desktop-protocol.ts'
import { parsePluginOperationRecord, type PluginOperationRecord, type PluginOperationRunId } from '@deepseek-ai/dsh-plugin-manager/diagnostic'
import type { SocialLoginObservation, SocialLoginObservationResult } from './social-login.ts'

interface ReadyEvent {
readonly type: 'ready'
Expand Down Expand Up @@ -46,6 +47,11 @@ type DesktopHostEvent = ReadyEvent | FatalEvent | PlatformSessionEvent | {
readonly activeTasks: boolean
readonly scheduledTasks: boolean
readonly error?: string
} | {
readonly type: 'ipollo-social-login'
readonly requestId: number
readonly result: SocialLoginObservationResult
readonly error?: string
}

/** Correlated answer to one shell control request. */
Expand Down Expand Up @@ -119,6 +125,10 @@ function isDesktopHostEvent(message: unknown): message is DesktopHostEvent {
case 'quit-inspection':
return Number.isSafeInteger(candidate.requestId) && typeof candidate.activeTasks === 'boolean'
&& typeof candidate.scheduledTasks === 'boolean' && (candidate.error === undefined || typeof candidate.error === 'string')
case 'ipollo-social-login':
return Number.isSafeInteger(candidate.requestId) && typeof candidate.result === 'string'
&& ['waiting', 'connected', 'mismatch', 'duplicate'].includes(candidate.result)
&& (candidate.error === undefined || typeof candidate.error === 'string')
default:
return false
}
Expand Down Expand Up @@ -348,9 +358,16 @@ export class DesktopHostProcess {
return response.resource
}

async observeSocialLogin(input: SocialLoginObservation, signal: AbortSignal): Promise<SocialLoginObservationResult> {
const response = await this.control({ type: 'ipollo-social-login', input }, 8_000, 'Account recognition timed out', 'social login', signal)
if (response.type !== 'ipollo-social-login') throw new Error('Unexpected account recognition response')
return response.result
}

private async control(
request: { readonly type: 'update-tasks'; readonly action: 'inspect' | 'lock' | 'unlock' } | { readonly type: 'quit-inspection' }
| { readonly type: 'file-drag-resource'; readonly address: string },
| { readonly type: 'file-drag-resource'; readonly address: string }
| { readonly type: 'ipollo-social-login'; readonly input: SocialLoginObservation },
deadlineMs: number, deadlineMessage: string, operation: string, signal?: AbortSignal,
): Promise<DesktopHostControlResponse> {
const child = this.child
Expand Down
4 changes: 4 additions & 0 deletions integrations/desktop/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { DesktopKeyboardApi, DesktopShortcutsApi } from '@deepseek-ai/dsh-c
import type { IpcMainInvokeEvent } from 'electron'
import type { DesktopBrowserBridge } from '@deepseek-ai/dsh-client-ui-sidebar-browser/types'
import type { DesktopFileDrag } from '@deepseek-ai/dsh-util-file-drag'
import type { SocialLoginRequest, SocialLoginResult } from './social-login.ts'

export const DESKTOP_VERSION_ARGUMENT = '--ipollo-app-version='
export const DESKTOP_FIXED_UPDATE_CHANNEL_ARGUMENT = '--ipollo-fixed-update-channel'
Expand All @@ -29,6 +30,7 @@ export const DESKTOP_IPC = {
browserAcquire: 'dsh-desktop:browser-acquire',
browserRelease: 'dsh-desktop:browser-release',
browserOpenRequested: 'dsh-desktop:browser-open-requested',
socialLogin: 'ipollo-desktop:social-login',
directoryPick: 'dsh-desktop:directory-pick',
fileDragPrepare: 'dsh-desktop:file-drag-prepare',
fileDragCancel: 'dsh-desktop:file-drag-cancel',
Expand Down Expand Up @@ -99,6 +101,8 @@ export interface DshDesktopProductApi {
readonly version?: string
readonly appVersion: () => Promise<string>
readonly browser: DesktopBrowserBridge
readonly socialLogin: (request: SocialLoginRequest) => Promise<SocialLoginResult>
readonly socialLoginQrEntry: true
readonly organizationBrowser: true
readonly organizationPackageSaveAs: true
readonly fileDrag: DesktopFileDrag
Expand Down
Loading