Skip to content

Commit c4214ed

Browse files
authored
Merge pull request #606 from Devin-AXIS/Jovan
Fix desktop and social logins and improve organization asset delivery
2 parents d015699 + 47bbecf commit c4214ed

78 files changed

Lines changed: 1909 additions & 266 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎integrations/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ipollo/desktop",
33
"description": "Electron desktop shell for a bundled dsh runtime and external plugins",
4-
"version": "1.0.22",
4+
"version": "1.0.23",
55
"private": true,
66
"license": "SEE LICENSE IN LICENSE",
77
"author": {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!doctype html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'">
7+
<style>
8+
:root {
9+
color-scheme: light dark;
10+
--line: color-mix(in srgb, CanvasText 16%, transparent);
11+
--secondary: color-mix(in srgb, CanvasText 68%, Canvas);
12+
}
13+
[hidden] { display: none !important; }
14+
body {
15+
margin: 0; min-height: 100vh; display: flex; flex-direction: column;
16+
background: Canvas; color: CanvasText; font: 14px/1.5 system-ui, sans-serif;
17+
}
18+
header {
19+
box-sizing: border-box; height: 52px; flex: none; padding: 0 12px;
20+
display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line);
21+
}
22+
.page { flex: 1; min-width: 0; line-height: 1.25; }
23+
.page > * { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
24+
h1 { font-size: 14px; font-weight: 500; }
25+
#context { margin-top: 3px; color: var(--secondary); font-size: 12px; }
26+
main { flex: 1; display: grid; place-items: center; }
27+
.feedback { box-sizing: border-box; padding: 24px; max-width: 420px; text-align: center; }
28+
[role="status"] { margin: 0; }
29+
#spinner {
30+
box-sizing: border-box; width: 24px; height: 24px; margin: 0 auto 14px;
31+
border: 2px solid color-mix(in srgb, CanvasText 20%, transparent);
32+
border-top-color: CanvasText; border-radius: 50%; animation: spin 900ms linear infinite;
33+
}
34+
button {
35+
padding: 4px 12px; min-height: 32px; font: inherit; white-space: nowrap;
36+
background: Canvas; color: CanvasText; border: 1px solid var(--line);
37+
border-radius: 8px; cursor: pointer;
38+
}
39+
button:hover { background: color-mix(in srgb, CanvasText 8%, Canvas); }
40+
button:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
41+
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
42+
.actions button { margin-top: 16px; }
43+
@keyframes spin { to { transform: rotate(360deg); } }
44+
@media (prefers-reduced-motion: reduce) { #spinner { animation: none; } }
45+
</style>
46+
</head>
47+
<body>
48+
<header aria-label="登录浏览器">
49+
<button id="leave" type="button">返回运营台</button>
50+
<div class="page">
51+
<h1 id="platform">平台账号登录</h1>
52+
<p id="context" aria-live="polite"></p>
53+
</div>
54+
<button id="back" type="button" hidden>返回登录页</button>
55+
<button id="reload" type="button" hidden>重新加载</button>
56+
<button id="direct-toolbar" type="button" hidden>直连重试</button>
57+
</header>
58+
<main id="feedback">
59+
<div class="feedback">
60+
<div id="spinner" aria-hidden="true"></div>
61+
<p id="message" role="status">正在加载平台登录页…</p>
62+
<div class="actions">
63+
<button id="retry" type="button" hidden>重试</button>
64+
<button id="direct" type="button" hidden>直连重试</button>
65+
</div>
66+
</div>
67+
</main>
68+
<script>
69+
const elements = Object.fromEntries(
70+
['leave', 'platform', 'context', 'back', 'reload', 'feedback', 'spinner', 'message', 'retry', 'direct', 'direct-toolbar']
71+
.map(id => [id, document.getElementById(id)])
72+
)
73+
for (const [id, action] of [['leave', 'leave'], ['back', 'back'], ['reload', 'retry'], ['retry', 'retry'], ['direct', 'direct'], ['direct-toolbar', 'direct']]) {
74+
elements[id].addEventListener('click', () => {
75+
history.replaceState(null, '', location.href.split('#')[0])
76+
location.hash = action
77+
})
78+
}
79+
globalThis.renderSocialLogin = ({ label, hostname, authorization, notice, message, retry, directRetry }) => {
80+
document.title = label
81+
elements.platform.textContent = label
82+
elements.context.textContent = notice || hostname
83+
elements.context.title = notice || hostname
84+
elements.back.hidden = !authorization
85+
elements.reload.hidden = Boolean(message || authorization)
86+
elements['direct-toolbar'].hidden = Boolean(message || authorization || !directRetry)
87+
elements.feedback.hidden = !message
88+
elements.message.textContent = message || ''
89+
elements.spinner.hidden = retry
90+
elements.retry.hidden = !retry
91+
elements.direct.hidden = !retry || !directRetry || authorization
92+
}
93+
</script>
94+
</body>
95+
</html>

‎integrations/desktop/src/client/WelcomePage.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export function Welcome({ api }: { api: WelcomeApi }) {
148148
'invalid-credentials': m.welcomeInvalidCredentials,
149149
'email-in-use': m.welcomeEmailInUse,
150150
'session-rejected': m.welcomeAuthSessionRejected,
151+
'connection-interrupted': m.welcomeAuthConnectionInterrupted,
151152
'service-unavailable': m.welcomeAuthServiceUnavailable,
152153
timeout: m.welcomeAuthTimeout,
153154
'rate-limited': m.welcomeAuthRateLimited,

‎integrations/desktop/src/enterprise-browser.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export class EnterpriseDesktop {
3535
private readonly active = new Map<string, BrowserWindow>()
3636
private readonly tracked = new Map<string, { session: Session; stop: () => void }>()
3737

38-
constructor(private readonly directory: string, private readonly localHost: () => string | undefined) {}
38+
constructor(private readonly directory: string, private readonly localHost: () => string | undefined,
39+
private readonly applicationIconPath: string) {}
3940

4041
handle(message: EnterpriseDesktopMessage): Promise<unknown> {
4142
return this.serialize(async () => {
@@ -143,7 +144,7 @@ export class EnterpriseDesktop {
143144
})
144145
profile.on('will-download', event => event.preventDefault())
145146
const window = new BrowserWindow({
146-
title: input.label, width: 1060, height: 760, autoHideMenuBar: true,
147+
title: input.label, width: 1060, height: 760, autoHideMenuBar: true, icon: this.applicationIconPath,
147148
webPreferences: {
148149
session: profile, sandbox: true, contextIsolation: true, nodeIntegration: false,
149150
webviewTag: false, devTools: false, navigateOnDragDrop: false,

‎integrations/desktop/src/host-process.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { PlatformSession } from '@deepseek-ai/dsh-deepseek-account'
88
import { desktopNodeEnvironment } from './node-environment.ts'
99
import { enterpriseDesktopMessage, type EnterpriseDesktopMessage } from './enterprise-desktop-protocol.ts'
1010
import { parsePluginOperationRecord, type PluginOperationRecord, type PluginOperationRunId } from '@deepseek-ai/dsh-plugin-manager/diagnostic'
11+
import type { SocialLoginObservation, SocialLoginObservationResult } from './social-login.ts'
1112

1213
interface ReadyEvent {
1314
readonly type: 'ready'
@@ -46,6 +47,11 @@ type DesktopHostEvent = ReadyEvent | FatalEvent | PlatformSessionEvent | {
4647
readonly activeTasks: boolean
4748
readonly scheduledTasks: boolean
4849
readonly error?: string
50+
} | {
51+
readonly type: 'ipollo-social-login'
52+
readonly requestId: number
53+
readonly result: SocialLoginObservationResult
54+
readonly error?: string
4955
}
5056

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

361+
async observeSocialLogin(input: SocialLoginObservation, signal: AbortSignal): Promise<SocialLoginObservationResult> {
362+
const response = await this.control({ type: 'ipollo-social-login', input }, 8_000, 'Account recognition timed out', 'social login', signal)
363+
if (response.type !== 'ipollo-social-login') throw new Error('Unexpected account recognition response')
364+
return response.result
365+
}
366+
351367
private async control(
352368
request: { readonly type: 'update-tasks'; readonly action: 'inspect' | 'lock' | 'unlock' } | { readonly type: 'quit-inspection' }
353-
| { readonly type: 'file-drag-resource'; readonly address: string },
369+
| { readonly type: 'file-drag-resource'; readonly address: string }
370+
| { readonly type: 'ipollo-social-login'; readonly input: SocialLoginObservation },
354371
deadlineMs: number, deadlineMessage: string, operation: string, signal?: AbortSignal,
355372
): Promise<DesktopHostControlResponse> {
356373
const child = this.child

‎integrations/desktop/src/ipc.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { DesktopKeyboardApi, DesktopShortcutsApi } from '@deepseek-ai/dsh-c
77
import type { IpcMainInvokeEvent } from 'electron'
88
import type { DesktopBrowserBridge } from '@deepseek-ai/dsh-client-ui-sidebar-browser/types'
99
import type { DesktopFileDrag } from '@deepseek-ai/dsh-util-file-drag'
10+
import type { SocialLoginRequest, SocialLoginResult } from './social-login.ts'
1011

1112
export const DESKTOP_VERSION_ARGUMENT = '--ipollo-app-version='
1213
export const DESKTOP_FIXED_UPDATE_CHANNEL_ARGUMENT = '--ipollo-fixed-update-channel'
@@ -29,6 +30,7 @@ export const DESKTOP_IPC = {
2930
browserAcquire: 'dsh-desktop:browser-acquire',
3031
browserRelease: 'dsh-desktop:browser-release',
3132
browserOpenRequested: 'dsh-desktop:browser-open-requested',
33+
socialLogin: 'ipollo-desktop:social-login',
3234
directoryPick: 'dsh-desktop:directory-pick',
3335
fileDragPrepare: 'dsh-desktop:file-drag-prepare',
3436
fileDragCancel: 'dsh-desktop:file-drag-cancel',
@@ -99,6 +101,8 @@ export interface DshDesktopProductApi {
99101
readonly version?: string
100102
readonly appVersion: () => Promise<string>
101103
readonly browser: DesktopBrowserBridge
104+
readonly socialLogin: (request: SocialLoginRequest) => Promise<SocialLoginResult>
105+
readonly socialLoginQrEntry: true
102106
readonly organizationBrowser: true
103107
readonly organizationPackageSaveAs: true
104108
readonly fileDrag: DesktopFileDrag

0 commit comments

Comments
 (0)