@chatcode/cco-better-sidebar 0.18.0-rc.12 → 0.18.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README_EN.md +2 -0
- package/lib/client-editor.js +258 -258
- package/lib/client-mermaid.js +263 -263
- package/lib/client-registry.js +406 -393
- package/lib/client-terminal.js +265 -265
- package/lib/client.js +412 -399
- package/lib/types/client/useChatcodeAccount.d.ts +1 -0
- package/package.json +1 -1
- package/src/client/AccountMenu.tsx +5 -3
- package/src/client/useChatcodeAccount.ts +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatcode/cco-better-sidebar",
|
|
3
|
-
"version": "0.18.0-rc.
|
|
3
|
+
"version": "0.18.0-rc.13",
|
|
4
4
|
"description": "ChatCode CLI Web plugin: a VS Code-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes a service for other plugins to register sidebar tabs and file viewers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -78,7 +78,7 @@ export function AccountMenu(): JSX.Element {
|
|
|
78
78
|
const [open, setOpen] = useState(false)
|
|
79
79
|
const [logoutTarget, setLogoutTarget] = useState<'chatcode' | 'browser'>()
|
|
80
80
|
const [userName, setUserName] = useState('User')
|
|
81
|
-
const { chatcode, busy, error, loginUrl, startLogin, logout: logoutChatcode } = useChatcodeAccount()
|
|
81
|
+
const { chatcode, busy, error, loginUrl, startLogin, logout: logoutChatcode, refresh } = useChatcodeAccount()
|
|
82
82
|
|
|
83
83
|
useEffect(() => {
|
|
84
84
|
let active = true
|
|
@@ -132,6 +132,8 @@ export function AccountMenu(): JSX.Element {
|
|
|
132
132
|
|
|
133
133
|
const chatcodeName = chatcode?.userName?.trim() || chatcode?.emailAddress?.trim() || userName
|
|
134
134
|
const signedIn = chatcode?.validation === 'valid' && chatcode.expired !== true
|
|
135
|
+
// A persisted login attempt can have failed before this account validated successfully.
|
|
136
|
+
const showLoginFailure = !signedIn && (chatcode?.login?.state === 'failed' || chatcode?.login?.state === 'timed-out')
|
|
135
137
|
// A saved credential remains usable for the next check when the company
|
|
136
138
|
// network is unavailable. Do not turn that transient state into a login CTA.
|
|
137
139
|
const hasChatcodeAccount = chatcode?.available === true && chatcode.configured === true
|
|
@@ -153,7 +155,7 @@ export function AccountMenu(): JSX.Element {
|
|
|
153
155
|
{t('accountMenuSettings')}
|
|
154
156
|
</button>
|
|
155
157
|
{error === 'operation' && <div role="alert" className={css.accountItem}>{t('accountMenuChatcodeError')}</div>}
|
|
156
|
-
{
|
|
158
|
+
{showLoginFailure && <div role="alert" className={css.accountItem}>{t('accountMenuChatcodeRetry')}</div>}
|
|
157
159
|
{loginUrl && <a data-dsh-external="true" className={css.accountItem} href={loginUrl} target="_blank" rel="noopener noreferrer" onClick={event => { event.stopPropagation() }}>{t('accountMenuChatcodeOpen')}</a>}
|
|
158
160
|
{chatcode?.available === true && <>
|
|
159
161
|
{canStartChatcodeLogin && <button type="button" role="menuitem" className={css.accountItem} disabled={busy} onClick={startLogin}>
|
|
@@ -174,7 +176,7 @@ export function AccountMenu(): JSX.Element {
|
|
|
174
176
|
aria-expanded={open}
|
|
175
177
|
aria-haspopup="menu"
|
|
176
178
|
aria-label={t('accountMenuLabel')}
|
|
177
|
-
onClick={() => { setOpen(value => !value) }}
|
|
179
|
+
onClick={() => { if (!open) refresh(); setOpen(value => !value) }}
|
|
178
180
|
>
|
|
179
181
|
<span className={css.accountAvatar}>{chatcodeName.slice(0, 1).toUpperCase()}</span>
|
|
180
182
|
<span className={css.accountName}>{chatcodeName}</span>
|
|
@@ -53,8 +53,17 @@ export function useChatcodeAccount() {
|
|
|
53
53
|
}
|
|
54
54
|
void refresh()
|
|
55
55
|
const visible = (): void => { if (document.visibilityState === 'visible') void refresh() }
|
|
56
|
+
const refreshNow = (): void => { void refresh() }
|
|
56
57
|
document.addEventListener('visibilitychange', visible)
|
|
57
|
-
|
|
58
|
+
window.addEventListener('focus', refreshNow)
|
|
59
|
+
window.addEventListener('online', refreshNow)
|
|
60
|
+
return () => {
|
|
61
|
+
controller.abort()
|
|
62
|
+
clearTimeout(timer)
|
|
63
|
+
document.removeEventListener('visibilitychange', visible)
|
|
64
|
+
window.removeEventListener('focus', refreshNow)
|
|
65
|
+
window.removeEventListener('online', refreshNow)
|
|
66
|
+
}
|
|
58
67
|
}, [revision])
|
|
59
68
|
|
|
60
69
|
const operate = (action: () => Promise<void>): void => {
|
|
@@ -99,5 +108,6 @@ export function useChatcodeAccount() {
|
|
|
99
108
|
const sessionId = chatcode?.login?.sessionId
|
|
100
109
|
if (sessionId) operate(async () => { await api.chatcodeCancel(sessionId) })
|
|
101
110
|
}
|
|
102
|
-
|
|
111
|
+
const refresh = (): void => { setRevision(value => value + 1) }
|
|
112
|
+
return { chatcode, busy, error, loginUrl, startLogin, logout, cancelLogin, refresh }
|
|
103
113
|
}
|