aboutsummaryrefslogtreecommitdiffstats
path: root/renderer/src/components/NewSessionModal.tsx
blob: ad5dae967bc41d158e24ad04b7fdbb5d66f7aeb9 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { useState, useEffect } from "react";
import type { Phase } from "../types";

interface NewSessionModalProps {
  onConfirm: (phase: Phase) => void;
  onCancel: () => void;
}

const phaseOptions: { phase: Phase; label: string; description: string }[] = [
  { phase: "research",  label: "Research",  description: "Understand the codebase and requirements" },
  { phase: "plan",      label: "Plan",      description: "Create a detailed implementation strategy" },
  { phase: "implement", label: "Implement", description: "Execute the implementation plan" },
];

export function NewSessionModal({ onConfirm, onCancel }: NewSessionModalProps) {
  const [selected, setSelected] = useState<Phase>("research");

  // Close on Escape
  useEffect(() => {
    const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onCancel(); };
    window.addEventListener("keydown", onKey);
    return () => window.removeEventListener("keydown", onKey);
  }, [onCancel]);

  return (
    <div className="modal-backdrop" onClick={onCancel}>
      <div className="modal" onClick={(e) => e.stopPropagation()}>

        <div className="modal-header">
          <span className="modal-title">New Session</span>
          <button className="modal-close" onClick={onCancel}>×</button>
        </div>

        <div className="modal-body">
          <p className="modal-prompt">Choose where to start</p>
          <div className="phase-cards">
            {phaseOptions.map(({ phase, label, description }) => (
              <button
                key={phase}
                className={`phase-card${selected === phase ? " selected" : ""}`}
                onClick={() => setSelected(phase)}
              >
                <span className="phase-card-label">{label}</span>
                <span className="phase-card-desc">{description}</span>
              </button>
            ))}
          </div>
        </div>

        <div className="modal-footer">
          <button className="modal-btn-secondary" onClick={onCancel}>Cancel</button>
          <button className="modal-btn-primary" onClick={() => onConfirm(selected)}>
            Create
          </button>
        </div>

      </div>
    </div>
  );
}