legacy message for v7 upgrades (#858)

This commit is contained in:
Mike Sawka 2024-09-25 15:52:12 -07:00 committed by GitHub
parent f886aa1e8e
commit fbbacbc09b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 98 additions and 28 deletions

View File

@ -219,10 +219,6 @@ func main() {
log.Printf("error initializing wstore: %v\n", err) log.Printf("error initializing wstore: %v\n", err)
return return
} }
migrateErr := wstore.TryMigrateOldHistory()
if migrateErr != nil {
log.Printf("error migrating old history: %v\n", migrateErr)
}
go func() { go func() {
err := shellutil.InitCustomShellStartupFiles() err := shellutil.InitCustomShellStartupFiles()
if err != nil { if err != nil {
@ -234,6 +230,12 @@ func main() {
log.Printf("error ensuring initial data: %v\n", err) log.Printf("error ensuring initial data: %v\n", err)
return return
} }
if firstRun {
migrateErr := wstore.TryMigrateOldHistory()
if migrateErr != nil {
log.Printf("error migrating old history: %v\n", migrateErr)
}
}
if window != nil { if window != nil {
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second) ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
defer cancelFn() defer cancelFn()

View File

@ -233,6 +233,10 @@
font-size: 14px; font-size: 14px;
} }
button:not(:first-child) {
margin-left: 10px;
}
button.disabled-button { button.disabled-button {
cursor: default; cursor: default;
} }

View File

@ -10,7 +10,7 @@ import { useEffect, useRef, useState } from "react";
import { FlexiModal } from "./modal"; import { FlexiModal } from "./modal";
import { QuickTips } from "@/app/element/quicktips"; import { QuickTips } from "@/app/element/quicktips";
import { atoms } from "@/app/store/global"; import { atoms, getApi } from "@/app/store/global";
import { modalsModel } from "@/app/store/modalmodel"; import { modalsModel } from "@/app/store/modalmodel";
import { atom, PrimitiveAtom, useAtom, useAtomValue, useSetAtom } from "jotai"; import { atom, PrimitiveAtom, useAtom, useAtomValue, useSetAtom } from "jotai";
import "./tos.less"; import "./tos.less";
@ -153,6 +153,58 @@ const ModalPage2 = () => {
); );
}; };
const ModalPageLegacy = () => {
const setPageNum = useSetAtom(pageNumAtom);
const handleContinue = () => {
setPageNum(1);
};
const handleDownloadLegacy = () => {
getApi().openExternal("https://waveterm.dev/download-legacy?ref=v7upgrade");
};
return (
<>
<header className="modal-header tos-header unselectable">
<div className="logo">
<Logo />
</div>
<div className="modal-title">Welcome to Wave v0.8</div>
</header>
<div className="modal-content tos-content unselectable">
<div className="item">
Were excited to announce the release of Wave Terminal v0.8. This update introduces a brand-new
layout engine, featuring drag-and-drop screen splitting with flexible block sizing and positioning.
We've also integrated powerful tools like file previews, an editor, web integration, and AI, all
designed to keep you focused and minimize context switching. And for the first time, Wave Terminal
runs <b>natively on Windows</b>!
</div>
<div>
Wave v0.8 is less opinionated, giving you the freedom to use your standard terminal prompt and
command completions, while supporting all shells (not just bash/zsh). We've also improved
compatibility with ohmyzsh packages, removing some of the friction users experienced. Its faster,
more performant, and provides a stronger foundation for you to build your own blocks and widgets in
the future.
</div>
<div className="item">
The new build is a fresh start, and a clean break from the current version. As such, your history,
settings, and configuration will <i>not</i> be carried over. If you'd like to continue to run the
legacy version, you will need to download it separately.
</div>
</div>
<footer className="unselectable">
<div className="button-wrapper">
<Button className="outlined grey" onClick={handleDownloadLegacy}>
Download WaveLegacy
</Button>
<Button className="font-weight-600" onClick={handleContinue}>
Continue
</Button>
</div>
</footer>
</>
);
};
const TosModal = () => { const TosModal = () => {
const modalRef = useRef<HTMLDivElement | null>(null); const modalRef = useRef<HTMLDivElement | null>(null);
const [pageNum, setPageNum] = useAtom(pageNumAtom); const [pageNum, setPageNum] = useAtom(pageNumAtom);
@ -173,7 +225,9 @@ const TosModal = () => {
useEffect(() => { useEffect(() => {
// on unmount, always reset pagenum // on unmount, always reset pagenum
if (clientData.tosagreed) { if (!clientData.tosagreed && clientData.hasoldhistory) {
setPageNum(0);
} else if (clientData.tosagreed) {
setPageNum(2); setPageNum(2);
} }
return () => { return () => {
@ -189,11 +243,25 @@ const TosModal = () => {
window.removeEventListener("resize", updateModalHeight); window.removeEventListener("resize", updateModalHeight);
}; };
}, []); }, []);
let pageComp: React.JSX.Element = null;
switch (pageNum) {
case 0:
pageComp = <ModalPageLegacy />;
break;
case 1:
pageComp = <ModalPage1 />;
break;
case 2:
pageComp = <ModalPage2 />;
break;
}
if (pageComp == null) {
return null;
}
return ( return (
<FlexiModal className="tos-modal" ref={modalRef}> <FlexiModal className="tos-modal" ref={modalRef}>
<OverlayScrollbarsComponent className="modal-inner" options={{ scrollbars: { autoHide: "leave" } }}> <OverlayScrollbarsComponent className="modal-inner" options={{ scrollbars: { autoHide: "leave" } }}>
{pageNum === 1 ? <ModalPage1 /> : <ModalPage2 />} {pageComp}
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
</FlexiModal> </FlexiModal>
); );

View File

@ -44,7 +44,7 @@ declare global {
type Client = WaveObj & { type Client = WaveObj & {
windowids: string[]; windowids: string[];
tosagreed?: number; tosagreed?: number;
historymigrated?: boolean; hasoldhistory?: boolean;
}; };
// wshrpc.CommandAppendIJsonData // wshrpc.CommandAppendIJsonData

View File

@ -117,7 +117,7 @@ type Client struct {
WindowIds []string `json:"windowids"` WindowIds []string `json:"windowids"`
Meta MetaMapType `json:"meta"` Meta MetaMapType `json:"meta"`
TosAgreed int64 `json:"tosagreed,omitempty"` TosAgreed int64 `json:"tosagreed,omitempty"`
HistoryMigrated bool `json:"historymigrated,omitempty"` HasOldHistory bool `json:"hasoldhistory,omitempty"`
} }
func (*Client) GetOType() string { func (*Client) GetOType() string {

View File

@ -83,19 +83,6 @@ func ReplaceOldHistory(ctx context.Context, hist []*OldHistoryType) error {
func TryMigrateOldHistory() error { func TryMigrateOldHistory() error {
ctx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelFn() defer cancelFn()
client, err := DBGetSingleton[*waveobj.Client](ctx)
if err != nil {
return err
}
if client.HistoryMigrated {
return nil
}
log.Printf("trying to migrate old wave history\n")
client.HistoryMigrated = true
err = DBUpdate(ctx, client)
if err != nil {
return err
}
hist, err := GetAllOldHistory() hist, err := GetAllOldHistory()
if err != nil { if err != nil {
return err return err
@ -108,5 +95,14 @@ func TryMigrateOldHistory() error {
return err return err
} }
log.Printf("migrated %d old wave history records\n", len(hist)) log.Printf("migrated %d old wave history records\n", len(hist))
client, err := DBGetSingleton[*waveobj.Client](ctx)
if err != nil {
return err
}
client.HasOldHistory = true
err = DBUpdate(ctx, client)
if err != nil {
return err
}
return nil return nil
} }