Fix server file browse flow

This commit is contained in:
npc0-hue
2026-08-26 22:00:23 +08:00
parent 861ee752ed
commit 6369a8099a
22 changed files with 627 additions and 132 deletions
+10
View File
@@ -1,6 +1,7 @@
package service
import (
"context"
"crypto/pbkdf2"
"crypto/rand"
"crypto/sha256"
@@ -126,6 +127,7 @@ type Core interface {
GetServerFileWorkspaceForSession(string, string) (domain.ServerFileWorkspaceView, error)
ListServerFilesForSession(string, domain.ServerFileListRequest) (domain.ServerFileListResult, error)
RefreshServerFileListForSession(string, domain.ServerFileListRequest) (domain.ServerFileListResult, error)
BrowseServerFilesForSession(context.Context, string, domain.ServerFileListRequest) (domain.ServerFileListResult, error)
ReadServerFileForSession(string, domain.ServerFileReadRequest) (domain.FileOperationDispatchResult, error)
WriteServerFileForSession(string, domain.ServerFileWriteRequest) (domain.FileOperationDispatchResult, error)
UploadServerFileForSession(string, domain.ServerFileUploadRequest) (domain.ServerFileUploadDispatch, error)
@@ -140,6 +142,7 @@ type Core interface {
ListJobsForSession(string, domain.JobFilter) ([]domain.Job, error)
RequestRunJobCancelForSession(string, domain.RunJobCancelRequest) (domain.RunJobCancelRequestResult, error)
ClaimRunJob(domain.RunJobClaim) (domain.RunJobClaimResult, error)
ClaimRunJobWithWait(context.Context, domain.RunJobClaim) (domain.RunJobClaimResult, error)
AckRunJob(domain.RunJobAck) (domain.RunJobAckResult, error)
UpdateRunJobProgress(domain.RunJobProgress) (domain.RunJobProgressResult, error)
CompleteRunJob(domain.RunJobResult) (domain.RunJobResultResult, error)
@@ -231,6 +234,8 @@ type CoreService struct {
runSessions map[string]domain.RunControlSession
runSessionSeq uint64
jobMu sync.Mutex
jobWaitMu sync.Mutex
jobWaiters map[string][]chan struct{}
bridgeMu sync.Mutex
bridgeSeq uint64
logStore LogBodyStore
@@ -279,6 +284,7 @@ func newCoreServiceWithLogStore(store repo.Store, logStore LogBodyStore, now fun
now: now,
authSessions: map[string]string{},
runSessions: map[string]domain.RunControlSession{},
jobWaiters: map[string][]chan struct{}{},
logStore: logStore,
logProjectionStates: map[string]map[string]pluginLogSequenceState{},
logEventSubscribers: map[uint64]logEventSubscriber{},
@@ -2516,6 +2522,9 @@ func (svc *CoreService) CreateJob(job domain.Job) (domain.Job, error) {
if err := svc.ensureJobLogStreams(existing, stamp); err != nil {
return domain.Job{}, err
}
if !isTerminalJobState(existing.State) {
svc.notifyRunJobWaiters(existing.RunEndpointID)
}
return existing, nil
}
if !errors.Is(err, repo.ErrNotFound) {
@@ -2555,6 +2564,7 @@ func (svc *CoreService) CreateJob(job domain.Job) (domain.Job, error) {
if err := svc.ensureJobLogStreams(job, stamp); err != nil {
return domain.Job{}, err
}
svc.notifyRunJobWaiters(job.RunEndpointID)
return domain.CopyJob(job), nil
}