Skip to content

Conversation

@amhsirak
Copy link
Member

@amhsirak amhsirak commented Nov 4, 2025

Summary by CodeRabbit

  • Refactor
    • Unified name-editing experience across lists, text items, and screenshots — single, consistent start/save/cancel and keyboard/blur behavior.
    • Improved tab management and automatic tab selection when opening the capture drawer based on your most recent content type.
    • Enhanced focus and name-editing flow for all capture workflows, preserving existing public behavior.

@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

Walkthrough

Unified per-item editing state and handlers in the InterpretationLog component; consolidated list/text/screenshot edit flows and tab-switching logic using a single getLatestCaptureType() decision and generalized startEdit/saveEdit/cancelEdit flows.

Changes

Cohort / File(s) Summary
InterpretationLog refactor
src/components/run/InterpretationLog.tsx
Replaced multiple per-type editing states and handlers with a single editing object and unified startEdit, saveEdit, and cancelEdit flows. Centralized onBlur/onKeyDown handling, generalized save path to call updateListStepName / updateBrowserTextStepLabel / updateScreenshotStepName and emit actions. Consolidated tab-switching to use getLatestCaptureType() and unified post-drawer tab selection with existing timeouts (100ms/300ms). Adjusted rendering checks and focus/highlight logic to use the unified editing state.

Sequence Diagram(s)

sequenceDiagram
    participant UI as InterpretationLog UI
    participant EditState as Unified Editing State
    participant Store as Local State (steps/tabs)
    participant Backend as Backend / Emitter

    rect rgb(235,245,255)
    UI->>EditState: startEdit(stepId, type, currentValue)
    EditState-->>UI: isEditing=true (controls input render)
    end

    rect rgb(240,255,240)
    UI->>EditState: saveEdit() (onBlur / Enter)
    EditState->>Store: updateStepName(type, stepId, value)
    Store-->>UI: updated step data
    EditState->>Backend: emitForStepId(stepId, action)
    EditState-->>UI: isEditing=null
    end

    rect rgb(255,245,235)
    UI->>EditState: cancelEdit() (onEscape / blur)
    EditState-->>UI: revert value, isEditing=null
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to correctness of save routing for each type to the appropriate update function.
  • Verify emitForStepId calls and payloads for all edit types.
  • Check that focus/timeouts (100ms/300ms) preserve previous UX across tab switches and new-data flows.

Possibly related PRs

  • feat: faster output preview #583 — Modifies src/components/run/InterpretationLog.tsx and touches tab-switching/data-selection and editing flows (likely overlapping changes).

Suggested labels

Type: Enhancement

Poem

🐰
I nibbled at states until one remained,
One little object, neat and well-trained.
Tabs now follow the freshest sight,
Edits save true with a single light—
Hooray, one hop, one tidy byte! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: switch to active action data tab on capture' accurately describes the main change: switching to the appropriate content tab based on the latest captured data type using the getLatestCaptureType() logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tabswitch-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56aeb5e and 3717d7d.

📒 Files selected for processing (1)
  • src/components/run/InterpretationLog.tsx (5 hunks)
🔇 Additional comments (2)
src/components/run/InterpretationLog.tsx (2)

391-399: LGTM!

The getLatestCaptureType helper function correctly identifies the most recent capture type by iterating backward through browserSteps. The implementation is clean and straightforward.


403-434: Nice refactoring of tab-switching logic!

The unified approach using getLatestCaptureType() is cleaner than the previous separate conditionals. The implementation correctly:

  • Determines the most recent capture type
  • Switches to the appropriate tab based on that type
  • Preserves the existing auto-focus behavior for screenshots with proper timing delays

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3717d7d and 6b0fac6.

📒 Files selected for processing (1)
  • src/components/run/InterpretationLog.tsx (15 hunks)

Comment on lines +362 to 367
const screenshotSteps = browserSteps.filter(step => step.type === "screenshot");
const latestScreenshotStep = screenshotSteps[latestIndex];
if (latestScreenshotStep) {
const screenshotName = latestScreenshotStep.name || `Screenshot ${latestIndex + 1}`;
handleStartEditScreenshotName(latestScreenshotStep.id, screenshotName);
startEdit(latestScreenshotStep.id, 'screenshot', screenshotName);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix screenshot auto-edit targeting.

latestIndex is derived from screenshotData, which only includes steps where step.screenshotData exists. However, the follow-up lookup builds screenshotSteps from all screenshot steps (including ones without data), so the indexes can drift and we end up renaming the wrong step—or failing to rename at all—whenever a screenshot action is recorded before its payload arrives. Filter the steps the same way you populated screenshotData before indexing.

Apply this diff to keep the arrays aligned:

-                const screenshotSteps = browserSteps.filter(step => step.type === "screenshot");
-                const latestScreenshotStep = screenshotSteps[latestIndex];
+                const screenshotStepsWithData = browserSteps.filter(
+                  (step): step is { id: number; name?: string; type: 'screenshot'; screenshotData?: string } =>
+                    step.type === "screenshot" && step.screenshotData
+                );
+                const latestScreenshotStep = screenshotStepsWithData[latestIndex];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const screenshotSteps = browserSteps.filter(step => step.type === "screenshot");
const latestScreenshotStep = screenshotSteps[latestIndex];
if (latestScreenshotStep) {
const screenshotName = latestScreenshotStep.name || `Screenshot ${latestIndex + 1}`;
handleStartEditScreenshotName(latestScreenshotStep.id, screenshotName);
startEdit(latestScreenshotStep.id, 'screenshot', screenshotName);
}
const screenshotStepsWithData = browserSteps.filter(
(step): step is { id: number; name?: string; type: 'screenshot'; screenshotData?: string } =>
step.type === "screenshot" && step.screenshotData
);
const latestScreenshotStep = screenshotStepsWithData[latestIndex];
if (latestScreenshotStep) {
const screenshotName = latestScreenshotStep.name || `Screenshot ${latestIndex + 1}`;
startEdit(latestScreenshotStep.id, 'screenshot', screenshotName);
}
🤖 Prompt for AI Agents
In src/components/run/InterpretationLog.tsx around lines 362 to 367, the code
builds screenshotSteps from all steps but latestIndex was computed from
screenshotData (only steps with step.screenshotData), causing index drift; fix
by constructing screenshotSteps using the same filter used for screenshotData
(i.e., only include steps with step.screenshotData) so latestIndex maps to the
correct element, then use that filtered array to pick latestScreenshotStep and
call startEdit as before.

@amhsirak amhsirak merged commit f2453a3 into develop Nov 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants