debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[blackbox] blackbox and pretty print sources should be persisted

Open jasonLaster opened this issue 9 years ago • 21 comments

It would be great if we could persist blackbox state like we persist tabs. This way, when you come back, the same sources are still blackboxed.

jasonLaster avatar Aug 08 '17 20:08 jasonLaster

This is a start on this issue:

diff --git a/src/actions/sources.js b/src/actions/sources.js
index 5e644db3..6027e169 100644
--- a/src/actions/sources.js
+++ b/src/actions/sources.js
@@ -92,6 +92,7 @@ export function newSource(source: Source) {
     }
 
     await checkSelectedSource(getState(), dispatch, source);
+    await checkPendingTabs(getState(), dispatch, source); // this should restore blackbox state for sources
     await checkPendingBreakpoints(getState(), dispatch, source);
   };
 }
@@ -244,10 +245,10 @@ export function addTab(source: Source, tabIndex: number) {
   };
 }
 
-export function moveTab(url: string, tabIndex: number) {
+export function moveTab(source: Source, tabIndex: number) {
   return {
     type: "MOVE_TAB",
-    url,
+    source,
     tabIndex
   };
 }
diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index 2004e4d8..a5add58b 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -301,7 +301,7 @@ class SourceTabs extends PureComponent {
     const hiddenSourceTabs = getHiddenTabs(sourceTabs, sourceTabEls);
 
     if (isVisible() && hiddenSourceTabs.indexOf(selectedSource) !== -1) {
-      return moveTab(selectedSource.get("url"), 0);
+      return moveTab(selectedSource.toJS(), 0);
     }
 
     this.setState({ hiddenSourceTabs });
@@ -319,7 +319,7 @@ class SourceTabs extends PureComponent {
 
     const onClick = () => {
       const tabIndex = 0;
-      moveTab(source.get("url"), tabIndex);
+      moveTab(source.toJS(), tabIndex);
     };
     return (
       <li key={source.get("id")} onClick={onClick}>
diff --git a/src/reducers/sources.js b/src/reducers/sources.js
index ddb14e34..929a69dd 100644
--- a/src/reducers/sources.js
+++ b/src/reducers/sources.js
@@ -102,12 +102,12 @@ function update(
 
     case "ADD_TAB":
       return state.merge({
-        tabs: updateTabList({ sources: state }, action.source.url)
+        tabs: updateTabList({ sources: state }, action.source)
       });
 
     case "MOVE_TAB":
       return state.merge({
-        tabs: updateTabList({ sources: state }, action.url, action.tabIndex)
+        tabs: updateTabList({ sources: state }, action.source, action.tabIndex)
       });
 
     case "CLOSE_TAB":
@@ -203,18 +203,20 @@ function restoreTabs() {
  * @memberof reducers/sources
  * @static
  */
-function updateTabList(state: OuterState, url: ?string, tabIndex?: number) {
+function updateTabList(state: OuterState, source: ?Object, tabIndex?: number) {
   let tabs = state.sources.get("tabs");
 
-  const urlIndex = tabs.indexOf(url);
-  const includesUrl = !!tabs.find(tab => tab == url);
+  const urlIndex = tabs.indexOf(source.url);
+  const includesUrl = !!tabs.find(tab => tab.url == source.url);
+  const { url, isBlackboxed } = source;
+  const tab = { url, isBlackboxed }
 
   if (includesUrl) {
     if (tabIndex != undefined) {
-      tabs = tabs.delete(urlIndex).insert(tabIndex, url);
+      tabs = tabs.delete(urlIndex).insert(tabIndex, tab);
     }
   } else {
-    tabs = tabs.insert(0, url);
+    tabs = tabs.insert(0, tab);
   }
 
   prefs.tabs = tabs.toJS();
@@ -350,7 +352,7 @@ export const getSourcesForTabs = createSelector(
   getSources,
   (tabs: TabList, sources: SourcesMap) => {
     return tabs
-      .map(tab => getSourceByUrlInSources(sources, tab))
+      .map(tab => getSourceByUrlInSources(sources, tab.url))
       .filter(source => source);
   }
 );

codehag avatar Aug 31 '17 21:08 codehag

@jasonLaster @codehag I would like to tackle this bug. That would be kind of you that you could feedback on some questions, thanks:

  1. What is the blackboxed state?
  2. I found checkPendingTabs doesn't exist so it looks like we have to implement it. What is the purpose of this function, checking what "pending" tabs? I could found TabList [1] in the state's sources, which carries js sources even beyond the todo-mvc website (or "tab") at which I am debugging, see the screenshot below. Guess that tab list is what we should check?

[1] https://github.com/devtools-html/debugger.html/blob/c6fe43a2870c08feb985d5e1a2af4629389ea6ad/src/reducers/sources.js#L33

screen shot 2017-09-14 at 1 37 52 am

Fischer-L avatar Sep 13 '17 17:09 Fischer-L

Hey @Fischer-L I'm so sorry i missed this. In general, you should ping us in slack if you haven't heard from us.

I think this issue is a bit too complicated for a new comer... lets find another issue

jasonLaster avatar Sep 27 '17 16:09 jasonLaster

ok, thanks

Fischer-L avatar Sep 27 '17 16:09 Fischer-L

I am grabbing it

nyrosmith avatar Sep 27 '17 16:09 nyrosmith

/unclaim

nyrosmith avatar Nov 04 '17 11:11 nyrosmith

Done :+1:

claim avatar Nov 04 '17 11:11 claim

/claim

Fischer-L avatar Nov 14 '17 15:11 Fischer-L

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 14 '17 15:11 claim

@Fischer-L how is this going?

bomsy avatar Jan 03 '18 01:01 bomsy

@bomsy

how is this going?

Working on this. Sorry for the slow progress because the busy day jobs and the vacations at end of the year

Fischer-L avatar Jan 03 '18 02:01 Fischer-L

Status update (so we know this issue is still moving):

  • Done: save the prefs tabs with the BlackBoxed state, which is { url, isBlackBoxed }
  • To go: test the BlackBoxed state can be restored successfully

Fischer-L avatar Jan 14 '18 09:01 Fischer-L

nice, maybe PR the prefs work?

jasonLaster avatar Jan 14 '18 15:01 jasonLaster

Hey @Fischer-L how's it going?

jasonLaster avatar Jan 25 '18 02:01 jasonLaster

Hey @Fischer-L how's it going?

@jasonLaster during testing I found some difficulties so I am trying another approach. Will update soon.

Fischer-L avatar Jan 25 '18 09:01 Fischer-L

@jasonLaster PR #5195 is created for persisting the blackbox states, thanks.

And would like to check another question about persisting the pretty print. Below tried to pretty print one script then after reloading, the pretty printed script still existed. For persisting pretty print what behavior is expected here? 3601-pretty_print

Fischer-L avatar Jan 25 '18 11:01 Fischer-L

oh interesting. I think that is the expected behavior :)

jasonLaster avatar Jan 25 '18 13:01 jasonLaster

@Fischer-L still interested in this?

jasonLaster avatar Feb 27 '18 21:02 jasonLaster

@Fischer-L still interested in this?

Yes, will rebase and update again.

Fischer-L avatar Mar 01 '18 17:03 Fischer-L

thanks! also, do you have an issue/pr for the redux toggle all bps? @nyrosmith added a PR for this recently too...

jasonLaster avatar Mar 01 '18 17:03 jasonLaster