From 1bcc0d5dda5e5cdb35ecbd5511bbb0b52340ac53 Mon Sep 17 00:00:00 2001 From: vshnosngh Date: Wed, 28 Oct 2026 11:11:51 +0530 Subject: [PATCH] feat(khira): application-oriented error form with drafts and database cleanup --- internal/khira/db.go | 44 +++- internal/khira/handlers.go | 75 +++++- internal/khira/models.go | 15 +- internal/khira/store.go | 220 ++++++++++++++--- web/khira/app.js | 472 +++++++++++++++++++++++++++++++++---- web/khira/index.html | 4 +- web/khira/styles.css | 203 ++++++++++++++++ 7 files changed, 943 insertions(+), 90 deletions(-) diff --git a/internal/khira/db.go b/internal/khira/db.go index 6b3c0e6..116153d 100644 --- a/internal/khira/db.go +++ b/internal/khira/db.go @@ -113,6 +113,16 @@ CREATE TABLE IF NOT EXISTS errors ( created_by VARCHAR(64) NOT NULL DEFAULT '', request_payload TEXT NOT NULL DEFAULT '', archived BOOLEAN NOT NULL DEFAULT FALSE, + platform VARCHAR(32) NOT NULL DEFAULT 'iOS', + current_phase VARCHAR(64) NOT NULL DEFAULT 'development phase', + error_screen VARCHAR(128) NOT NULL DEFAULT '', + feature_name VARCHAR(128) NOT NULL DEFAULT '', + error_type VARCHAR(32) NOT NULL DEFAULT 'Bug', + description TEXT NOT NULL DEFAULT '', + image_url TEXT NOT NULL DEFAULT '', + additional_info TEXT NOT NULL DEFAULT '', + is_draft BOOLEAN NOT NULL DEFAULT FALSE, + assigned_to VARCHAR(64) NOT NULL DEFAULT '', created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); @@ -213,8 +223,23 @@ func connectDB(url string) (*sql.DB, error) { } func initSchema(db *sql.DB) error { - _, err := db.Exec(ddlSchema) - return err + if _, err := db.Exec(ddlSchema); err != nil { + return err + } + // Ensure application-oriented error columns exist + _, _ = db.Exec(` + ALTER TABLE errors ADD COLUMN IF NOT EXISTS platform VARCHAR(32) NOT NULL DEFAULT 'iOS'; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS current_phase VARCHAR(64) NOT NULL DEFAULT 'development phase'; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS error_screen VARCHAR(128) NOT NULL DEFAULT ''; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS feature_name VARCHAR(128) NOT NULL DEFAULT ''; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS error_type VARCHAR(32) NOT NULL DEFAULT 'Bug'; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS description TEXT NOT NULL DEFAULT ''; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS image_url TEXT NOT NULL DEFAULT ''; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS additional_info TEXT NOT NULL DEFAULT ''; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS is_draft BOOLEAN NOT NULL DEFAULT FALSE; + ALTER TABLE errors ADD COLUMN IF NOT EXISTS assigned_to VARCHAR(64) NOT NULL DEFAULT ''; + `) + return nil } func seedDefaultUsers(db *sql.DB) error { @@ -232,11 +257,6 @@ func seedDefaultUsers(db *sql.DB) error { avatar string }{ {"admin", "System Administrator", "admin", "team_lead", "Team Lead", "A"}, - {"charlie", "Charlie Diaz", "charlie123", "tester", "Tester", "๐Ÿ•ต๏ธโ€โ™‚๏ธ"}, - {"alice", "Alice Sharma", "alice123", "ios_dev", "iOS Dev", "๐Ÿ‘ฉโ€๐Ÿ’ป"}, - {"bob", "Bob Anderson", "bob123", "backend_dev", "Backend Dev", "๐Ÿ‘จโ€๐Ÿ’ป"}, - {"diana", "Diana Prince", "diana123", "android_dev", "Android Dev", "๐Ÿค–"}, - {"eva", "Eva Chen", "eva123", "designer", "Designer", "๐ŸŽจ"}, } for _, u := range defaultUsers { @@ -438,7 +458,8 @@ func SyncDatabases(primaryDB, backupDB *sql.DB) (map[string]any, error) { errRows, err := primaryDB.Query(` SELECT id, fingerprint, app_name, version, environment, service, endpoint, exception_type, message, stack_trace, severity, status, occurrences, first_seen, last_seen, resolved_at, resolved_by, - resolution_notes, linked_ticket_id, created_by, request_payload, archived, created_at + resolution_notes, linked_ticket_id, created_by, request_payload, archived, created_at, + platform, current_phase, error_screen, feature_name, error_type, description, image_url, additional_info, is_draft, assigned_to FROM errors `) if err != nil { @@ -449,8 +470,9 @@ func SyncDatabases(primaryDB, backupDB *sql.DB) (map[string]any, error) { errStmt, err := tx.Prepare(` INSERT INTO errors (id, fingerprint, app_name, version, environment, service, endpoint, exception_type, message, stack_trace, severity, status, occurrences, first_seen, last_seen, resolved_at, resolved_by, - resolution_notes, linked_ticket_id, created_by, request_payload, archived, created_at) - VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23) + resolution_notes, linked_ticket_id, created_by, request_payload, archived, created_at, + platform, current_phase, error_screen, feature_name, error_type, description, image_url, additional_info, is_draft, assigned_to) + VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33) `) if err != nil { return nil, err @@ -463,6 +485,7 @@ func SyncDatabases(primaryDB, backupDB *sql.DB) (map[string]any, error) { &e.ID, &e.Fingerprint, &e.AppName, &e.Version, &e.Environment, &e.Service, &e.Endpoint, &e.ExceptionType, &e.Message, &e.StackTrace, &e.Severity, &e.Status, &e.Occurrences, &e.FirstSeen, &e.LastSeen, &e.ResolvedAt, &e.ResolvedBy, &e.ResolutionNotes, &e.LinkedTicketID, &e.CreatedBy, &e.RequestPayload, &e.Archived, &e.CreatedAt, + &e.Platform, &e.CurrentPhase, &e.ErrorScreen, &e.FeatureName, &e.ErrorType, &e.Description, &e.ImageURL, &e.AdditionalInfo, &e.IsDraft, &e.AssignedTo, ); err != nil { return nil, err } @@ -470,6 +493,7 @@ func SyncDatabases(primaryDB, backupDB *sql.DB) (map[string]any, error) { e.ID, e.Fingerprint, e.AppName, e.Version, e.Environment, e.Service, e.Endpoint, e.ExceptionType, e.Message, e.StackTrace, e.Severity, e.Status, e.Occurrences, e.FirstSeen, e.LastSeen, e.ResolvedAt, e.ResolvedBy, e.ResolutionNotes, e.LinkedTicketID, e.CreatedBy, e.RequestPayload, e.Archived, e.CreatedAt, + e.Platform, e.CurrentPhase, e.ErrorScreen, e.FeatureName, e.ErrorType, e.Description, e.ImageURL, e.AdditionalInfo, e.IsDraft, e.AssignedTo, ); err != nil { return nil, err } diff --git a/internal/khira/handlers.go b/internal/khira/handlers.go index 0ee3208..601a3cc 100644 --- a/internal/khira/handlers.go +++ b/internal/khira/handlers.go @@ -144,6 +144,9 @@ func (s *Server) RegisterRoutes(r chi.Router) { api.Post("/errors", s.handleIngestError) api.Get("/errors/stats", s.handleErrorStats) api.Get("/errors/{id}", s.handleGetError) + api.Put("/errors/{id}", s.handleUpdateError) + api.Post("/errors/{id}", s.handleUpdateError) + api.Delete("/errors/{id}", s.handleDeleteError) api.Put("/errors/{id}/status", s.handleUpdateErrorStatus) api.Post("/errors/{id}/status", s.handleUpdateErrorStatus) api.Post("/errors/{id}/escalate", s.handleEscalateError) @@ -1177,7 +1180,7 @@ func (s *Server) handleIngestError(w http.ResponseWriter, r *http.Request) { } var ticket *Ticket - if assignee != "" && actor != nil { + if !saved.IsDraft && assignee != "" && actor != nil { title := fmt.Sprintf("[%s] %s: %s", saved.AppName, saved.ExceptionType, saved.Message) if len(title) > 80 { title = title[:77] + "..." @@ -1196,6 +1199,76 @@ func (s *Server) handleIngestError(w http.ResponseWriter, r *http.Request) { }) } +func (s *Server) handleUpdateError(w http.ResponseWriter, r *http.Request) { + actor := s.getActor(r) + if actor == nil { + s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Please sign in to update errors"}) + return + } + id := chi.URLParam(r, "id") + + var req struct { + AppError + AssignedTo string `json:"assigned_to"` + AssigneeUsername string `json:"assignee_username"` + Notes string `json:"notes"` + } + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Invalid request payload"}) + return + } + + assignee := strings.TrimSpace(req.AssignedTo) + if assignee == "" { + assignee = strings.TrimSpace(req.AssigneeUsername) + } + if assignee != "" { + req.AppError.AssignedTo = assignee + } + + updated, err := s.Store.UpdateError(id, &req.AppError, actor) + if err != nil { + s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()}) + return + } + + var ticket *Ticket + if !updated.IsDraft && assignee != "" && updated.LinkedTicketID == "" { + title := fmt.Sprintf("[%s] %s: %s", updated.AppName, updated.ExceptionType, updated.Message) + if len(title) > 80 { + title = title[:77] + "..." + } + t, errItem, errEsc := s.Store.EscalateErrorToTicket(updated.ID, title, assignee, updated.Severity, req.Notes, actor) + if errEsc == nil { + ticket = t + updated = errItem + } + } + + s.writeJSON(w, http.StatusOK, map[string]any{ + "status": "ok", + "error": updated, + "ticket": ticket, + }) +} + +func (s *Server) handleDeleteError(w http.ResponseWriter, r *http.Request) { + actor := s.getActor(r) + if actor == nil { + s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Please sign in to delete errors"}) + return + } + id := chi.URLParam(r, "id") + if err := s.Store.DeleteError(id, actor); err != nil { + s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()}) + return + } + s.writeJSON(w, http.StatusOK, map[string]any{ + "status": "ok", + "id": id, + }) +} + func (s *Server) handleUpdateErrorStatus(w http.ResponseWriter, r *http.Request) { actor := s.getActor(r) if actor == nil { diff --git a/internal/khira/models.go b/internal/khira/models.go index 3142e37..3ec9408 100644 --- a/internal/khira/models.go +++ b/internal/khira/models.go @@ -167,6 +167,7 @@ const ( ErrorStatusInvestigating ErrorStatus = "investigating" ErrorStatusResolved ErrorStatus = "resolved" ErrorStatusIgnored ErrorStatus = "ignored" + ErrorStatusDraft ErrorStatus = "draft" ) type AppError struct { @@ -181,7 +182,7 @@ type AppError struct { Message string `json:"message"` StackTrace string `json:"stack_trace"` Severity string `json:"severity"` // critical, high, medium, low - Status string `json:"status"` // unresolved, investigating, resolved, ignored + Status string `json:"status"` // unresolved, investigating, resolved, ignored, draft Occurrences int `json:"occurrences"` FirstSeen time.Time `json:"first_seen"` LastSeen time.Time `json:"last_seen"` @@ -194,6 +195,18 @@ type AppError struct { Archived bool `json:"archived"` CreatedAt time.Time `json:"created_at"` Tags []string `json:"tags,omitempty"` + + // Application-oriented error fields + Platform string `json:"platform"` // iOS or Android + CurrentPhase string `json:"current_phase"` // development phase or ready to live + ErrorScreen string `json:"error_screen"` // screen or view where error occurred + FeatureName string `json:"feature_name"` // feature name + ErrorType string `json:"error_type"` // Bug or Crash + Description string `json:"description"` // user description of error + ImageURL string `json:"image_url"` // attached image URL + AdditionalInfo string `json:"additional_info"` // any additional info + IsDraft bool `json:"is_draft"` // draft flag + AssignedTo string `json:"assigned_to"` // assigned developer or recipient username } type Notification struct { diff --git a/internal/khira/store.go b/internal/khira/store.go index 090fb10..c9da842 100644 --- a/internal/khira/store.go +++ b/internal/khira/store.go @@ -1267,31 +1267,82 @@ func (s *Store) MarkNotificationsRead(username string) { // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ func (s *Store) IngestError(errItem *AppError, actor *User) (*AppError, error) { - - if errItem.AppName == "" || errItem.ExceptionType == "" || errItem.Message == "" { - return nil, errors.New("app_name, exception_type and message are required") + // Normalize defaults for application-oriented error reports + if errItem.Platform == "" { + errItem.Platform = "iOS" + } + if errItem.CurrentPhase == "" { + errItem.CurrentPhase = "development phase" + } + if errItem.ErrorType == "" { + errItem.ErrorType = "Bug" + } + if errItem.Description != "" && errItem.Message == "" { + errItem.Message = errItem.Description + } + if errItem.ErrorType != "" && errItem.ExceptionType == "" { + errItem.ExceptionType = errItem.ErrorType + } + if errItem.FeatureName != "" && errItem.Service == "" { + errItem.Service = errItem.FeatureName + } + if errItem.Severity == "" { + if strings.EqualFold(errItem.ErrorType, "Crash") { + errItem.Severity = "critical" + } else { + errItem.Severity = "medium" + } + } + if errItem.Environment == "" { + errItem.Environment = errItem.CurrentPhase } - // Fingerprint for deduplication - fpRaw := fmt.Sprintf("%s:%s:%s", errItem.AppName, errItem.ExceptionType, errItem.Message) - h := sha256.Sum256([]byte(fpRaw)) - fingerprint := fmt.Sprintf("%x", h)[:16] + if errItem.IsDraft { + errItem.Status = string(ErrorStatusDraft) + if errItem.AppName == "" { + errItem.AppName = "Draft Application" + } + if errItem.Message == "" { + errItem.Message = "(Draft Error)" + } + if errItem.ExceptionType == "" { + errItem.ExceptionType = "Bug" + } + } else { + if errItem.AppName == "" || errItem.Message == "" { + return nil, errors.New("app_name and description/message are required") + } + if errItem.ExceptionType == "" { + errItem.ExceptionType = "Bug" + } + if errItem.Status == "" || errItem.Status == string(ErrorStatusDraft) { + errItem.Status = string(ErrorStatusUnresolved) + } + } now := time.Now() - // Check if already exists with same fingerprint - var existingID string - var occurrences int - err := s.primaryDB.QueryRow(` - SELECT id, occurrences FROM errors WHERE fingerprint = $1 AND status != 'resolved' - `, fingerprint).Scan(&existingID, &occurrences) + // Only deduplicate non-draft errors + if !errItem.IsDraft { + fpRaw := fmt.Sprintf("%s:%s:%s", errItem.AppName, errItem.ExceptionType, errItem.Message) + h := sha256.Sum256([]byte(fpRaw)) + fingerprint := fmt.Sprintf("%x", h)[:16] + errItem.Fingerprint = fingerprint - if err == nil && existingID != "" { - // Update existing error occurrences - _, _ = s.primaryDB.Exec(` - UPDATE errors SET occurrences = occurrences + 1, last_seen = $1 WHERE id = $2 - `, now, existingID) - return s.GetError(existingID) + var existingID string + var occurrences int + err := s.primaryDB.QueryRow(` + SELECT id, occurrences FROM errors WHERE fingerprint = $1 AND status != 'resolved' AND is_draft = FALSE + `, fingerprint).Scan(&existingID, &occurrences) + + if err == nil && existingID != "" { + _, _ = s.primaryDB.Exec(` + UPDATE errors SET occurrences = occurrences + 1, last_seen = $1 WHERE id = $2 + `, now, existingID) + return s.GetError(existingID) + } + } else { + errItem.Fingerprint = "draft-" + uuid.New().String()[:8] } id, err := s.nextSeq("error_seq", "ERR") @@ -1299,11 +1350,9 @@ func (s *Store) IngestError(errItem *AppError, actor *User) (*AppError, error) { return nil, err } errItem.ID = id - errItem.Fingerprint = fingerprint errItem.Occurrences = 1 errItem.FirstSeen = now errItem.LastSeen = now - errItem.Status = string(ErrorStatusUnresolved) if actor != nil { errItem.CreatedBy = actor.Username } @@ -1311,35 +1360,126 @@ func (s *Store) IngestError(errItem *AppError, actor *User) (*AppError, error) { _, err = s.primaryDB.Exec(` INSERT INTO errors ( id, fingerprint, app_name, version, environment, service, endpoint, exception_type, message, - stack_trace, severity, status, occurrences, first_seen, last_seen, created_by, request_payload, created_at - ) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18) + stack_trace, severity, status, occurrences, first_seen, last_seen, created_by, request_payload, + platform, current_phase, error_screen, feature_name, error_type, description, image_url, additional_info, is_draft, assigned_to, created_at + ) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28) `, errItem.ID, errItem.Fingerprint, errItem.AppName, errItem.Version, errItem.Environment, errItem.Service, errItem.Endpoint, errItem.ExceptionType, errItem.Message, errItem.StackTrace, errItem.Severity, errItem.Status, errItem.Occurrences, errItem.FirstSeen, errItem.LastSeen, errItem.CreatedBy, - errItem.RequestPayload, now) + errItem.RequestPayload, errItem.Platform, errItem.CurrentPhase, errItem.ErrorScreen, errItem.FeatureName, + errItem.ErrorType, errItem.Description, errItem.ImageURL, errItem.AdditionalInfo, errItem.IsDraft, + errItem.AssignedTo, now) if err != nil { return nil, fmt.Errorf("failed to insert error: %w", err) } if s.Broker != nil { - s.Broker.Broadcast("error_logged", "", errItem.ID, "", "log", map[string]string{"app": errItem.AppName, "severity": errItem.Severity}) + actionType := "log" + if errItem.IsDraft { + actionType = "draft_created" + } + s.Broker.Broadcast("error_logged", "", errItem.ID, "", actionType, map[string]string{ + "app": errItem.AppName, "severity": errItem.Severity, "status": errItem.Status, "is_draft": fmt.Sprintf("%v", errItem.IsDraft), + }) } return errItem, nil } +func (s *Store) UpdateError(id string, u *AppError, actor *User) (*AppError, error) { + if u.Platform == "" { + u.Platform = "iOS" + } + if u.CurrentPhase == "" { + u.CurrentPhase = "development phase" + } + if u.ErrorType == "" { + u.ErrorType = "Bug" + } + if u.Description != "" && u.Message == "" { + u.Message = u.Description + } + if u.ErrorType != "" && u.ExceptionType == "" { + u.ExceptionType = u.ErrorType + } + if u.FeatureName != "" && u.Service == "" { + u.Service = u.FeatureName + } + if u.Severity == "" { + if strings.EqualFold(u.ErrorType, "Crash") { + u.Severity = "critical" + } else { + u.Severity = "medium" + } + } + if u.Environment == "" { + u.Environment = u.CurrentPhase + } + + if u.IsDraft { + u.Status = string(ErrorStatusDraft) + } else { + if u.Status == "" || u.Status == string(ErrorStatusDraft) { + u.Status = string(ErrorStatusUnresolved) + } + } + + now := time.Now() + _, err := s.primaryDB.Exec(` + UPDATE errors SET + app_name = $1, version = $2, environment = $3, service = $4, endpoint = $5, + exception_type = $6, message = $7, stack_trace = $8, severity = $9, status = $10, + platform = $11, current_phase = $12, error_screen = $13, feature_name = $14, + error_type = $15, description = $16, image_url = $17, additional_info = $18, + is_draft = $19, assigned_to = $20, last_seen = $21 + WHERE id = $22 + `, u.AppName, u.Version, u.Environment, u.Service, u.Endpoint, + u.ExceptionType, u.Message, u.StackTrace, u.Severity, u.Status, + u.Platform, u.CurrentPhase, u.ErrorScreen, u.FeatureName, + u.ErrorType, u.Description, u.ImageURL, u.AdditionalInfo, + u.IsDraft, u.AssignedTo, now, id) + if err != nil { + return nil, fmt.Errorf("failed to update error: %w", err) + } + + if s.Broker != nil { + actionType := "error_updated" + if !u.IsDraft { + actionType = "error_published" + } + s.Broker.Broadcast("error_updated", "", id, "", actionType, map[string]string{ + "app": u.AppName, "severity": u.Severity, "status": u.Status, "is_draft": fmt.Sprintf("%v", u.IsDraft), + }) + } + + return s.GetError(id) +} + +func (s *Store) DeleteError(id string, actor *User) error { + _, err := s.primaryDB.Exec("DELETE FROM errors WHERE id = $1", id) + if err != nil { + return err + } + if s.Broker != nil { + s.Broker.Broadcast("error_deleted", "", id, "", "delete", map[string]string{}) + } + return nil +} + func (s *Store) GetError(id string) (*AppError, error) { var e AppError err := s.primaryDB.QueryRow(` SELECT id, fingerprint, app_name, version, environment, service, endpoint, exception_type, message, stack_trace, severity, status, occurrences, first_seen, last_seen, resolved_at, resolved_by, - resolution_notes, linked_ticket_id, created_by, request_payload, archived + resolution_notes, linked_ticket_id, created_by, request_payload, archived, + platform, current_phase, error_screen, feature_name, error_type, description, image_url, additional_info, is_draft, assigned_to FROM errors WHERE id = $1 `, id).Scan( &e.ID, &e.Fingerprint, &e.AppName, &e.Version, &e.Environment, &e.Service, &e.Endpoint, &e.ExceptionType, &e.Message, &e.StackTrace, &e.Severity, &e.Status, &e.Occurrences, &e.FirstSeen, &e.LastSeen, &e.ResolvedAt, &e.ResolvedBy, &e.ResolutionNotes, &e.LinkedTicketID, &e.CreatedBy, &e.RequestPayload, &e.Archived, + &e.Platform, &e.CurrentPhase, &e.ErrorScreen, &e.FeatureName, &e.ErrorType, &e.Description, &e.ImageURL, &e.AdditionalInfo, &e.IsDraft, &e.AssignedTo, ) if err != nil { return nil, errors.New("error not found") @@ -1353,11 +1493,19 @@ func (s *Store) ListErrors(status, severity, app, query string) []*AppError { var args []any idx := 1 - if status != "" { - conds = append(conds, fmt.Sprintf("LOWER(status) = LOWER($%d)", idx)) + if strings.EqualFold(status, "draft") { + conds = append(conds, "is_draft = TRUE") + } else if strings.EqualFold(status, "all_with_drafts") { + // Include all + } else if status != "" { + conds = append(conds, fmt.Sprintf("LOWER(status) = LOWER($%d) AND is_draft = FALSE", idx)) args = append(args, status) idx++ + } else { + // Default: list non-draft errors + conds = append(conds, "is_draft = FALSE") } + if severity != "" { conds = append(conds, fmt.Sprintf("LOWER(severity) = LOWER($%d)", idx)) args = append(args, severity) @@ -1370,7 +1518,7 @@ func (s *Store) ListErrors(status, severity, app, query string) []*AppError { } if query != "" { q := "%" + strings.ToLower(query) + "%" - conds = append(conds, fmt.Sprintf("(LOWER(id) LIKE $%d OR LOWER(message) LIKE $%d OR LOWER(exception_type) LIKE $%d OR LOWER(endpoint) LIKE $%d)", idx, idx, idx, idx)) + conds = append(conds, fmt.Sprintf("(LOWER(id) LIKE $%d OR LOWER(message) LIKE $%d OR LOWER(description) LIKE $%d OR LOWER(exception_type) LIKE $%d OR LOWER(feature_name) LIKE $%d OR LOWER(error_screen) LIKE $%d OR LOWER(endpoint) LIKE $%d)", idx, idx, idx, idx, idx, idx, idx)) args = append(args, q) idx++ } @@ -1383,7 +1531,8 @@ func (s *Store) ListErrors(status, severity, app, query string) []*AppError { querySQL := fmt.Sprintf(` SELECT id, fingerprint, app_name, version, environment, service, endpoint, exception_type, message, stack_trace, severity, status, occurrences, first_seen, last_seen, resolved_at, resolved_by, - resolution_notes, linked_ticket_id, created_by, request_payload, archived + resolution_notes, linked_ticket_id, created_by, request_payload, archived, + platform, current_phase, error_screen, feature_name, error_type, description, image_url, additional_info, is_draft, assigned_to FROM errors %s ORDER BY last_seen DESC LIMIT 100 @@ -1402,6 +1551,7 @@ func (s *Store) ListErrors(status, severity, app, query string) []*AppError { &e.ID, &e.Fingerprint, &e.AppName, &e.Version, &e.Environment, &e.Service, &e.Endpoint, &e.ExceptionType, &e.Message, &e.StackTrace, &e.Severity, &e.Status, &e.Occurrences, &e.FirstSeen, &e.LastSeen, &e.ResolvedAt, &e.ResolvedBy, &e.ResolutionNotes, &e.LinkedTicketID, &e.CreatedBy, &e.RequestPayload, &e.Archived, + &e.Platform, &e.CurrentPhase, &e.ErrorScreen, &e.FeatureName, &e.ErrorType, &e.Description, &e.ImageURL, &e.AdditionalInfo, &e.IsDraft, &e.AssignedTo, ); err == nil { list = append(list, &e) } @@ -1419,9 +1569,10 @@ func (s *Store) GetErrorStats() map[string]int { "critical": 0, "high": 0, "escalated": 0, + "drafts": 0, } - rows, err := s.primaryDB.Query(`SELECT status, severity, linked_ticket_id FROM errors`) + rows, err := s.primaryDB.Query(`SELECT status, severity, linked_ticket_id, is_draft FROM errors`) if err != nil { return stats } @@ -1429,7 +1580,12 @@ func (s *Store) GetErrorStats() map[string]int { for rows.Next() { var st, sev, lk string - if err := rows.Scan(&st, &sev, &lk); err == nil { + var isDraft bool + if err := rows.Scan(&st, &sev, &lk, &isDraft); err == nil { + if isDraft { + stats["drafts"]++ + continue + } stats["total"]++ switch strings.ToLower(st) { case "unresolved": diff --git a/web/khira/app.js b/web/khira/app.js index 407ddc9..17276ad 100644 --- a/web/khira/app.js +++ b/web/khira/app.js @@ -66,7 +66,7 @@ const PRI=[['P0','P0 ยท Critical'],['P1','P1 ยท High'],['P2','P2 ยท Medium'],['P const SEV=[['CRITICAL','Critical'],['HIGH','High'],['MEDIUM','Medium'],['LOW','Low']]; const STAT={open:'Open',progress:'In progress',hold:'On hold',completed:'Completed'}; const COLS=[['open','var(--out)'],['progress','var(--pri)'],['hold','var(--on-warn-c)'],['completed','var(--on-ter-c)']]; -const EL={unresolved:'Unresolved',escalated:'Escalated',resolved:'Resolved'}; +const EL={draft:'Drafts',unresolved:'Unresolved',escalated:'Escalated',resolved:'Resolved'}; const EMOJIS=['โšก','๐Ÿ‘ฉโ€๐Ÿ’ป','๐Ÿ‘จโ€๐Ÿ’ป','๐Ÿ•ต๏ธโ€โ™‚๏ธ','๐Ÿ‘ค','๐Ÿš€','๐Ÿ›ก๏ธ','๐ŸŽจ','๐Ÿค–','๐ŸฆŠ','๐Ÿฆ‰','๐Ÿฆ','๐Ÿ”ฅ','๐Ÿ’ก','๐ŸŽฏ','โš™๏ธ','๐ŸŒŸ','๐Ÿ’ป']; /* โ”€โ”€ API โ”€โ”€ */ @@ -99,7 +99,7 @@ const priFull=t=>{ return 'Low'; }; const st=t=>{const s=(t.status||'open').toLowerCase();return s==='in_progress'?'progress':s==='on_hold'?'hold':s}; -const ek=e=>e.status==='resolved'?'resolved':e.escalated_ticket_id?'escalated':'unresolved'; +const ek=e=>(e.is_draft||e.status==='draft')?'draft':e.status==='resolved'?'resolved':(e.escalated_ticket_id||e.linked_ticket_id)?'escalated':'unresolved'; const isAdmin=u=>u&&(u.username==='admin'||u.role==='team_lead'||u.role==='lead'); const roleClass=u=>{ @@ -290,7 +290,7 @@ async function refresh(anim){ const [tr,ts,er,es,nr,ur]=await Promise.all([ api('/khira/api/tickets?limit=100'), api('/khira/api/stats'), - api('/khira/api/errors?limit=100'), + api('/khira/api/errors?status=all_with_drafts&limit=100'), api('/khira/api/errors/stats'), api('/khira/api/notifications'), api('/khira/api/users') @@ -497,28 +497,91 @@ function initBoardDragDrop(){ }); } +const verFmt=v=>!v?'':(String(v).toLowerCase().startsWith('v')?' ':' v')+esc(v); + /* โ”€โ”€ Errors View โ”€โ”€ */ function renderE(anim){ const s=S.es; - put('#estats',tile(s.total,'Total','et')+tile(s.unresolved,'Unresolved','eu')+tile(s.escalated,'Escalated','ee')+tile(s.resolved,'Resolved','er')); - const archErrCount=S.e.filter(e=>e.archived).length; - const eChips=[['','All'],...Object.entries(EL),['archived',`Archived (${archErrCount})`]]; + const draftCount=S.e.filter(e=>e.is_draft||e.status==='draft').length; + put('#estats',tile(s.total,'Total','et')+tile(s.unresolved,'Unresolved','eu')+tile(draftCount,'Drafts','ed')+tile(s.resolved,'Resolved','er')); + const archErrCount=S.e.filter(e=>e.archived&&!e.is_draft).length; + const eChips=[['','All Published'],['draft',`Drafts (${draftCount})`],['unresolved','Unresolved'],['escalated','Escalated'],['resolved','Resolved'],['archived',`Archived (${archErrCount})`]]; put('#eChips',chipRow(eChips,S.ef,'data-ef')); + const f=S.e.filter(e=>{ - if(S.ef==='archived'){ - if(!e.archived)return false; + const isDr=e.is_draft||e.status==='draft'; + if(S.ef==='draft'){ + if(!isDr)return false; + }else if(S.ef==='archived'){ + if(!e.archived||isDr)return false; + }else if(!S.ef){ + if(e.archived||isDr)return false; }else{ - if(e.archived)return false; - if(S.ef&&ek(e)!==S.ef)return false; + if(e.archived||isDr||ek(e)!==S.ef)return false; } - return!S.q||[e.id,e.exception_type,e.message,e.endpoint,e.app,e.app_name].join(' ').toLowerCase().includes(S.q); + return!S.q||[e.id,e.exception_type,e.message,e.description,e.endpoint,e.app,e.app_name,e.feature_name,e.error_screen,e.platform,e.assigned_to].join(' ').toLowerCase().includes(S.q); }); + + const draftBannerHtml=(draftCount>0&&S.ef!=='draft')?` +
+ ๐Ÿ“ You have ${draftCount} saved error draft(s) available to edit and send. + +
`:'' ; + $('#elist').classList.toggle('anim',!!anim); - put('#elist',f.length?f.map((e,i)=>{ + put('#elist',draftBannerHtml+(f.length?f.map((e,i)=>{ const sev=(e.severity||'MEDIUM').toUpperCase(),k=ek(e); const isArch=!!e.archived; - return`
${ic('error',16)}

${esc(e.exception_type)}

${esc(e.message)}

${esc(e.id)} ยท ${esc(e.app||e.app_name||'โ€”')} ยท ${esc(e.endpoint||'โ€”')}

${isArch?'Archived':EL[k]}${e.events||e.occurrences||1} events ยท ${ago(e.last_seen)}
`; - }).join(''):`
${ic('bug_report',36)}

No errors tracked.

`); + const isDr=e.is_draft||e.status==='draft'; + const platChip=`${e.platform==='Android'?'๐Ÿค– Android':'๐Ÿ iOS'}`; + const typeChip=`${esc(e.error_type||'Bug')}`; + const phaseChip=e.current_phase?`${esc(e.current_phase)}`:''; + + if(isDr){ + return`
+ ${ic('ticket',16)} +
+
+ Draft + ${platChip} + ${typeChip} + ${phaseChip} +
+

${esc(e.app_name||'Draft Application')}${verFmt(e.version)}${e.error_screen?' ยท '+esc(e.error_screen):''}

+

${esc(e.description||e.message||'(No description provided)')}

+

${esc(e.id)}${e.assigned_to?' ยท Sent to @'+esc(e.assigned_to):' ยท Unassigned'}${e.image_url?' ยท ๐Ÿ“ท Image attached':''}

+
+
+ + ${ago(e.last_seen||e.created_at)} +
+
`; + } + + return`
+ ${ic('error',16)} +
+
+ ${platChip} + ${typeChip} + ${phaseChip} +
+

${esc(e.app_name||e.app||'Application')}${verFmt(e.version)}${e.error_screen?' ยท '+esc(e.error_screen):''}${e.feature_name?' ('+esc(e.feature_name)+')':''}

+

${esc(e.description||e.message)}

+

${esc(e.id)}${e.assigned_to?' ยท Assigned to @'+esc(e.assigned_to):''}${e.image_url?' ยท ๐Ÿ“ท Image attached':''}

+
+
+ ${isArch?'Archived':EL[k]||k} + ${e.events||e.occurrences||1} events ยท ${ago(e.last_seen||e.created_at)} +
+
`; + }).join(''):`
${ic('bug_report',36)}

No errors tracked.

`)); + + $('#btnViewDrafts')?.addEventListener('click',()=>{ + S.ef='draft'; + renderE(true); + }); + put('#title','Error Tracking'); } @@ -1275,14 +1338,44 @@ function newTicket(){ /* โ”€โ”€ Error Details & Escalation โ”€โ”€ */ function errD(id){ - const e=S.e.find(x=>x.id===id);if(!e)return;const k=ek(e); + const e=S.e.find(x=>x.id===id);if(!e)return; + if(e.is_draft||e.status==='draft'){ + return reportErr(e); + } + const k=ek(e); const blk=(l,v)=>v?`

${l}

${esc(v)}
`:''; - const appName=e.app||e.app_name||''; + const appName=e.app_name||e.app||''; const isArch=!!e.archived; - dlg({wide:1,title:esc(e.exception_type),sub:esc(`${e.id} ยท ${appName}${e.environment?' ยท '+e.environment:''}`), - body:`
${esc(e.severity)}${isArch?'Archived':EL[k]}${e.events||e.occurrences||1} events ยท ${ago(e.last_seen)}
- ${appName?`
`:''} -

${esc(e.message)}

${blk('Endpoint',e.endpoint)}${blk('Stack trace',e.stack_trace)}${blk('Payload',e.payload||e.request_payload)}${e.escalated_ticket_id||e.linked_ticket_id?`

Escalated as ${esc(e.escalated_ticket_id||e.linked_ticket_id)}

`:''}${e.resolution_notes?`

Resolution: ${esc(e.resolution_notes)}

`:''}`, + + const platChip=`${e.platform==='Android'?'๐Ÿค– Android':'๐Ÿ iOS'}`; + const typeChip=`${esc(e.error_type||'Bug')}`; + const phaseChip=e.current_phase?`${esc(e.current_phase)}`:''; + + const imgHtml=e.image_url?`
+

Attached Image / Screenshot

+ + Error attachment + +
`:''; + + dlg({wide:1,title:esc(e.exception_type||e.error_type||'Application Error'),sub:esc(`${e.id} ยท ${appName}${verFmt(e.version)}${e.error_screen?' ยท Screen: '+e.error_screen:''}`), + body:`
+ ${esc(e.severity||'Medium')} + ${isArch?'Archived':EL[k]||k} + ${platChip} + ${typeChip} + ${phaseChip} + ${e.events||e.occurrences||1} events ยท ${ago(e.last_seen||e.created_at)} +
+ ${e.feature_name?`

Feature: ${esc(e.feature_name)}

`:''} + ${e.assigned_to?`

Assigned to Developer: @${esc(e.assigned_to)}

`:''} +
Description:
${esc(e.description||e.message)}
+ ${imgHtml} + ${blk('Additional Info & Reproduction',e.additional_info)} + ${blk('Endpoint / Route',e.endpoint)} + ${blk('Stack Trace / Logs',e.stack_trace)} + ${e.escalated_ticket_id||e.linked_ticket_id?`

Escalated as ${esc(e.escalated_ticket_id||e.linked_ticket_id)}

`:''} + ${e.resolution_notes?`

Resolution: ${esc(e.resolution_notes)}

`:''}`, ok:k==='resolved'?'Close':'Escalate to ticket', alt:k==='unresolved'?['Resolve',()=>resolveD(id)]:(k==='resolved'?[(isArch?'Restore':'Archive'),async()=>{ const actName=isArch?'unarchive':'archive'; @@ -1292,19 +1385,13 @@ function errD(id){ $('#dlg').close(); await refresh(); }]:undefined), - init:f=>{ - f.querySelector('#btnLogMoreForApp')?.addEventListener('click',()=>{ - $('#dlg').close(); - reportErr({app_name:appName,environment:e.environment,service:e.service,continue_app:true}); - }); - }, go:()=>k!=='resolved'&&escD(id)}); } function escD(id){ const e=S.e.find(x=>x.id===id); dlg({title:'Escalate error to ticket',sub:e.id, - body:fld('title','Ticket title',{req:1,v:`[${e.app||e.app_name}] ${e.exception_type}: ${e.message.slice(0,60)}`})+fld('priority','Priority',{t:'select',opts:PRI,v:'P1'})+fld('assignee','Assign to',{t:'select',opts:usOpts(1),req:1}), + body:fld('title','Ticket title',{req:1,v:`[${e.platform||'App'} ยท ${e.app||e.app_name}] ${e.exception_type||e.error_type}: ${e.message.slice(0,60)}`})+fld('priority','Priority',{t:'select',opts:PRI,v:'P1'})+fld('assignee','Assign to',{t:'select',opts:usOpts(1),req:1,v:e.assigned_to||''}), ok:'Escalate',go:async v=>{ const r=await api(`/khira/api/errors/${encodeURIComponent(id)}/escalate`,'POST',{title:v.title,priority:v.priority,assigned_to:v.assignee}); if(r._f){toast(r.error,'err');return false} @@ -1321,27 +1408,324 @@ function resolveD(id){ }}); } +/* โ”€โ”€ Application-Oriented Error Reporting Form with Drafts โ”€โ”€ */ function reportErr(prefill={}){ - const currentApp=prefill.app_name||prefill.app||''; - const continueMode=!!prefill.continue_app; + const isEdit=!!prefill.id; + const isDraft=!!(prefill.is_draft||prefill.status==='draft'); + const d=$('#dlg'); + d.className='wide'; - dlg({title:continueMode&¤tApp?`Testing Phase: Assigning Errors for ${esc(currentApp)}`:'Report runtime error', - sub:continueMode?'Log continuous errors for this application with automatic re-prompting.':'Simulate an exception from a service.', - body:fld('app','Application',{t:'select',opts:EAPPS,req:1,v:currentApp})+fld('exception_type','Exception type',{req:1,v:'InternalServerError',opts:['CrashException','NetworkTimeoutException','AuthTokenExpiredException','TextureBindingException','ShaderCompileError','OutOfMemoryError']})+fld('message','Message',{t:'area',rows:2,req:1,v:'Unexpected fatal crash on render loop'})+fld('severity','Severity',{t:'select',opts:SEV,v:'HIGH'})+fld('environment','Environment',{req:1,v:prefill.environment||'Production'})+fld('endpoint','Endpoint',{v:prefill.endpoint||'/api/v1/render'})+fld('stack_trace','Stack trace',{t:'area',rows:3,mono:1,v:'Error at Engine.render (engine.js:42:15)'}), - ok:continueMode?'Submit & Log Another':'Report error', - alt:continueMode?['Submit & Done',null]:undefined, - go:async v=>{ - const r=await api('/khira/api/errors','POST',{app_name:v.app,exception_type:v.exception_type,message:v.message,severity:v.severity.toLowerCase(),environment:v.environment,service:v.app,endpoint:v.endpoint,stack_trace:v.stack_trace}); - if(r._f){toast(r.error,'err');return false} - toast('Error reported'); - await refresh(); + const curPlatform=prefill.platform||'iOS'; + const curPhase=prefill.current_phase||'development phase'; + const curErrorType=prefill.error_type||'Bug'; + const curAppName=prefill.app_name||prefill.app||''; + const curVersion=prefill.version||''; + const curScreen=prefill.error_screen||''; + const curFeature=prefill.feature_name||prefill.service||''; + const curDesc=prefill.description||prefill.message||''; + const curAddInfo=prefill.additional_info||prefill.stack_trace||''; + const curImg=prefill.image_url||''; + const curAssignee=prefill.assigned_to||''; - if(continueMode){ - setTimeout(()=>{ - reportErr({app_name:v.app,environment:v.environment,endpoint:v.endpoint,continue_app:true}); - },150); + const titleText=isEdit?(isDraft?`Edit Error Draft ยท ${esc(prefill.id)}`:`Edit Error ยท ${esc(prefill.id)}`):'Report Application Error'; + const subText=isDraft?'Edit draft fields and send to developer or save for later.':'Submit application bugs and crashes, or save as draft before final publishing.'; + + d.innerHTML=`
+

${titleText}

+

${subText}

+ +
+ +
+
+ +
+ + +
+ +
+ +
+ +
+ + +
+ +
+
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + + + + +
+ +
+ + +
+ + Click to attach screenshot or drag & drop +
+
+ Attached preview +
+ ${curImg?esc(curImg.split('/').pop()):''} + +
+
+
+
+ + + + + + +
+ + +
+ + ${isEdit?``:''} +
+ + +
+
`; + + const form=$('#errReportForm'); + + // Interactive Pill Switchers + const bindPillGroup=(containerId, hiddenInputId)=>{ + const wrap=form.querySelector(containerId); + const inp=form.querySelector(hiddenInputId); + if(!wrap||!inp)return; + wrap.querySelectorAll('.seg-pill').forEach(btn=>{ + btn.onclick=()=>{ + wrap.querySelectorAll('.seg-pill').forEach(b=>b.classList.remove('on')); + btn.classList.add('on'); + inp.value=btn.dataset.v; + }; + }); + }; + bindPillGroup('#platformPills','#inputPlatform'); + bindPillGroup('#phasePills','#inputPhase'); + bindPillGroup('#errTypePills','#inputErrType'); + + // Image Upload Binding + const uploadBox=form.querySelector('#errImgUploadBox'); + const fileInput=form.querySelector('#errImgFileInput'); + const imgUrlInput=form.querySelector('#errImgUrlInput'); + const placeholder=form.querySelector('#errImgPlaceholder'); + const previewWrap=form.querySelector('#errImgPreviewWrap'); + const thumb=form.querySelector('#errImgThumb'); + const imgName=form.querySelector('#errImgName'); + const rmBtn=form.querySelector('#btnRmErrImg'); + + uploadBox.onclick=(e)=>{ + if(e.target.closest('#btnRmErrImg'))return; + fileInput.click(); + }; + + fileInput.onchange=async()=>{ + const file=fileInput.files[0]; + if(!file)return; + const fd=new FormData(); + fd.append('file',file); + try{ + toast('Uploading image...'); + const res=await fetch('/khira/api/upload',{ + method:'POST', + headers:{'X-Khira-User':S.u?.username||''}, + body:fd + }); + const data=await res.json(); + if(data.status==='ok'&&data.attachment){ + imgUrlInput.value=data.attachment.url; + thumb.src=data.attachment.url; + imgName.textContent=file.name; + placeholder.hidden=true; + previewWrap.hidden=false; + toast('Image attached'); + }else{ + toast(data.error||'Failed to upload image','err'); + } + }catch(err){ + toast('Upload failed','err'); } - }}); + }; + + rmBtn.onclick=(e)=>{ + e.stopPropagation(); + imgUrlInput.value=''; + fileInput.value=''; + thumb.src=''; + imgName.textContent=''; + placeholder.hidden=false; + previewWrap.hidden=true; + }; + + // Helper to collect payload + const getPayload=(asDraft)=>{ + const app=form.querySelector('#errAppName').value.trim()||(asDraft?'Draft Application':''); + const desc=form.querySelector('#errDesc').value.trim()||(asDraft?'(Draft description)':''); + const errType=form.querySelector('#inputErrType').value||'Bug'; + return { + platform:form.querySelector('#inputPlatform').value||'iOS', + current_phase:form.querySelector('#inputPhase').value||'development phase', + app_name:app, + version:form.querySelector('#errVersion').value.trim(), + error_screen:form.querySelector('#errScreen').value.trim(), + feature_name:form.querySelector('#errFeature').value.trim(), + error_type:errType, + exception_type:errType, + description:desc, + message:desc, + image_url:imgUrlInput.value, + additional_info:form.querySelector('#errAddInfo').value.trim(), + assigned_to:form.querySelector('#errAssigneeSelect').value, + is_draft:asDraft + }; + }; + + // Save as draft handler + form.querySelector('#btnSaveDraft')?.addEventListener('click',async()=>{ + const payload=getPayload(true); + const saveBtn=form.querySelector('#btnSaveDraft'); + await busy(saveBtn,async()=>{ + let r; + if(isEdit){ + r=await api(`/khira/api/errors/${encodeURIComponent(prefill.id)}`,'PUT',payload); + }else{ + r=await api('/khira/api/errors','POST',payload); + } + if(r._f||typeof r.error==='string'){ + toast((typeof r.error==='string'?r.error:'')||'Failed to save draft','err'); + return; + } + toast('Draft saved successfully'); + d.close(); + await refresh(); + }); + }); + + // Submit handler (Publish) + form.onsubmit=async(e)=>{ + e.preventDefault(); + const app=form.querySelector('#errAppName').value.trim(); + const desc=form.querySelector('#errDesc').value.trim(); + if(!app){toast('Please enter an app name','err');return} + if(!desc){toast('Please describe the error','err');return} + + const payload=getPayload(false); + const submitBtn=form.querySelector('#btnSubmitErr'); + await busy(submitBtn,async()=>{ + let r; + if(isEdit){ + r=await api(`/khira/api/errors/${encodeURIComponent(prefill.id)}`,'PUT',payload); + }else{ + r=await api('/khira/api/errors','POST',payload); + } + if(r._f||typeof r.error==='string'){ + toast((typeof r.error==='string'?r.error:'')||'Failed to submit error','err'); + return; + } + const sentNotice=payload.assigned_to?` and sent to @${payload.assigned_to}`:''; + toast(isEdit&&isDraft?`Draft published${sentNotice}`:`Error submitted${sentNotice}`); + d.close(); + await refresh(); + }); + }; + + // Delete draft / error handler + form.querySelector('#btnDeleteErr')?.addEventListener('click',async()=>{ + if(!confirm(`Are you sure you want to delete this ${isDraft?'draft':'error'}?`))return; + const r=await api(`/khira/api/errors/${encodeURIComponent(prefill.id)}`,'DELETE'); + if(r._f||r.error){ + toast(r.error||'Delete failed','err'); + return; + } + toast('Error removed'); + d.close(); + await refresh(); + }); + + if(!d.open)d.showModal(); } /* โ”€โ”€ Bulk Actions Management โ”€โ”€ */ diff --git a/web/khira/index.html b/web/khira/index.html index 5a98c33..4fb3c57 100644 --- a/web/khira/index.html +++ b/web/khira/index.html @@ -9,7 +9,7 @@ - + @@ -246,6 +246,6 @@
- + \ No newline at end of file diff --git a/web/khira/styles.css b/web/khira/styles.css index a7a5ef9..89bf2a1 100644 --- a/web/khira/styles.css +++ b/web/khira/styles.css @@ -2394,3 +2394,206 @@ dd { word-break: break-word; } border: 1px dashed rgba(56, 189, 248, 0.5) !important; border-radius: 18px !important; } + +/* โ”€โ”€ Application-Oriented Error Form & Drafts System โ”€โ”€ */ +#dlg.wide { + width: min(720px, calc(100% - 32px)); +} + +.err-form-grid { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 16px; +} +@media (max-width: 640px) { + .err-form-grid { + grid-template-columns: 1fr; + } +} +.err-form-full { + grid-column: 1 / -1; +} + +.form-seg-group { + display: flex; + flex-direction: column; + gap: 6px; +} +.form-seg-label { + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + color: var(--on-sv); +} +.seg-pills { + display: flex; + gap: 6px; + background: rgba(255, 255, 255, 0.04); + padding: 4px; + border-radius: 12px; + border: 1px solid rgba(255, 255, 255, 0.08); +} +.seg-pill { + flex: 1; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 12px; + font-size: 12px; + font-weight: 500; + border-radius: 8px; + border: none; + background: transparent; + color: var(--on-sv); + cursor: pointer; + transition: all 0.2s ease; +} +.seg-pill:hover { + color: var(--on-s); + background: rgba(255, 255, 255, 0.06); +} +.seg-pill.on { + background: rgba(255, 255, 255, 0.14); + color: #fff; + font-weight: 600; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2); +} +.seg-pill.bug-pill.on { + background: linear-gradient(135deg, rgba(234, 179, 8, 0.35) 0%, rgba(202, 138, 4, 0.2) 100%); + color: #fef08a; + border: 1px solid rgba(250, 204, 21, 0.4); +} +.seg-pill.crash-pill.on { + background: linear-gradient(135deg, rgba(239, 68, 68, 0.4) 0%, rgba(185, 28, 28, 0.25) 100%); + color: #fca5a5; + border: 1px solid rgba(248, 113, 113, 0.4); +} + +/* Image Attachment Dropzone */ +.err-attach-group { + display: flex; + flex-direction: column; + gap: 6px; +} +.err-upload-box { + background: rgba(255, 255, 255, 0.03); + border: 1px dashed rgba(255, 255, 255, 0.18); + border-radius: 14px; + padding: 14px; + text-align: center; + cursor: pointer; + transition: all 0.2s ease; +} +.err-upload-box:hover { + background: rgba(255, 255, 255, 0.06); + border-color: var(--pri); +} +.err-upload-placeholder { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + color: var(--on-sv); + font-size: 13px; +} +.err-upload-placeholder svg { + stroke: var(--pri); +} +.err-upload-preview { + display: flex; + align-items: center; + gap: 12px; + text-align: left; +} +.err-upload-preview img { + width: 60px; + height: 60px; + object-fit: cover; + border-radius: 10px; + border: 1px solid rgba(255, 255, 255, 0.15); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); +} +.err-upload-meta { + flex: 1; + display: flex; + flex-direction: column; + gap: 4px; + min-width: 0; +} +.err-upload-meta span { + font-size: 13px; + color: var(--on-s); + font-weight: 500; +} +.err-rm-img-btn { + align-self: flex-start; + color: #ef4444 !important; + font-size: 11px !important; + padding: 2px 8px !important; + height: 24px !important; +} + +/* Draft Banner in Errors View */ +.draft-banner { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 18px; + border-radius: 16px; + background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.08) 100%); + border: 1px solid rgba(245, 158, 11, 0.3); + margin-bottom: 16px; + font-size: 13px; + color: #fde68a; +} +.draft-banner b { + color: #fff; +} +.draft-btn { + background: rgba(245, 158, 11, 0.16) !important; + color: #fde68a !important; + border: 1px solid rgba(245, 158, 11, 0.35) !important; +} +.draft-btn:hover { + background: rgba(245, 158, 11, 0.28) !important; + color: #fff !important; +} +.stt.draft { + background: rgba(245, 158, 11, 0.2); + color: #fbbf24; + border: 1px solid rgba(245, 158, 11, 0.4); +} +.meta-chip { + display: inline-flex; + align-items: center; + gap: 4px; + font-size: 11px; + padding: 2px 8px; + border-radius: 6px; + background: rgba(255, 255, 255, 0.06); + color: var(--on-sv); + border: 1px solid rgba(255, 255, 255, 0.08); +} +.meta-chip.ios { + color: #38bdf8; + border-color: rgba(56, 189, 248, 0.3); + background: rgba(56, 189, 248, 0.1); +} +.meta-chip.android { + color: #4ade80; + border-color: rgba(74, 222, 128, 0.3); + background: rgba(74, 222, 128, 0.1); +} +.meta-chip.crash { + color: #f87171; + border-color: rgba(248, 113, 113, 0.3); + background: rgba(248, 113, 113, 0.1); +} +.meta-chip.bug { + color: #facc15; + border-color: rgba(250, 204, 21, 0.3); + background: rgba(250, 204, 21, 0.1); +} +