mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
This commit is contained in:
parent
d65eabe494
commit
1742c19e13
@ -10,7 +10,9 @@ class BlockServiceType {
|
|||||||
GetControllerStatus(arg2: string): Promise<BlockControllerRuntimeStatus> {
|
GetControllerStatus(arg2: string): Promise<BlockControllerRuntimeStatus> {
|
||||||
return WOS.callBackendService("block", "GetControllerStatus", Array.from(arguments))
|
return WOS.callBackendService("block", "GetControllerStatus", Array.from(arguments))
|
||||||
}
|
}
|
||||||
SaveTerminalState(arg2: string, arg3: string, arg4: string, arg5: number): Promise<void> {
|
|
||||||
|
// save the terminal state to a blockfile
|
||||||
|
SaveTerminalState(blockId: string, state: string, stateType: string, ptyOffset: number, termSize: TermSize): Promise<void> {
|
||||||
return WOS.callBackendService("block", "SaveTerminalState", Array.from(arguments))
|
return WOS.callBackendService("block", "SaveTerminalState", Array.from(arguments))
|
||||||
}
|
}
|
||||||
SaveWaveAiData(arg2: string, arg3: OpenAIPromptMessageType[]): Promise<void> {
|
SaveWaveAiData(arg2: string, arg3: OpenAIPromptMessageType[]): Promise<void> {
|
||||||
|
@ -216,7 +216,21 @@ export class TermWrap {
|
|||||||
if (cacheFile != null) {
|
if (cacheFile != null) {
|
||||||
ptyOffset = cacheFile.meta["ptyoffset"] ?? 0;
|
ptyOffset = cacheFile.meta["ptyoffset"] ?? 0;
|
||||||
if (cacheData.byteLength > 0) {
|
if (cacheData.byteLength > 0) {
|
||||||
|
const curTermSize: TermSize = { rows: this.terminal.rows, cols: this.terminal.cols };
|
||||||
|
const fileTermSize: TermSize = cacheFile.meta["termsize"];
|
||||||
|
let didResize = false;
|
||||||
|
if (
|
||||||
|
fileTermSize != null &&
|
||||||
|
(fileTermSize.rows != curTermSize.rows || fileTermSize.cols != curTermSize.cols)
|
||||||
|
) {
|
||||||
|
console.log("terminal restore size mismatch, temp resize", fileTermSize, curTermSize);
|
||||||
|
this.terminal.resize(fileTermSize.cols, fileTermSize.rows);
|
||||||
|
didResize = true;
|
||||||
|
}
|
||||||
this.doTerminalWrite(cacheData, ptyOffset);
|
this.doTerminalWrite(cacheData, ptyOffset);
|
||||||
|
if (didResize) {
|
||||||
|
this.terminal.resize(curTermSize.cols, curTermSize.rows);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { data: mainData, fileInfo: mainFile } = await fetchWaveFile(this.blockId, TermFileName, ptyOffset);
|
const { data: mainData, fileInfo: mainFile } = await fetchWaveFile(this.blockId, TermFileName, ptyOffset);
|
||||||
@ -268,8 +282,9 @@ export class TermWrap {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const serializedOutput = this.serializeAddon.serialize();
|
const serializedOutput = this.serializeAddon.serialize();
|
||||||
console.log("idle timeout term", this.dataBytesProcessed, serializedOutput.length);
|
const termSize: TermSize = { rows: this.terminal.rows, cols: this.terminal.cols };
|
||||||
services.BlockService.SaveTerminalState(this.blockId, serializedOutput, "full", this.ptyOffset);
|
console.log("idle timeout term", this.dataBytesProcessed, serializedOutput.length, termSize);
|
||||||
|
services.BlockService.SaveTerminalState(this.blockId, serializedOutput, "full", this.ptyOffset, termSize);
|
||||||
this.dataBytesProcessed = 0;
|
this.dataBytesProcessed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,14 @@ func (bs *BlockService) GetControllerStatus(ctx context.Context, blockId string)
|
|||||||
return bc.GetRuntimeStatus(), nil
|
return bc.GetRuntimeStatus(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *BlockService) SaveTerminalState(ctx context.Context, blockId string, state string, stateType string, ptyOffset int64) error {
|
func (*BlockService) SaveTerminalState_Meta() tsgenmeta.MethodMeta {
|
||||||
|
return tsgenmeta.MethodMeta{
|
||||||
|
Desc: "save the terminal state to a blockfile",
|
||||||
|
ArgNames: []string{"ctx", "blockId", "state", "stateType", "ptyOffset", "termSize"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bs *BlockService) SaveTerminalState(ctx context.Context, blockId string, state string, stateType string, ptyOffset int64, termSize waveobj.TermSize) error {
|
||||||
_, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId)
|
_, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -52,7 +59,11 @@ func (bs *BlockService) SaveTerminalState(ctx context.Context, blockId string, s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot save terminal state: %w", err)
|
return fmt.Errorf("cannot save terminal state: %w", err)
|
||||||
}
|
}
|
||||||
err = filestore.WFS.WriteMeta(ctx, blockId, "cache:term:"+stateType, filestore.FileMeta{"ptyoffset": ptyOffset}, true)
|
fileMeta := filestore.FileMeta{
|
||||||
|
"ptyoffset": ptyOffset,
|
||||||
|
"termsize": termSize,
|
||||||
|
}
|
||||||
|
err = filestore.WFS.WriteMeta(ctx, blockId, "cache:term:"+stateType, fileMeta, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot save terminal state meta: %w", err)
|
return fmt.Errorf("cannot save terminal state meta: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user