P0-R5-R3 Research Design reset and workflow sync

#140
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -505,13 +505,19 @@ def _uploaded_material_descriptors() -> list[dict[str, str]]:
505
 
506
 
507
  def _method_intent_signature() -> str:
508
- """Stable identity for the manual Research Design control.
509
 
510
- Title and Keywords must never reset or auto-change the user's selected
511
- research design. The signature therefore identifies the control policy, not
512
- the topic text.
 
 
513
  """
514
- payload = {"research_design_control": "manual-default-qualitative-v1"}
 
 
 
 
515
  return hashlib.sha256(
516
  json.dumps(payload, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
517
  ).hexdigest()
@@ -1516,8 +1522,8 @@ def render_workspace_controls(user):
1516
  else:
1517
  # SmartPaper intentionally supports only two reader-visible research
1518
  # designs. New tasks default to qualitative research. The user may
1519
- # adjust the design manually; Title, Keywords, and uploaded materials
1520
- # never auto-select or reset the Research Design.
1521
  method_signature = _method_intent_signature()
1522
  stored = str(st.session_state.get("sp_method_confirmation") or "").strip().casefold()
1523
  stored_sig = str(st.session_state.get("sp_method_confirmation_signature") or "").strip()
 
505
 
506
 
507
  def _method_intent_signature() -> str:
508
+ """Identity for the manual Research Design control and current paper intent.
509
 
510
+ A new task defaults to Qualitative Research. If the user manually selects
511
+ Survey-Based Quantitative Research, changing the Title or Keywords resets
512
+ the design to Qualitative Research so the workflow and recommended template
513
+ return to the qualitative/ASQ lane together. Uploaded materials do not reset
514
+ the selection.
515
  """
516
+ payload = {
517
+ "research_design_control": "manual-default-qualitative-v2",
518
+ "topic": str(st.session_state.get("sp_topic") or DEFAULT_TOPIC).strip(),
519
+ "keywords": str(st.session_state.get("sp_keywords") or DEFAULT_KEYWORDS).strip(),
520
+ }
521
  return hashlib.sha256(
522
  json.dumps(payload, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
523
  ).hexdigest()
 
1522
  else:
1523
  # SmartPaper intentionally supports only two reader-visible research
1524
  # designs. New tasks default to qualitative research. The user may
1525
+ # adjust the design manually. Changing Title or Keywords resets a manual
1526
+ # survey selection to qualitative; uploaded materials do not reset it.
1527
  method_signature = _method_intent_signature()
1528
  stored = str(st.session_state.get("sp_method_confirmation") or "").strip().casefold()
1529
  stored_sig = str(st.session_state.get("sp_method_confirmation_signature") or "").strip()