Skip to content

Commit 8d0216a

Browse files
committed
Lift update check to root component and display update indicator in header
- when there is a new version, 'back' button in header of main view should have dot in top right corner - do update checks from Prompt so move the hook to `apps/editor/src/views/prompt/frontend/hooks` - add 'has update' to main ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Home │ │ └── Home.tsx │ ├── Main │ │ ├── Main.tsx │ │ └── MainView │ │ ├── MainView.tsx │ │ └── components │ │ └── Header │ │ ├── Header.module.scss │ │ └── Header.tsx │ ├── Prompt.tsx │ └── hooks │ ├── use-alt-pressed.ts │ ├── use-api-configuration-editing.ts │ ├── use-cli-configuration-editing.ts │ ├── use-editor-sync.ts │ ├── use-is-landscape.ts │ ├── use-modal-manager.ts │ ├── use-preview-manager.ts │ ├── use-prompt │ │ ├── hooks │ │ │ └── use-instructions.ts │ │ ├── index.ts │ │ └── use-prompt.ts │ ├── use-recent-donations.ts │ ├── use-response-history.ts │ ├── use-update-check.ts │ └── use-web-configuration-editing.ts └── packages └── ui └── src └── components └── editor └── common └── Button ├── Button.module.scss └── Button.tsx
1 parent fdca53e commit 8d0216a

7 files changed

Lines changed: 42 additions & 14 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
CliPromptType
2121
} from '@shared/types/prompt-types'
2222
import { use_is_landscape } from '../hooks/use-is-landscape'
23-
import { use_update_check } from './hooks/use-update-check'
23+
import { UpdateInfo } from '../hooks/use-update-check'
2424
import { UpdateAvailable as UiUpdateAvailable } from '@ui/components/editor/prompt-view/UpdateAvailable'
2525

2626
type Props = {
@@ -36,6 +36,7 @@ type Props = {
3636
web_prompt_type: WebPromptType
3737
api_prompt_type: ApiPromptType
3838
cli_prompt_type: CliPromptType
39+
update_info: UpdateInfo
3940
}
4041

4142
export const Home: React.FC<Props> = (props) => {
@@ -71,8 +72,6 @@ export const Home: React.FC<Props> = (props) => {
7172
is_disabled: is_landscape
7273
})
7374

74-
const update_info = use_update_check(props.version, props.is_active)
75-
7675
const header_targets_ref = useRef<HTMLDivElement>(null)
7776

7877
const discord_label = 'Discord'
@@ -159,27 +158,27 @@ export const Home: React.FC<Props> = (props) => {
159158
</div>
160159
)
161160

162-
const update_section = update_info.is_available ? (
161+
const update_section = props.update_info.is_available ? (
163162
<>
164163
<div className={styles.inner__update}>
165164
<UiUpdateAvailable
166165
on_update={() =>
167166
post_message(props.vscode, { command: 'UPDATE_EXTENSION' })
168167
}
169168
current_version={props.version}
170-
latest_version={update_info.latest_version}
169+
latest_version={props.update_info.latest_version}
171170
translations={{
172171
title: t('home.update.title'),
173172
button: t('home.update.button'),
174-
age: update_info.current_version_age_days ? (
173+
age: props.update_info.current_version_age_days ? (
175174
<Translation
176175
id={
177-
update_info.current_version_age_days === 1
176+
props.update_info.current_version_age_days === 1
178177
? 'home.update.age.singular'
179178
: 'home.update.age'
180179
}
181180
components={{
182-
days: update_info.current_version_age_days.toString()
181+
days: props.update_info.current_version_age_days.toString()
183182
}}
184183
/>
185184
) : undefined,

‎apps/editor/src/views/prompt/frontend/Main/Main.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type Props = {
9090
) => void
9191
on_skill_click?: (agent: string, repo: string, skill_name: string) => void
9292
on_agentic_search: () => void
93+
has_update?: boolean
9394
}
9495

9596
export const Main: React.FC<Props> = (props) => {
@@ -748,6 +749,7 @@ export const Main: React.FC<Props> = (props) => {
748749
completed_tasks={completed_tasks}
749750
on_task_completed={handle_task_completed}
750751
on_clear_completed_tasks={handle_clear_completed_tasks}
752+
has_update={props.has_update}
751753
/>
752754
)
753755
}

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ type Props = {
154154
completed_tasks: string[]
155155
on_task_completed: () => void
156156
on_clear_completed_tasks: () => void
157+
has_update?: boolean
157158
}
158159

159160
const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
@@ -355,6 +356,7 @@ export const MainView: React.FC<Props> = (props) => {
355356
is_content_scrollable={is_content_scrollable}
356357
is_api_warning_visible={is_api_warning_visible}
357358
response_history={props.response_history}
359+
has_update={props.has_update || false}
358360
/>
359361
)
360362

‎apps/editor/src/views/prompt/frontend/Main/MainView/components/Header/Header.module.scss‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@
3939

4040
&__back {
4141
display: flex;
42+
43+
&_wrapper {
44+
position: relative;
45+
display: flex;
46+
}
47+
}
48+
49+
&__update_dot {
50+
position: absolute;
51+
right: 0;
52+
--size: 6px;
53+
width: var(--size);
54+
height: var(--size);
55+
border-radius: 50%;
56+
background-color: var(--vscode-button-background);
57+
pointer-events: none;
4258
}
4359

4460
&__types {

‎apps/editor/src/views/prompt/frontend/Main/MainView/components/Header/Header.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Props = {
3535
is_content_scrollable: boolean
3636
is_api_warning_visible: boolean
3737
response_history: ResponseHistoryItem[]
38+
has_update: boolean
3839
}
3940

4041
export const Header: React.FC<Props> = (props) => {
@@ -51,11 +52,14 @@ export const Header: React.FC<Props> = (props) => {
5152
>
5253
<div className={styles.header__left}>
5354
<div className={styles.header__back}>
54-
<UiIconButton
55-
codicon_icon="chevron-left"
56-
on_click={props.on_show_home}
57-
title={`${t('header.return')} (Esc)`}
58-
/>
55+
<div className={styles.header__back_wrapper}>
56+
<UiIconButton
57+
codicon_icon="chevron-left"
58+
on_click={props.on_show_home}
59+
title={`${t('header.return')} (Esc)`}
60+
/>
61+
{!props.has_update && <div className={styles.header__update_dot} />}
62+
</div>
5963
</div>
6064

6165
<div className={styles.header__types}>

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { EditApiConfigurationForm } from '@/views/shared/forms/EditApiConfigurat
3131
import { use_cli_configuration_editing } from './hooks/use-cli-configuration-editing'
3232
import { EditCliConfigurationForm } from '@/views/shared/forms/EditCliConfigurationForm/EditCliConfigurationForm'
3333
import { use_translation } from './i18n/use-translation'
34+
import { use_update_check } from './hooks/use-update-check'
3435

3536
const vscode = acquireVsCodeApi()
3637

@@ -165,6 +166,8 @@ export const Prompt = () => {
165166
const { viewing_donations, set_viewing_donations, ...donations_state } =
166167
use_recent_donations()
167168

169+
const update_info = use_update_check(version, true)
170+
168171
if (
169172
ask_about_context_instructions === undefined ||
170173
edit_files_instructions === undefined ||
@@ -289,6 +292,7 @@ export const Prompt = () => {
289292
})}
290293
>
291294
<Main
295+
has_update={update_info.is_available}
292296
api_configurations={api_configurations}
293297
set_api_configurations={set_api_configurations}
294298
scroll_reset_key={main_view_scroll_reset_key}
@@ -432,6 +436,7 @@ export const Prompt = () => {
432436
version={version}
433437
is_setup_complete={is_setup_complete}
434438
on_donate_click={() => set_viewing_donations(true)}
439+
update_info={update_info}
435440
/>
436441
</div>
437442
</Layout>

apps/editor/src/views/prompt/frontend/Home/hooks/use-update-check.ts renamed to apps/editor/src/views/prompt/frontend/hooks/use-update-check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from 'react'
22

3-
type UpdateInfo = {
3+
export type UpdateInfo = {
44
is_available: boolean
55
latest_version?: string
66
current_version_age_days?: number

0 commit comments

Comments
 (0)