mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
reinit updates (#500)
* working on re-init when you create a tab. some refactoring of existing reinit to make the messaging clearer. auto-connect, etc. * working to remove the 'default' shell states out of MShellProc. each tab should have its own state that gets set on open. * refactor newtab settings into individual components (and move to a new file) * more refactoring of tab settings -- use same control in settings and newtab * have screensettings use the same newtab settings components * use same conn dropdown, fix classes, update some of the confirm messages to be less confusing (replace screen with tab) * force a cr on a new tab to initialize state in a new line. poc right now, need to add to new workspace workflow as well * small fixups * remove nohist from GetRawStr, make const * update hover behavior for tabs * fix interaction between change remote dropdown, cmdinput, error handling, and selecting a remote * only switch screen remote if the activemainview is session (new remote flow). don't switch it if we're on the connections page which is confusing. also make it interactive * fix wording on tos modal * allow empty workspaces. also allow the last workspace to be deleted. (prep for new startup sequence where we initialize the first session after tos modal) * add some dead code that might come in use later (when we change how we show connection in cmdinput) * working a cople different angles. new settings tab-pulldown (likely orphaned). and then allowing null activeScreen and null activeSession in workspaceview (show appropriate messages, and give buttons to create new tabs/workspaces). prep for new startup flow * don't call initActiveShells anymore. also call ensureWorkspace() on TOS close * trying to use new pulldown screen settings * experiment with an escape keybinding * working on tab settings close triggers * close tab settings on tab switch * small updates to tos popup, reorder, update button text/size, small wording updates * when deleting a screen, send SIGHUP to all running commands * not sure how this happened, lineid should not be passed to setLineFocus * remove context timeouts for ReInit (it is now interactive, so it gets canceled like a normal command -- via ^C, and should not timeout on its own) * deal with screen/session tombstones updates (ignore to quite warning) * remove defaultfestate from remote * fix issue with removing default ris * remove dead code * open the settings pulldown for new screens * update prompt to show when the shell is still initializing (or if it failed) * switch buttons to use wave button class, update messages, and add warning for no shell state * all an override of rptr for dyncmds. needed for the 'connect' command (we need to set the rptr to the *new* connection rather than the old one) * remove old commented out code
This commit is contained in:
@@ -386,9 +386,9 @@ func GetSessionByName(ctx context.Context, name string) (*SessionType, error) {
|
||||
return session, nil
|
||||
}
|
||||
|
||||
// returns sessionId
|
||||
// returns (update, newSessionId, newScreenId, error)
|
||||
// if sessionName == "", it will be generated
|
||||
func InsertSessionWithName(ctx context.Context, sessionName string, activate bool) (*scbus.ModelUpdatePacketType, error) {
|
||||
func InsertSessionWithName(ctx context.Context, sessionName string, activate bool) (*scbus.ModelUpdatePacketType, string, string, error) {
|
||||
var newScreen *ScreenType
|
||||
newSessionId := scbase.GenWaveUUID()
|
||||
txErr := WithTx(ctx, func(tx *TxWrap) error {
|
||||
@@ -414,11 +414,11 @@ func InsertSessionWithName(ctx context.Context, sessionName string, activate boo
|
||||
return nil
|
||||
})
|
||||
if txErr != nil {
|
||||
return nil, txErr
|
||||
return nil, "", "", txErr
|
||||
}
|
||||
session, err := GetSessionById(ctx, newSessionId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, "", "", err
|
||||
}
|
||||
update := scbus.MakeUpdatePacket()
|
||||
update.AddUpdate(*session)
|
||||
@@ -426,7 +426,7 @@ func InsertSessionWithName(ctx context.Context, sessionName string, activate boo
|
||||
if activate {
|
||||
update.AddUpdate(ActiveSessionIdUpdate(newSessionId))
|
||||
}
|
||||
return update, nil
|
||||
return update, newSessionId, newScreen.ScreenId, nil
|
||||
}
|
||||
|
||||
func SetActiveSessionId(ctx context.Context, sessionId string) error {
|
||||
@@ -569,6 +569,9 @@ func InsertScreen(ctx context.Context, sessionId string, origScreenName string,
|
||||
query = `UPDATE session SET activescreenid = ? WHERE sessionid = ?`
|
||||
tx.Exec(query, newScreenId, sessionId)
|
||||
}
|
||||
if opts.RtnScreenId != nil {
|
||||
*opts.RtnScreenId = newScreenId
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if txErr != nil {
|
||||
@@ -1044,11 +1047,6 @@ func DeleteScreen(ctx context.Context, screenId string, sessionDel bool, update
|
||||
if sessionId == "" {
|
||||
return fmt.Errorf("cannot delete screen (no sessionid)")
|
||||
}
|
||||
query = `SELECT count(*) FROM screen WHERE sessionid = ? AND NOT archived`
|
||||
numScreens := tx.GetInt(query, sessionId)
|
||||
if numScreens <= 1 {
|
||||
return fmt.Errorf("cannot delete the last screen in a session")
|
||||
}
|
||||
isActive = tx.Exists(`SELECT sessionid FROM session WHERE sessionid = ? AND activescreenid = ?`, sessionId, screenId)
|
||||
if isActive {
|
||||
screenIds := tx.SelectStrings(`SELECT screenid FROM screen WHERE sessionid = ? AND NOT archived ORDER BY screenidx`, sessionId)
|
||||
|
||||
@@ -375,6 +375,7 @@ type ScreenCreateOpts struct {
|
||||
CopyRemote bool
|
||||
CopyCwd bool
|
||||
CopyEnv bool
|
||||
RtnScreenId *string
|
||||
}
|
||||
|
||||
func (sco ScreenCreateOpts) HasCopy() bool {
|
||||
@@ -760,7 +761,6 @@ type RemoteRuntimeState struct {
|
||||
RemoteAlias string `json:"remotealias,omitempty"`
|
||||
RemoteCanonicalName string `json:"remotecanonicalname"`
|
||||
RemoteVars map[string]string `json:"remotevars"`
|
||||
DefaultFeState map[string]string `json:"defaultfestate"`
|
||||
Status string `json:"status"`
|
||||
ConnectTimeout int `json:"connecttimeout,omitempty"`
|
||||
CountdownActive bool `json:"countdownactive"`
|
||||
@@ -779,9 +779,9 @@ type RemoteRuntimeState struct {
|
||||
MShellVersion string `json:"mshellversion"`
|
||||
WaitingForPassword bool `json:"waitingforpassword,omitempty"`
|
||||
Local bool `json:"local,omitempty"`
|
||||
IsSudo bool `json:"issudo,omitempty"`
|
||||
RemoteOpts *RemoteOptsType `json:"remoteopts,omitempty"`
|
||||
CanComplete bool `json:"cancomplete,omitempty"`
|
||||
ActiveShells []string `json:"activeshells,omitempty"`
|
||||
ShellPref string `json:"shellpref,omitempty"`
|
||||
DefaultShellType string `json:"defaultshelltype,omitempty"`
|
||||
}
|
||||
@@ -1127,21 +1127,6 @@ func EnsureLocalRemote(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func EnsureOneSession(ctx context.Context) error {
|
||||
numSessions, err := GetSessionCount(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if numSessions > 0 {
|
||||
return nil
|
||||
}
|
||||
_, err = InsertSessionWithName(ctx, DefaultSessionName, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func createClientData(tx *TxWrap) error {
|
||||
curve := elliptic.P384()
|
||||
pkey, err := ecdsa.GenerateKey(curve, rand.Reader)
|
||||
|
||||
Reference in New Issue
Block a user