external_edit_svc

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxMaxReadFileSizeMBForConfig

func MaxMaxReadFileSizeMBForConfig() int

func MaxReadFileSizeBytesForConfig

func MaxReadFileSizeBytesForConfig(cfg *bootstrap.AppConfig) int64

func MinMaxReadFileSizeMBForConfig

func MinMaxReadFileSizeMBForConfig() int

Types

type AssetFinder

type AssetFinder interface {
	Find(ctx context.Context, id int64) (*asset_entity.Asset, error)
}

type AutoSaveStatus

type AutoSaveStatus struct {
	DocumentKey string `json:"documentKey"`
	SessionID   string `json:"sessionId,omitempty"`
	Phase       string `json:"phase"`
}

AutoSaveStatus 只描述运行期的自动保存瞬时阶段。 它通过 runtime event 给前端做反馈,不会落到 manifest / Session 持久状态中。

type CompareResult

type CompareResult struct {
	DocumentKey             string    `json:"documentKey"`
	PrimaryDraftSessionID   string    `json:"primaryDraftSessionId"`
	LatestSnapshotSessionID string    `json:"latestSnapshotSessionId,omitempty"`
	FileName                string    `json:"fileName"`
	RemotePath              string    `json:"remotePath"`
	LocalContent            string    `json:"localContent"`
	RemoteContent           string    `json:"remoteContent"`
	ReadOnly                bool      `json:"readOnly"`
	Status                  string    `json:"status,omitempty"`
	Message                 string    `json:"message,omitempty"`
	Session                 *Session  `json:"session,omitempty"`
	Conflict                *Conflict `json:"conflict,omitempty"`
}

type Conflict

type Conflict struct {
	DocumentKey             string `json:"documentKey"`
	PrimaryDraftSessionID   string `json:"primaryDraftSessionId"`
	LatestSnapshotSessionID string `json:"latestSnapshotSessionId,omitempty"`
}

Conflict 描述 document 级冲突关系: primaryDraftSessionId 永远指向用户正在保留的原始草稿; latestSnapshotSessionId 只在执行 reread 后出现,用来标记最新远端快照副本。

type Editor

type Editor struct {
	ID        string   `json:"id"`
	Name      string   `json:"name"`
	Path      string   `json:"path"`
	Args      []string `json:"args,omitempty"`
	BuiltIn   bool     `json:"builtIn"`
	Available bool     `json:"available"`
	Default   bool     `json:"default"`
}

type ErrorSnapshot

type ErrorSnapshot struct {
	Step       string `json:"step"`
	Summary    string `json:"summary"`
	Suggestion string `json:"suggestion"`
	At         int64  `json:"at"`
}

ErrorSnapshot 只保留用户能理解、且不泄露 transport / 本地路径细节的失败摘要。 记录层会把最近一次失败沉淀到这里,前端再按文件态展示失败步骤和恢复建议。

type Event

type Event struct {
	Type       string          `json:"type"`
	Session    *Session        `json:"session,omitempty"`
	SaveResult *SaveResult     `json:"saveResult,omitempty"`
	AutoSave   *AutoSaveStatus `json:"autoSave,omitempty"`
}

type Launcher

type Launcher interface {
	Launch(path string, args []string) error
}

type MergeApplyRequest

type MergeApplyRequest struct {
	SessionID    string `json:"sessionId"`
	FinalContent string `json:"finalContent"`
	RemoteHash   string `json:"remoteHash"`
}

type MergePrepareResult

type MergePrepareResult struct {
	DocumentKey           string   `json:"documentKey"`
	PrimaryDraftSessionID string   `json:"primaryDraftSessionId"`
	FileName              string   `json:"fileName"`
	RemotePath            string   `json:"remotePath"`
	LocalContent          string   `json:"localContent"`
	RemoteContent         string   `json:"remoteContent"`
	FinalContent          string   `json:"finalContent"`
	RemoteHash            string   `json:"remoteHash"`
	Session               *Session `json:"session,omitempty"`
}

type OpenRequest

type OpenRequest struct {
	AssetID    int64  `json:"assetId"`
	SessionID  string `json:"sessionId"`
	RemotePath string `json:"remotePath"`
	EditorID   string `json:"editorId,omitempty"`
}

type Options

type Options struct {
	DataDir        string
	ConfigProvider func() *bootstrap.AppConfig
	ConfigSaver    func(cfg *bootstrap.AppConfig) error
	Remote         RemoteFileService
	FindSessions   func(assetID int64) []string
	Assets         AssetFinder
	Audit          audit_repo.AuditRepo
	Emit           func(Event)
	Launch         Launcher
	Now            func() time.Time
}

type RemoteFileService

type RemoteFileService interface {
	Stat(sessionID, remotePath string) (*sftp_svc.RemoteFileInfo, error)
	ReadFile(sessionID, remotePath string) ([]byte, *sftp_svc.RemoteFileInfo, error)
	WriteFile(sessionID, remotePath string, data []byte) error
}

type SaveResult

type SaveResult struct {
	Status    string    `json:"status"`
	Message   string    `json:"message,omitempty"`
	Session   *Session  `json:"session,omitempty"`
	Conflict  *Conflict `json:"conflict,omitempty"`
	Automatic bool      `json:"automatic,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) (*Service, error)

func (*Service) ApplyMerge

func (s *Service) ApplyMerge(ctx context.Context, req MergeApplyRequest) (*SaveResult, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Compare

func (s *Service) Compare(sessionID string) (*CompareResult, error)

func (*Service) Continue

func (s *Service) Continue(sessionID string) (*Session, error)

func (*Service) GetSettings

func (s *Service) GetSettings() (*Settings, error)

func (*Service) ListSessions

func (s *Service) ListSessions() []*Session

func (*Service) Open

func (s *Service) Open(ctx context.Context, req OpenRequest) (*Session, error)

func (*Service) PrepareMerge

func (s *Service) PrepareMerge(sessionID string) (*MergePrepareResult, error)

func (*Service) Recover

func (s *Service) Recover(sessionID string) (*Session, error)

func (*Service) Refresh

func (s *Service) Refresh(sessionID string) (*Session, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, sessionID, resolution string) (*SaveResult, error)

func (*Service) Save

func (s *Service) Save(ctx context.Context, sessionID string) (*SaveResult, error)

func (*Service) SaveSettings

func (s *Service) SaveSettings(input SettingsInput) (*Settings, error)

func (*Service) Start

func (s *Service) Start(context.Context) error

type Session

type Session struct {
	ID             string   `json:"id"`
	AssetID        int64    `json:"assetId"`
	AssetName      string   `json:"assetName"`
	DocumentKey    string   `json:"documentKey"`
	SessionID      string   `json:"sessionId"`
	RemotePath     string   `json:"remotePath"`
	RemoteRealPath string   `json:"remoteRealPath"`
	LocalPath      string   `json:"localPath"`
	WorkspaceRoot  string   `json:"workspaceRoot"`
	WorkspaceDir   string   `json:"workspaceDir"`
	EditorID       string   `json:"editorId"`
	EditorName     string   `json:"editorName"`
	EditorPath     string   `json:"editorPath"`
	EditorArgs     []string `json:"editorArgs,omitempty"`
	// OriginalSHA256 保留旧字段名以兼容现有 manifest / IPC,语义上等同于当前 document 的 baseHash。
	OriginalSHA256     string `json:"originalSha256"`
	OriginalSize       int64  `json:"originalSize"`
	OriginalModTime    int64  `json:"originalModTime"`
	OriginalEncoding   string `json:"originalEncoding"`
	OriginalBOM        string `json:"originalBom,omitempty"`
	OriginalByteSample string `json:"originalByteSample,omitempty"`
	// LastLocalSHA256 同样保留兼容字段名,语义上等同于最近一次落盘的 localHash。
	LastLocalSHA256       string         `json:"lastLocalSha256"`
	Dirty                 bool           `json:"dirty"`
	State                 string         `json:"state"`
	RecordState           string         `json:"recordState,omitempty"`
	SaveMode              string         `json:"saveMode,omitempty"`
	PendingReview         bool           `json:"pendingReview,omitempty"`
	Hidden                bool           `json:"hidden"`
	Expired               bool           `json:"expired"`
	LastError             *ErrorSnapshot `json:"lastError,omitempty"`
	ResumeRequired        bool           `json:"resumeRequired,omitempty"`
	MergeRemoteSHA256     string         `json:"mergeRemoteSha256,omitempty"`
	SourceSessionID       string         `json:"sourceSessionId,omitempty"`
	SupersededBySessionID string         `json:"supersededBySessionId,omitempty"`
	CreatedAt             int64          `json:"createdAt"`
	UpdatedAt             int64          `json:"updatedAt"`
	LastLaunchedAt        int64          `json:"lastLaunchedAt"`
	LastSyncedAt          int64          `json:"lastSyncedAt"`
}

Session 是桌面端外部编辑的单一事实记录: 它同时串起远端基线、本地副本、编辑器选择、冲突状态和恢复信息,前后端都围绕这份记录推进状态。

type Settings

type Settings struct {
	DefaultEditorID      string                           `json:"defaultEditorId"`
	WorkspaceRoot        string                           `json:"workspaceRoot"`
	CleanupRetentionDays int                              `json:"cleanupRetentionDays"`
	MaxReadFileSizeMB    int                              `json:"maxReadFileSizeMB"`
	Editors              []Editor                         `json:"editors"`
	CustomEditors        []bootstrap.ExternalEditorConfig `json:"customEditors"`
}

type SettingsInput

type SettingsInput struct {
	DefaultEditorID      string                           `json:"defaultEditorId"`
	WorkspaceRoot        string                           `json:"workspaceRoot"`
	CleanupRetentionDays int                              `json:"cleanupRetentionDays"`
	MaxReadFileSizeMB    int                              `json:"maxReadFileSizeMB"`
	CustomEditors        []bootstrap.ExternalEditorConfig `json:"customEditors"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL