fix: consistent error reporting + reset mapping modal per account

Error consistency: folder-level failures were counted only toward the task's
done_with_errors status, not the account's error_count, so a task showed
DONE_WITH_ERRORS while its only account showed 0 errors / DONE. Now folder
errors increment the account counter and the account status becomes
done_with_errors when errs>0.

Visibility: persist accounts.last_error (migration 0002) so the failing folder
/ login error survives a page reload (shown red under the source login);
cleared at the start of each run.

Modal reset: the folder-mapping modal kept its selections across opens, so
adding a second account showed the first account's mapping. It now mounts
fresh per add (conditional render + key), reflecting the newly-probed folders.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
This commit is contained in:
2026-07-02 15:14:11 +07:00
parent cdb93926bf
commit 477077d9e3
8 changed files with 59 additions and 15 deletions
+10 -2
View File
@@ -18,6 +18,7 @@ type Account struct {
Copied int64
Skipped int64
Errors int64
LastError string
}
func (s *Store) CreateAccount(ctx context.Context, a Account) (int64, error) {
@@ -38,7 +39,7 @@ func (s *Store) DeleteAccount(ctx context.Context, id int64) error {
func (s *Store) ListAccountsByTask(ctx context.Context, taskID int64) ([]Account, error) {
rows, err := s.Pool.Query(ctx,
`SELECT id, task_id, src_login, src_pass_enc, dst_login, dst_pass_enc,
test_src_status, test_dst_status, status, copied_count, skipped_count, error_count
test_src_status, test_dst_status, status, copied_count, skipped_count, error_count, last_error
FROM accounts WHERE task_id=$1 ORDER BY id`, taskID)
if err != nil {
return nil, err
@@ -48,7 +49,7 @@ func (s *Store) ListAccountsByTask(ctx context.Context, taskID int64) ([]Account
for rows.Next() {
var a Account
if err := rows.Scan(&a.ID, &a.TaskID, &a.SrcLogin, &a.SrcPassEnc, &a.DstLogin, &a.DstPassEnc,
&a.TestSrcStatus, &a.TestDstStatus, &a.Status, &a.Copied, &a.Skipped, &a.Errors); err != nil {
&a.TestSrcStatus, &a.TestDstStatus, &a.Status, &a.Copied, &a.Skipped, &a.Errors, &a.LastError); err != nil {
return nil, err
}
out = append(out, a)
@@ -56,6 +57,13 @@ func (s *Store) ListAccountsByTask(ctx context.Context, taskID int64) ([]Account
return out, rows.Err()
}
// SetAccountError stores (or clears, with "") the last error message shown for
// an account, so it survives a page reload after the run's live log is gone.
func (s *Store) SetAccountError(ctx context.Context, id int64, msg string) error {
_, err := s.Pool.Exec(ctx, `UPDATE accounts SET last_error=$2 WHERE id=$1`, id, msg)
return err
}
// side = "src" | "dst"
func (s *Store) SetAccountTestStatus(ctx context.Context, id int64, side, status string) error {
col := "test_src_status"